204 lines
6.4 KiB
Plaintext
204 lines
6.4 KiB
Plaintext
let form, layer, table, tableIns;
|
||
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10
|
||
layui.use(['form', 'layer', 'table','laydate'], function () {
|
||
form = layui.form;
|
||
layer = layui.layer;
|
||
table = layui.table;
|
||
laydate = layui.laydate;
|
||
laydate.render({
|
||
elem: '#bandingDate', //指定元素 元素选择器
|
||
type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
|
||
trigger: 'click',
|
||
max: Date.parse(new Date()),
|
||
format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
|
||
btns: ['clear', 'now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定
|
||
done: function (value, date) { //时间回调
|
||
}
|
||
});
|
||
$('#bandingDate').val(getNowTime())
|
||
pages(1, 10, 1);
|
||
})
|
||
|
||
function pages(pageNum, pageSize, typeNum) {
|
||
let params = getReqParams(pageNum, pageSize, typeNum);
|
||
$.ajax({
|
||
headers: {
|
||
"encrypt": sm3(JSON.stringify(params))
|
||
},
|
||
url: dataUrl + "proteam/pot/duty/getUserBandingList?token=" + token,
|
||
data: params,
|
||
type: 'POST',
|
||
async: false,
|
||
success: function (result) {
|
||
if (result.code === 200) {
|
||
if (result.data) {
|
||
initTable(result.data, result.limit, result.curr)
|
||
laypages(result.count, result.curr, result.limit)
|
||
}
|
||
} else if (result.code === 500) {
|
||
layer.alert(result.msg, {icon: 2})
|
||
} else if (result.code === 401) {
|
||
logout(1);
|
||
}
|
||
}, error: function () {
|
||
}
|
||
});
|
||
}
|
||
|
||
function laypages(total, page, limit) {
|
||
layui.use(['laypage'], function () {
|
||
let laypage = layui.laypage;
|
||
laypage.render({
|
||
elem: 'voi-page',
|
||
count: total,
|
||
curr: page,
|
||
limit: limit,
|
||
limits: [10, 20, 50, 100, 200, 500],
|
||
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
|
||
groups: 5,
|
||
jump: function (obj, first) {
|
||
if (!first) {
|
||
pageNum = obj.curr, limitSize = obj.limit;
|
||
pages(obj.curr, obj.limit, null);
|
||
}
|
||
}
|
||
});
|
||
})
|
||
}
|
||
|
||
/*初始化表格*/
|
||
function initTable(dataList, limit, page) {
|
||
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
||
tableIns = table.render({
|
||
elem: "#vioTypeTable",
|
||
id: "vioTypeTable",
|
||
height: "full-150",
|
||
data: dataList,
|
||
limit: limit,
|
||
cols: [
|
||
[
|
||
//表头
|
||
{
|
||
title: "序号",
|
||
width: '10%',
|
||
unresize: true,
|
||
align: "center",
|
||
templet: function (d) {
|
||
return (page - 1) * limit + d.LAY_INDEX;
|
||
}
|
||
},
|
||
{
|
||
field: "loginName",
|
||
title: "登录名",
|
||
width: '25%',
|
||
unresize: true,
|
||
align: "center",
|
||
sort: true
|
||
},
|
||
{
|
||
field: "schedulingName",
|
||
title: "值班员姓名",
|
||
width: '25%',
|
||
unresize: true,
|
||
align: "center",
|
||
sort: true
|
||
},
|
||
{
|
||
field: "bandingDate",
|
||
title: "绑定日期",
|
||
width: '20%',
|
||
unresize: true,
|
||
align: "center",
|
||
sort: true
|
||
},
|
||
|
||
{
|
||
title: "操作",
|
||
width: '20%',
|
||
unresize: true,
|
||
align: "center",
|
||
templet: function (d) {
|
||
return "<a onclick=\"delData('" + d.id + '\')" style="color:#EB3330;">移除</a>';
|
||
}
|
||
}
|
||
],
|
||
],
|
||
done: function (res, curr, count) {
|
||
layer.close(loadingMsg);
|
||
table.resize("vioTypeTable");
|
||
count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block");
|
||
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
|
||
},
|
||
});
|
||
}
|
||
|
||
|
||
// 获取参数
|
||
function getReqParams(page, limit, type) {
|
||
let obj = {};
|
||
if (!type) {
|
||
obj = {
|
||
page: page + "",
|
||
limit: limit + "",
|
||
bandingDate: $('#bandingDate').val()
|
||
};
|
||
} else {
|
||
obj = {
|
||
page: '1',
|
||
limit: '10',
|
||
bandingDate: getNowTime()
|
||
};
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
// 查询/重置
|
||
function query() {
|
||
pageNum = 1;
|
||
pages(1, limitSize)
|
||
}
|
||
|
||
/*移除绑定值班员*/
|
||
function delData(id) {
|
||
layer.confirm("确定移除吗?", function () {
|
||
let loadingMsg = layer.msg('数据移除中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
||
$.ajax({
|
||
headers: {
|
||
"encrypt": sm3(JSON.stringify({
|
||
'id': id
|
||
}))
|
||
},
|
||
url: dataUrl + 'proteam/pot/duty/removeUserBanding?token=' + token,
|
||
data: {
|
||
'id': id,
|
||
},
|
||
type: 'post',
|
||
async: true,
|
||
success: function (result) {
|
||
layer.close(loadingMsg); // 关闭提示层
|
||
if (result.code === 200) {
|
||
parent.layer.msg(result.msg, {icon: 1})
|
||
query()
|
||
} else if (result.code === 500) {
|
||
layer.alert(result.msg, {icon: 2})
|
||
} else if (result.code === 401) {
|
||
logout(1);
|
||
}
|
||
}, error: function () {
|
||
layer.close(loadingMsg); // 关闭提示层
|
||
layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
|
||
}
|
||
});
|
||
})
|
||
}
|
||
|
||
/*刷新页面数据*/
|
||
function reloadData() {
|
||
pages(pageNum, limitSize);
|
||
}
|
||
|
||
// 关闭页面
|
||
function closePage() {
|
||
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
||
parent.layer.close(index); //再执行关闭
|
||
} |