73 lines
2.4 KiB
JavaScript
Executable File
73 lines
2.4 KiB
JavaScript
Executable File
layui.use(['jquery', 'laytpl', 'table', 'form', 'miniTab'], function () {
|
|
let $ = layui.jquery,
|
|
form = layui.form,
|
|
table = layui.table,
|
|
layer = layui.layer,
|
|
miniTab = layui.miniTab;
|
|
|
|
miniTab.listen();
|
|
|
|
let customer = [
|
|
{field: 'nickname', title: '微信昵称'},
|
|
{field: 'real_name', title: '真实姓名'},
|
|
{field: 'position', title: '角色'},
|
|
{field: 'mobile', minWidth: 150, title: '手机号'},
|
|
{field: 'shares', title: '分享次数'},
|
|
{field: 'views', title: '客户浏览'},
|
|
{field: 'customer', title: '带来客户'},
|
|
{field: 'asks', title: '咨询数量'},
|
|
];
|
|
let staff = [
|
|
{field: 'nickname', title: '微信昵称'},
|
|
{field: 'staff_name', title: '真实姓名'},
|
|
{field: 'position', title: '职位'},
|
|
{field: 'dept_name', title: '部门'},
|
|
{field: 'staff_phone', minWidth: 150, title: '手机号'},
|
|
{field: 'shares', title: '分享次数'},
|
|
{field: 'views', title: '客户浏览'},
|
|
{field: 'customer', title: '带来客户'},
|
|
{field: 'asks', title: '咨询数量'},
|
|
];
|
|
|
|
// 渲染表格
|
|
let listUrl = $('#table-container').data('url');
|
|
let type = $('#table-container').data('type');
|
|
|
|
let column = type === 'staff' ? staff : customer;
|
|
let insTb = table.render({
|
|
elem: '#table-container',
|
|
toolbar: '#toolbar-tpl',
|
|
defaultToolbar: ['filter', 'exports'],
|
|
url: listUrl,
|
|
method: 'post',
|
|
limits: [10, 20, 50, 100, 200, 500, 1000, 2000],
|
|
request: {
|
|
pageName: 'page',
|
|
limitName: 'size',
|
|
},
|
|
skin: 'line',
|
|
parseData: function (res) {
|
|
return {
|
|
"code": res.code, //解析接口状态
|
|
"msg": res.msg, //解析提示文本
|
|
"count": res.data.total, //解析数据长度
|
|
"data": res.data.list //解析数据列表
|
|
};
|
|
},
|
|
page: true,
|
|
cols: [column],
|
|
done: function () {
|
|
}
|
|
});
|
|
|
|
//监听工具条 注意区别toolbar和tool toolbar是表头上的工具条 tool是行中的工具条
|
|
table.on('toolbar(table-container)', function (obj) {
|
|
let layEvent = obj.event;
|
|
|
|
if (layEvent === 'refresh') {
|
|
insTb.reload();
|
|
return false;
|
|
}
|
|
|
|
});
|
|
}); |