layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect', 'soulTable'], function () { let $ = layui.jquery, form = layui.form, table = layui.table, layer = layui.layer, miniTab = layui.miniTab, soulTable = layui.soulTable; /** * index page */ if ($('.location-index-page').length > 0) { miniTab.listen(); let listUrl = $('#table-container').data('url'); let insTb = table.render({ elem: '#table-container', toolbar: '#toolbar-tpl', title: '留言数据表', defaultToolbar: [{ title: '搜索' , layEvent: 'search' , icon: 'layui-icon-search' }], url: listUrl, even: true, method: 'post', page: true, limit:20, limits: [20, 30, 50, 100, 200, 300, 500, 1000, 3000], request: { pageName: 'page', limitName: 'size', }, parseData: function (res) { return { "code": res.code, //解析接口状态 "msg": res.msg, //解析提示文本 "count": res.data.total, //解析数据长度 "data": res.data.list //解析数据列表 }; }, cols: [[ {type: 'checkbox'}, {field: 'user_name', width: 150, title: '留言用户'}, {field: 'user_tel', width:200, title: '联系电话'}, {field: 'created_at', width: 170, title: '创建时间'}, {field: 'content', minWidth: 250, title: '留言内容'}, // {templet: '#row-operate', width: 150, field: 'right', align: 'center', title: '操作', fixed: 'right'} ]], excel: { curPage: true, filename: '留言数据表.xlsx', }, done: function () { Tools.setInsTb(insTb); soulTable.render(this); } }); // toolbar 事件扩展 tableToolbarCallableEvent = ['exportExcel']; tableToolbarCallable = function (obj, ele, insTb) { let layEvent = obj.event; switch (layEvent) { case 'exportExcel': console.log('exportExcel'); soulTable.export(insTb); break; default: return false; } } } });