180 lines
5.6 KiB
JavaScript
180 lines
5.6 KiB
JavaScript
let form, layer, table, tableIns, laydate;
|
||
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为20
|
||
let user = getUser();
|
||
let dataObj = {};
|
||
function setParams(params) {
|
||
dataObj = JSON.parse(params);
|
||
layui.use(['form', 'layer', 'table', 'laydate'], function () {
|
||
form = layui.form;
|
||
layer = layui.layer;
|
||
table = layui.table;
|
||
pages(1, 10, 1);
|
||
})
|
||
}
|
||
|
||
|
||
function pages(pageNum, pageSize, typeNum) {
|
||
let params = getReqParams(pageNum, pageSize, typeNum);
|
||
$.ajax({
|
||
url: dataUrl + "proteam/pot/cityDailyDutyReport/getApplyBackData?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],
|
||
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-110",
|
||
data: dataList,
|
||
cols: [
|
||
[
|
||
{
|
||
title: "序号",
|
||
width: '5%',
|
||
unresize: true,
|
||
align: "center",
|
||
templet: function (d) {
|
||
return (page - 1) * limit + d.LAY_NUM;
|
||
}
|
||
},
|
||
{
|
||
field: "orgName",
|
||
title: "建管单位",
|
||
width: '25%',
|
||
unresize: false,
|
||
align: "center",
|
||
},
|
||
{
|
||
field: "currentDay",
|
||
title: "日期",
|
||
width: '30%',
|
||
unresize: false,
|
||
align: "center",
|
||
},
|
||
{
|
||
title: "状态",
|
||
width: '30%',
|
||
unresize: false,
|
||
align: "center",
|
||
templet: function (d) {
|
||
let cent = '', color = '';
|
||
if (d.storeStatus === '2') {
|
||
cent = '待审核', color = '#f70';
|
||
} else if (d.storeStatus === '3') {
|
||
cent = '审核驳回', color = '#f40';
|
||
}
|
||
return '<span style="color:' + color + '">' + cent + '</span>';
|
||
}
|
||
},
|
||
{
|
||
title: "操作",
|
||
width: '10%',
|
||
unresize: false,
|
||
align: "center",
|
||
templet: function (d) {
|
||
let html = '';
|
||
if(d.storeStatus === '2'){
|
||
html += "<a style='color:green;' onclick='auditData(" + JSON.stringify(d) + ",0)'>通过</a><div>|</div>";
|
||
html += "<a style='color:#f40;' onclick='auditData(" + JSON.stringify(d) + ",3)'>驳回</a>";
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
],
|
||
],
|
||
limit: limit,
|
||
done: function (res, curr, count) {
|
||
layer.close(loadingMsg);
|
||
},
|
||
});
|
||
}
|
||
|
||
|
||
// 获取参数
|
||
function getReqParams(page, limit, type) {
|
||
let obj = {};
|
||
if (!type) {
|
||
obj = {
|
||
page: page + "",
|
||
limit: limit + "",
|
||
roleType: user.isSup,
|
||
userId: user.userId,
|
||
};
|
||
} else {
|
||
obj = {
|
||
page: 1,
|
||
limit: limit,
|
||
roleType: user.isSup,
|
||
userId: user.userId,
|
||
|
||
};
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
// 查询
|
||
function query() {
|
||
pages(1, limitSize);
|
||
}
|
||
|
||
// 审核
|
||
function auditData(obj,type) {
|
||
layer.confirm('确定'+(type === 0 ? '通过':'驳回')+'吗?', function () {
|
||
let loadingMsg = layer.msg('数据保存中,请稍等...', { icon: 16, shade: 0.01, time: '0' });
|
||
let url = dataUrl + "proteam/pot/cityDailyDutyReport/updateDailyStatus";
|
||
let params = { id: obj.id,storeStatus:type };
|
||
ajaxRequest2(url, "POST", params, true, function (result) {
|
||
layer.close(loadingMsg); // 关闭提示层
|
||
if (result.code === 200) {
|
||
parent.layer.msg(result.msg, { icon: 1 })
|
||
query(1);
|
||
parent.getApplyBackDataNum();
|
||
} else {
|
||
layer.msg(result.msg, { icon: 2 })
|
||
}
|
||
}, function (xhr) {
|
||
layer.close(loadingMsg); // 关闭提示层
|
||
error(xhr)
|
||
}, null, token);
|
||
})
|
||
}
|