2023-01-09 08:41:41 +00:00
|
|
|
|
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', width: 80, title: '用户ID'},
|
|
|
|
|
{field: 'nickname', width: 150, title: '微信昵称'},
|
|
|
|
|
{field: 'real_name', width: 100, title: '姓名'},
|
|
|
|
|
{field: 'mobile', width: 120, title: '电话'},
|
|
|
|
|
{field: 'role_text', minWidth: 100, title: '身份'},
|
|
|
|
|
{field: 'position_text', minWidth: 100, title: '岗位', hide: true},
|
|
|
|
|
{field: 'worksite_name', minWidth: 100, title: '所属工地', hide: true},
|
|
|
|
|
{field: 'pay', minWidth: 100, title: '薪资', hide: true},
|
|
|
|
|
{field: 'emergency_contact', minWidth: 180, title: '紧急联系人', hide: true},
|
|
|
|
|
{field: 'emergency_phone', minWidth: 180, title: '紧急联系人电话', hide: true},
|
|
|
|
|
{field: 'bank_card_name', minWidth: 180, title: '银行卡户名', hide: true},
|
|
|
|
|
{field: 'bank_card_number', minWidth: 180, title: '银行卡号', hide: true},
|
|
|
|
|
{field: 'bank_name', minWidth: 180, title: '开户行', hide: true},
|
|
|
|
|
{field: 'card_number', minWidth: 180, title: '身份证', hide: true},
|
|
|
|
|
{field: 'gender_text', minWidth: 80, title: '性别'},
|
|
|
|
|
{templet: '#row-operate', fixed: "right", minWidth: 250, title: '操作'},
|
|
|
|
|
]],
|
|
|
|
|
done: function () {
|
|
|
|
|
Tools.setInsTb(insTb);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//监听工具条 注意区别toolbar和tool toolbar是表头上的工具条 tool是行中的工具条
|
|
|
|
|
table.on('toolbar(table-container-filter)', function (obj) {
|
|
|
|
|
let layEvent = obj.event;
|
|
|
|
|
let insTb = Tools.getInsTb();
|
|
|
|
|
let url = $($(this).context).data('href')
|
|
|
|
|
let title = $($(this).context).data('title')
|
|
|
|
|
let width = $($(this).context).data('width') ? $($(this).context).data('width') : '100%';
|
|
|
|
|
let height = $($(this).context).data('height') ? $($(this).context).data('height') : '100%';
|
|
|
|
|
|
|
|
|
|
// debugger;
|
|
|
|
|
switch (layEvent) {
|
|
|
|
|
// toolbar 分配指定员工 分配客户标签 到店设置 来源设置
|
|
|
|
|
case 'tag':
|
|
|
|
|
let checkStatus = table.checkStatus('table-container');
|
|
|
|
|
if (checkStatus.data.length <= 0) {
|
|
|
|
|
layer.msg('请先选择数据');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let selected = checkStatus.data;
|
|
|
|
|
let ids = [];
|
|
|
|
|
|
|
|
|
|
$.each(selected, function (index, val) {
|
|
|
|
|
ids.push(val.id);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (ids.length > 500) {
|
|
|
|
|
layer.msg('一次操作请不要超过500条');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
url += '?id=' + ids;
|
|
|
|
|
openLayer(url, title, width, height);
|
|
|
|
|
return false;
|
|
|
|
|
// toolbar 刷新
|
|
|
|
|
case 'refresh':
|
|
|
|
|
refreshTab(insTb);
|
|
|
|
|
return false;
|
|
|
|
|
// toolbar 搜索
|
|
|
|
|
case 'search':
|
|
|
|
|
let search = $('.table-search-fieldset');
|
|
|
|
|
if (search.hasClass('div-show')) {
|
|
|
|
|
search.css('display', 'none').removeClass('div-show');
|
|
|
|
|
} else {
|
|
|
|
|
search.css('display', 'block').addClass('div-show');
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
// 其他 默认为打开弹出层
|
|
|
|
|
default:
|
|
|
|
|
if (layEvent !== 'LAYTABLE_COLS' && layEvent !== 'LAYTABLE_EXPORT') {
|
|
|
|
|
openLayer(url, title, width, height);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//监听行工具条
|
|
|
|
|
table.on('tool(table-container-filter)', function (obj) {
|
|
|
|
|
let data = obj.data;
|
|
|
|
|
let layEvent = obj.event;
|
|
|
|
|
let url = $($(this).context).data('href');
|
|
|
|
|
let title = $($(this).context).data('title');
|
|
|
|
|
let width = $($(this).context).data('width') ? $($(this).context).data('width') : '100%';
|
|
|
|
|
let height = $($(this).context).data('height') ? $($(this).context).data('height') : '100%';
|
|
|
|
|
let insTb = Tools.getInsTb();
|
|
|
|
|
|
|
|
|
|
switch (layEvent) {
|
|
|
|
|
// 行 删除
|
|
|
|
|
case 'del':
|
|
|
|
|
let ids = [data.id];
|
|
|
|
|
delRow(url, ids, insTb);
|
|
|
|
|
return false;
|
|
|
|
|
//其他 默认为打开弹出层
|
|
|
|
|
default:
|
|
|
|
|
openLayer(url, title, width, height);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 监听搜索操作
|
|
|
|
|
form.on('submit(data-search-btn)', function (data) {
|
|
|
|
|
//执行搜索重载
|
|
|
|
|
table.reload('table-container', {
|
|
|
|
|
page: {curr: 1}
|
|
|
|
|
, where: {searchParams: data.field}
|
|
|
|
|
}, 'data');
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/*** index end ***/
|
|
|
|
|
|
|
|
|
|
if ($('.location-tag-page').length > 0) {
|
|
|
|
|
let tagList = $('#tag-list');
|
|
|
|
|
let dataOne = tagList.data('data') ? tagList.data('data') : [];
|
|
|
|
|
var xmSelectObj = xmSelect.render({
|
|
|
|
|
el: '#tag-list',
|
|
|
|
|
paging: true,
|
|
|
|
|
autoRow: true,
|
|
|
|
|
name: 'tag_id',
|
|
|
|
|
tips: '请选择客户标签',
|
|
|
|
|
direction: 'auto',
|
|
|
|
|
height: 'auto',
|
|
|
|
|
prop: {
|
|
|
|
|
name: 'name',
|
|
|
|
|
value: 'id',
|
|
|
|
|
},
|
|
|
|
|
model: {
|
|
|
|
|
icon: 'hidden',
|
|
|
|
|
},
|
|
|
|
|
theme: {
|
|
|
|
|
color: '#1e84ff',
|
|
|
|
|
},
|
|
|
|
|
on: function(data){
|
|
|
|
|
//可以return一个数组, 代表想选中的数据
|
|
|
|
|
|
|
|
|
|
//arr: 当前多选已选中的数据
|
|
|
|
|
var arr = data.arr;
|
|
|
|
|
//change, 此次选择变化的数据,数组
|
|
|
|
|
var change = data.change;
|
|
|
|
|
//isAdd, 此次操作是新增还是删除
|
|
|
|
|
var isAdd = data.isAdd;
|
|
|
|
|
|
|
|
|
|
if(isAdd){
|
|
|
|
|
for(j = 0,len=change.length; j < len; j++) {
|
|
|
|
|
if(change[j].add != undefined && change[j].add==true){
|
|
|
|
|
console.log( change[j].name);
|
|
|
|
|
|
|
|
|
|
$.ajax('/manager/account-tag/add', {
|
|
|
|
|
data: {name: change[j].name},
|
|
|
|
|
async: false,
|
|
|
|
|
dataType: 'json',//服务器返回json格式数据
|
|
|
|
|
type: 'post',//HTTP请求类型
|
|
|
|
|
timeout: 10000,//超时时间设置为10秒;
|
|
|
|
|
success: function (res) {
|
|
|
|
|
// console.log(res)
|
|
|
|
|
if (res.code === 0) {
|
|
|
|
|
|
|
|
|
|
let id = res.data.id;
|
|
|
|
|
var name = change[j].name
|
|
|
|
|
var value = change[j].value
|
|
|
|
|
arr.find(function(item){
|
|
|
|
|
if(item.name === name){
|
|
|
|
|
item.id = id;
|
|
|
|
|
item.value = value;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
layer.msg("创建新标签成功");
|
|
|
|
|
//返回一个创建成功的对象, val是搜索的数据, arr是搜索后的当前页面数据
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
layer.msg("创建新标签失败");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: function (xhr, type, errorThrown) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
xmSelectObj.setValue(arr)
|
|
|
|
|
},
|
|
|
|
|
filterable: true,
|
|
|
|
|
create: function(val, arr){
|
|
|
|
|
|
|
|
|
|
if(arr.length === 0){
|
|
|
|
|
return {
|
|
|
|
|
name: "新增_" + val,
|
|
|
|
|
id: val,
|
|
|
|
|
value:val,
|
|
|
|
|
add:true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
data: dataOne
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 03:02:24 +00:00
|
|
|
|
laydate.render({
|
|
|
|
|
elem: '#star-date',
|
|
|
|
|
type: 'month',
|
|
|
|
|
});
|
2023-01-09 08:41:41 +00:00
|
|
|
|
});
|