building-sign/public/static/manager/js/pay/pay.js

300 lines
12 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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: 80, title: '用户ID'},
{field: 'time_text', minWidth: 120, title: '月份'},
{field: 'nickname', minWidth: 80, title: '昵称'},
{field: 'real_name', minWidth: 100, title: '姓名'},
{field: 'mobile', minWidth: 120, title: '电话'},
{field: 'position_text', minWidth: 80, title: '岗位'},
{field: 'worksite_name', minWidth: 100, title: '所属工地'},
{field: 'amount', minWidth: 100, title: '总计'},
{field: 'base_amount', minWidth: 100, title: '基本工资'},
{field: 'overtime_amount', minWidth: 100, title: '加班工资'},
{field: 'paid_amount', minWidth: 100, title: '已发工资'},
{field: 'status_text', minWidth: 100, title: '状态'},
{templet: '#row-operate', fixed: "right", minWidth: 100, 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
});
}
//编辑页面
if ($('.location-operate-page').length > 0) {
miniTab.listen();
// 渲染表格
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: false,
cols: [[
{type: 'checkbox'},
{field: 'id', minWidth: 80, title: '用户ID'},
{field: 'time_text', minWidth: 120, title: '月份'},
{field: 'nickname', minWidth: 80, title: '昵称'},
// {field: 'real_name', minWidth: 100, title: '姓名'},
// {field: 'mobile', minWidth: 120, title: '电话'},
// {field: 'position_text', minWidth: 80, title: '岗位'},
{field: 'worksite_name', minWidth: 100, title: '工作工地'},
{field: 'amount', minWidth: 100, title: '总计'},
{field: 'base_amount', minWidth: 100, title: '基本工资'},
{field: 'overtime_amount', minWidth: 100, title: '加班工资'},
{field: 'status_text', minWidth: 100, title: '状态'},
]],
done: function () {
Tools.setInsTb(insTb);
}
});
}
});