123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- {extend name="common/base"/}
- <!-- 主体 -->
- {block name="body"}
- <div class="p-3">
- <table class="layui-hide" id="test" lay-filter="test"></table>
- </div>
- <script type="text/html" id="status">
- <i class="layui-icon {{# if(d.status == 1){ }}green layui-icon-ok{{# } else { }}yellow layui-icon-close{{# } }}"></i>
- </script>
- <script type="text/html" id="toolbarDemo">
- <div class="layui-btn-container">
- <button class="layui-btn layui-btn-sm" lay-event="add">+ 添加岗位</button>
- </div>
- </script>
- <script type="text/html" id="barDemo">
- <div class="layui-btn-group"><button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button><button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button></div>
- </script>
- {/block}
- <!-- /主体 -->
- <!-- 脚本 -->
- {block name="script"}
- <script>
- const moduleInit = ['tool'];
- function gouguInit() {
- var table = layui.table, tool = layui.tool;
- layui.pageTable = table.render({
- elem: '#test',
- title: '岗位列表',
- toolbar: '#toolbarDemo',
- url: "/admin/position/index", //数据接口
- page: false, //开启分页
- cols: [
- [
- {
- field: 'id',
- title: 'ID号',
- align: 'center',
- width: 80
- },
- {
- field: 'd_title',
- title: '所属单位',
- align: 'center',
- width: 120
- },
- {
- field: 'title',
- title: '岗位名称',
- align: 'center',
- width: 120
- },
- {
- field: 'remark',
- title: '备注'
- },
- // {
- // field: 'work_price',
- // title: '岗位工时单价(元)',
- // align: 'center',
- // width: 132
- // },
- {
- field: 'status',
- title: '状态',
- toolbar: '#status',
- align: 'center',
- width: 60
- },
- {
- field: 'right',
- title: '操作',
- toolbar: '#barDemo',
- width: 120,
- align: 'center'
- }
- ]
- ]
- });
- //表头工具栏事件
- table.on('toolbar(test)', function(obj){
- if (obj.event === 'add') {
- tool.side("/admin/position/add");
- return;
- }
- });
- //监听行工具事件
- table.on('tool(test)', function (obj) {
- var data = obj.data;
- if(obj.event === 'edit'){
- tool.side('/admin/position/add?id='+data.id);
- return;
- }
- if (obj.event === 'del') {
- if (data.id == 1) {
- layer.msg('董事长职位不能删除');
- return;
- }
- layer.confirm('您确定要删除该岗位', {
- icon: 3,
- title: '提示'
- }, function (index) {
- let callback = function (e) {
- layer.msg(e.msg);
- if (e.code == 0) {
- obj.del();
- }
- }
- tool.delete("/admin/position/delete", { id: obj.data.id }, callback);
- layer.close(index);
- });
- }
- });
- }
- </script>
- {/block}
- <!-- /脚本 -->
|