layui.use(['jquery', 'laytpl', 'table', 'miniTab', 'xmSelect'], function () { let $ = layui.jquery, table = layui.table, layer = layui.layer, xmSelect = layui.xmSelect, miniTab = layui.miniTab; /**** index begin ***/ //index页面 if ($('.location-index-page').length > 0) { miniTab.listen(); // 渲染表格 let listUrl = $('#table-container').data('url'); let insTb = table.render({ elem: '#table-container', toolbar: '#toolbar-tpl', defaultToolbar: [], url: listUrl, method: 'post', request: { pageName: 'page', limitName: 'size', }, parseData: function (res) { return { "code": res.code, //解析接口状态 "msg": res.msg, //解析提示文本 "count": res.data.total, //解析数据长度 "data": res.data.list //解析数据列表 }; }, page: true, cols: [[ {type: 'checkbox'}, {field: 'title', minWidth: 200, title: '配置标题'}, {field: 'name', minWidth: 200, title: '配置标识'}, {field: 'value', minWidth: 200, title: '值'}, {field: 'sort', align: 'center', title: '排序', edit: 'text'}, {templet: '#row-operate', align: 'center', title: '操作'} ]], done: function () { Tools.setInsTb(insTb); } }); } /*** index end ***/ // 操作页 add|edit if ($('.location-operate-page').length > 0) { let parentMenu = $('#parent-menu'); let menuList = parentMenu.data('menu') ? parentMenu.data('menu') : []; xmSelect.render({ el: '#parent-menu', paging: false, autoRow: true, radio: true, clickClose: true, name: 'group', tips: '请选择上级分类', direction: 'auto', height: 'auto', model: { icon: 'hidden', }, prop: { name: 'title', value: 'name', }, tree: { show: true, strict: false, clickCheck: true, expandedKeys: true, clickExpand: false }, theme: { color: '#1e84ff', }, data: menuList }); } });