170 lines
4.9 KiB
JavaScript
170 lines
4.9 KiB
JavaScript
|
|
let form, layer, table, laydate, tableIns;
|
|||
|
|
let pageNum = 1, limitSize = 300; // 默认第一页,分页数量为200
|
|||
|
|
let user = getUser();
|
|||
|
|
let accountId = 0;
|
|||
|
|
|
|||
|
|
let paramsObj = null;
|
|||
|
|
|
|||
|
|
function setParams(params) {
|
|||
|
|
paramsObj = JSON.parse(params);
|
|||
|
|
accountId = paramsObj.checkUser;
|
|||
|
|
layui.use(['form', 'layer', 'table', 'laydate'], function () {
|
|||
|
|
form = layui.form;
|
|||
|
|
layer = layui.layer;
|
|||
|
|
table = layui.table;
|
|||
|
|
laydate = layui.laydate;
|
|||
|
|
//日期范围
|
|||
|
|
laydate.render({
|
|||
|
|
elem: '#startTime',
|
|||
|
|
type: 'date',
|
|||
|
|
range: '~',
|
|||
|
|
format: 'yyyy-MM-dd',
|
|||
|
|
});
|
|||
|
|
pages(1, 300, 1);
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
function pages(pageNum, pageSize, typeNum) {
|
|||
|
|
let params = getReqParams(pageNum, pageSize, typeNum);
|
|||
|
|
$.ajax({
|
|||
|
|
url: dataUrl + "proteam/pot/allocation/getTwoRiskPlans?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: [300, 400, 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({
|
|||
|
|
id: 'todayTaskTable',
|
|||
|
|
elem: "#todayTaskTable",
|
|||
|
|
height: "full-150",
|
|||
|
|
data: dataList,
|
|||
|
|
cols: [
|
|||
|
|
[
|
|||
|
|
//表头
|
|||
|
|
{
|
|||
|
|
title: "序号",
|
|||
|
|
width: '8%',
|
|||
|
|
unresize: true,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
return (page - 1) * limit + d.LAY_NUM;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "orgName",
|
|||
|
|
title: "建管单位",
|
|||
|
|
width: '10%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "proName",
|
|||
|
|
title: "工程名称",
|
|||
|
|
width: '20%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "workManager",
|
|||
|
|
title: "班组长",
|
|||
|
|
width: '10%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "workContent",
|
|||
|
|
title: "作业内容",
|
|||
|
|
width: '52%',
|
|||
|
|
unresize: false,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
],
|
|||
|
|
limit: limit,
|
|||
|
|
done: function (res, curr, count) {
|
|||
|
|
console.log(res);
|
|||
|
|
|
|||
|
|
let startTime = $('#startTime').val();
|
|||
|
|
if(res.data && res.data.length > 0 && paramsObj.type ===2 && !startTime){
|
|||
|
|
$('#startTime').val(res.data[0].currentDate + ' ~ ' + res.data[0].currentDate);
|
|||
|
|
}
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 获取参数
|
|||
|
|
function getReqParams(page, limit, type) {
|
|||
|
|
let startTime = isEmpty($('#startTime').val().split('~')[0]) ? "" : $('#startTime').val().split('~')[0];
|
|||
|
|
let endTime = isEmpty($('#startTime').val().split('~')[1]) ? "" : $('#startTime').val().split('~')[1];
|
|||
|
|
let obj = {};
|
|||
|
|
if (!type) {
|
|||
|
|
obj = {
|
|||
|
|
page: page + "",
|
|||
|
|
limit: limit + "",
|
|||
|
|
type: 2,
|
|||
|
|
accountId: accountId,
|
|||
|
|
startDay: startTime.trim(),
|
|||
|
|
endDay: endTime.trim(),
|
|||
|
|
keyWord:$('#keyWord').val()
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
} else {
|
|||
|
|
obj = {
|
|||
|
|
page: 1,
|
|||
|
|
limit: limit,
|
|||
|
|
accountId: accountId,
|
|||
|
|
type: 2,
|
|||
|
|
startDay: startTime.trim(),
|
|||
|
|
endDay: endTime.trim(),
|
|||
|
|
keyWord:$('#keyWord').val()
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
return obj;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 查询
|
|||
|
|
function query(){
|
|||
|
|
pages(1,limitSize);
|
|||
|
|
}
|