| | |
| | | var pageCurr; |
| | | layui.use(['table','laydate', 'form'], function(){ |
| | | var tableRender; |
| | | |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" // 配置模块所在的目录 |
| | | }).use(['table','laydate', 'form','treeTable'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | var treetable = layui.treeTable; |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | | elem: '#tag', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/tag/list/auth', |
| | | page: true, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | | even: true, |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 50, |
| | | cols: [[ |
| | | {type: 'checkbox'} |
| | | // ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80} |
| | | ,{field: 'id', align: 'center',title: 'ID'} |
| | | ,{field: 'uuid', align: 'center',title: '编号'} |
| | | ,{field: 'name', align: 'center',title: '名称'} |
| | | ,{field: 'parentId', align: 'center',title: '父级'} |
| | | ,{field: 'parentName', align: 'center',title: '父级名称'} |
| | | ,{field: 'path', align: 'center',title: '关联路径'} |
| | | ,{field: 'pathName', align: 'center',title: '关联路径名'} |
| | | ,{field: 'type$', align: 'center',title: '类型'} |
| | | ,{field: 'leading', align: 'center',title: '负责人'} |
| | | ,{field: 'img', align: 'center',title: '图片'} |
| | | ,{field: 'brief', align: 'center',title: '简要描述'} |
| | | ,{field: 'count', align: 'center',title: '数量'} |
| | | ,{field: 'level', align: 'center',title: '等级'} |
| | | ,{field: 'sort', align: 'center',title: '排序'} |
| | | ,{field: 'status$', align: 'center',title: '状态'} |
| | | ,{field: 'createTime$', align: 'center',title: '添加时间'} |
| | | ,{field: 'createBy$', align: 'center',title: '添加人员',event: 'createBy', style: 'cursor:pointer'} |
| | | ,{field: 'updateTime$', align: 'center',title: '修改时间'} |
| | | ,{field: 'updateBy$', align: 'center',title: '修改人员',event: 'updateBy', style: 'cursor:pointer'} |
| | | ,{field: 'memo', align: 'center',title: '备注'} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | form.on('checkbox(tableCheckbox)', function (data) { |
| | | var _index = $(data.elem).attr('table-index')||0; |
| | | if(data.elem.checked){ |
| | | res.data[_index][data.value] = 'Y'; |
| | | }else{ |
| | | res.data[_index][data.value] = 'N'; |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(locMast)', function (obj) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | searchData['orderByField'] = obj.field; |
| | | searchData['orderByType'] = obj.type; |
| | | tableIns.reload({ |
| | | where: searchData, |
| | | page: { |
| | | curr: 1 |
| | | tableRender = function() { |
| | | var tableIdx = treetable.render({ |
| | | elem: '#tag', |
| | | url: baseUrl+'/tag/list/auth', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | height: 'full-200', |
| | | tree: { |
| | | iconIndex: 1, // 折叠图标显示在第几列 |
| | | isPidData: true, // 是否是id、pid形式数据 |
| | | idName: 'id', // id字段名称 |
| | | pidName: 'parentId' // pid字段名称 |
| | | }, |
| | | done: function (res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | toolbar: 'default', |
| | | cols: [[ |
| | | {type: 'checkbox'} |
| | | ,{field: 'uuid', align: 'center',title: '编号'} |
| | | ,{field: 'name', align: 'center',title: '名称'} |
| | | ,{field: 'parentId', align: 'center',title: '父级'} |
| | | ,{field: 'parentName', align: 'center',title: '父级名称'} |
| | | // ,{field: 'path', align: 'center',title: '关联路径'} |
| | | // ,{field: 'pathName', align: 'center',title: '关联路径名'} |
| | | ,{field: 'type$', align: 'center',title: '类型'} |
| | | ,{field: 'leading', align: 'center',title: '负责人'} |
| | | ,{field: 'img', align: 'center',title: '图片'} |
| | | ,{field: 'brief', align: 'center',title: '简要描述'} |
| | | ,{field: 'count', align: 'center',title: '数量'} |
| | | ,{field: 'level', align: 'center',title: '等级'} |
| | | ,{field: 'sort', align: 'center',title: '排序'} |
| | | ,{field: 'status$', align: 'center',title: '状态'} |
| | | ,{field: 'updateTime$', align: 'center',title: '修改时间'} |
| | | ,{field: 'updateBy$', align: 'center',title: '修改人员', hide: true} |
| | | ,{field: 'memo', align: 'center',title: '备注', hide: true} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} |
| | | ]], |
| | | done: function () { |
| | | tableIdx.expandAll(); |
| | | $(".ew-tree-table .ew-tree-table-tool .ew-tree-table-tool-item").css("display", "none"); |
| | | limit() |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | } |
| | | tableRender(); |
| | | |
| | | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(tag)', function (obj) { |
| | |
| | | table.on('tool(tag)', function(obj){ |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | // 详情 |
| | | case 'detail': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | | content: 'tag_detail.html', |
| | | success: function(layero, index){ |
| | | setFormVal(layer.getChildFrame('#detail', index), data, true); |
| | | top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); |
| | | layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('select'); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); |
| | | } |
| | | }); |
| | | break; |
| | | // 编辑 |
| | | case 'edit': |
| | | layer.open({ |
| | |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); |
| | | } |
| | | }); |
| | | break; |
| | | case 'createBy': |
| | | var param = top.reObject(data).createBy; |
| | | if (param === undefined) { |
| | | layer.msg("无数据"); |
| | | } else { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '添加人员详情', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | | content: '../user/user_detail.html', |
| | | success: function(layero, index){ |
| | | $.ajax({ |
| | | url: "baseUrl+/user/"+ param +"/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'GET', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | setFormVal(layer.getChildFrame('#detail', index), res.data, true); |
| | | top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); |
| | | layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('select'); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | case 'updateBy': |
| | | var param = top.reObject(data).updateBy; |
| | | if (param === undefined) { |
| | | layer.msg("无数据"); |
| | | } else { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '修改人员详情', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | | content: '../user/user_detail.html', |
| | | success: function(layero, index){ |
| | | $.ajax({ |
| | | url: "baseUrl+/user/"+ param +"/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'GET', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | setFormVal(layer.getChildFrame('#detail', index), res.data, true); |
| | | top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); |
| | | layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide(); |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('select'); |
| | | layero.find('iframe')[0].contentWindow.layui.form.render('checkbox'); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | |
| | | } |
| | |
| | | <div id="search-box" class="layui-form layui-card-header"> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="id" placeholder="编号" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline cool-auto-complete"> |
| | | <input id="createBy" class="layui-input" name="create_by" type="text" placeholder="请输入" autocomplete="off" style="display: none"> |
| | | <input id="createBy$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="添加人员" onfocus=this.blur()> |
| | | <div class="cool-auto-complete-window"> |
| | | <input class="cool-auto-complete-window-input" data-key="userQueryBycreateBy" onkeyup="autoLoad(this.getAttribute('data-key'))"> |
| | | <select class="cool-auto-complete-window-select" data-key="userQueryBycreateBySelect" onchange="confirmed(this.getAttribute('data-key'))" multiple="multiple"> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline cool-auto-complete"> |
| | | <input id="updateBy" class="layui-input" name="update_by" type="text" placeholder="请输入" autocomplete="off" style="display: none"> |
| | | <input id="updateBy$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="修改人员" onfocus=this.blur()> |
| | | <div class="cool-auto-complete-window"> |
| | | <input class="cool-auto-complete-window-input" data-key="userQueryByupdateBy" onkeyup="autoLoad(this.getAttribute('data-key'))"> |
| | | <select class="cool-auto-complete-window-select" data-key="userQueryByupdateBySelect" onchange="confirmed(this.getAttribute('data-key'))" multiple="multiple"> |
| | | </select> |
| | | </div> |
| | | <input class="layui-input" type="text" name="uuid" placeholder="编号" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | </script> |
| | | |
| | | <script type="text/html" id="operate"> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a> |
| | | <a class="layui-btn layui-btn-xs btn-edit" lay-event="edit">编辑</a> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">修改</a> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs btn-del" lay-event="del">删除</a> |
| | | </script> |
| | | |
| | | <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> |