79 lines
2.8 KiB
JavaScript
79 lines
2.8 KiB
JavaScript
|
layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect', 'laydate'], function () {
|
||
|
let $ = layui.jquery,
|
||
|
form = layui.form,
|
||
|
table = layui.table,
|
||
|
layer = layui.layer,
|
||
|
laydate = layui.laydate,
|
||
|
xmSelect = layui.xmSelect,
|
||
|
miniTab = layui.miniTab;
|
||
|
|
||
|
/**** index begin ***/
|
||
|
//index页面
|
||
|
if ($('.location-index-page').length > 0) {
|
||
|
miniTab.listen();
|
||
|
|
||
|
laydate.render({
|
||
|
elem: '#publish-date',
|
||
|
});
|
||
|
|
||
|
// 渲染表格
|
||
|
let listUrl = $('#table-container').data('url');
|
||
|
let insTb = table.render({
|
||
|
elem: '#table-container',
|
||
|
toolbar: '#toolbar-tpl',
|
||
|
defaultToolbar: ['filter', 'exports',{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
|
||
|
title: '搜索'
|
||
|
, layEvent: 'search'
|
||
|
, icon: 'layui-icon-search'
|
||
|
}],
|
||
|
url: listUrl,
|
||
|
method: 'post',
|
||
|
even: true,
|
||
|
limits: [10, 20, 50, 100, 200, 500, 1000, 2000],
|
||
|
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: 'id', minWidth: 50, title: '编号'},
|
||
|
{field: 'nickname', minWidth: 150, title: '微信昵称'},
|
||
|
{field: 'real_name', minWidth: 150, title: '真实姓名'},
|
||
|
{field: 'mobile', minWidth: 150, title: '电话'},
|
||
|
{field: 'channel_text', minWidth: 150, title: '客户来源'},
|
||
|
{field: 'share_source', minWidth: 150, title: '分享来源', templet: function (d) {
|
||
|
let s = '';
|
||
|
if (d.customer !== null) {
|
||
|
return d.customer.nickname;
|
||
|
}
|
||
|
return s;
|
||
|
}},
|
||
|
{field: 'created_at', minWidth: 200, title: '注册时间'},
|
||
|
]],
|
||
|
done: function () {
|
||
|
Tools.setInsTb(insTb);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// 监听搜索操作
|
||
|
form.on('submit(data-search-btn)', function (data) {
|
||
|
//执行搜索重载
|
||
|
table.reload('table-container', {
|
||
|
page: {curr: 1}
|
||
|
, where: {searchParams: data.field}
|
||
|
}, 'data');
|
||
|
|
||
|
return false;
|
||
|
});
|
||
|
}
|
||
|
/*** index end ***/
|
||
|
});
|