231 lines
7.1 KiB
JavaScript
231 lines
7.1 KiB
JavaScript
let form, table, laydate;
|
|
let tableIns;
|
|
let pageNum = 1; // 定义分页
|
|
layui.use(["form", "table", 'laydate'], function () {
|
|
form = layui.form;
|
|
table = layui.table;
|
|
laydate = layui.laydate;
|
|
laydate.render({
|
|
elem: '#ID-laydate-rangeLinked',
|
|
range: ['#startDay', '#endDay'],
|
|
rangeLinked: true
|
|
});
|
|
initTable();
|
|
});
|
|
|
|
// 查询/重置
|
|
function queryTable(type) {
|
|
if (type === 1) {
|
|
let keyWord = $('#keyWord').val();
|
|
let flag = checkValue(keyWord);
|
|
if (flag) {
|
|
$('#keyWord').val('');
|
|
return layer.msg('关键字查询包含特殊字符,请重新输入', { icon: 2 });
|
|
}
|
|
reloadTable(1);
|
|
} else if (type === 2) {
|
|
$('#keyWord').val('');
|
|
$('#startDate').val('');
|
|
$('#endDate').val('');
|
|
layui.form.render();
|
|
reloadTable(1);
|
|
}
|
|
}
|
|
|
|
// 刷新页面数据
|
|
function reloadData() {
|
|
reloadTable(1);
|
|
}
|
|
|
|
// 重载表格
|
|
function reloadTable(pageNum) {
|
|
table.reload("currentTableId", {
|
|
page: {
|
|
curr: pageNum ? pageNum : 1,
|
|
},
|
|
where: {
|
|
encryptedData: JSON.stringify({
|
|
'keyWord': $('#keyWord').val(),
|
|
'startDate': $('#startDate').val(),
|
|
'endDate': $('#endDate').val()
|
|
}),
|
|
},
|
|
},
|
|
);
|
|
}
|
|
|
|
// 初始化表格
|
|
function initTable() {
|
|
tableIns = table.render({
|
|
elem: "#currentTableId",
|
|
id: 'currentTableId',
|
|
headers: {
|
|
authorization: sessionStorage.getItem("gz-token"),
|
|
},
|
|
height: "full-170",
|
|
url: dataUrl + "backstage/planApplication/findByPage",
|
|
where: {
|
|
encryptedData: JSON.stringify({
|
|
'keyWord': $('#keyWord').val(),
|
|
'startDate': $('#startDate').val(),
|
|
'endDate': $('#endDate').val()
|
|
}),
|
|
},
|
|
request: {
|
|
pageName: 'pageNum',
|
|
limitName: 'pageSize'
|
|
},
|
|
parseData: function (res) { // res 即为原始返回的数据
|
|
if(res.code === 401){
|
|
closeWindowOpen();
|
|
}
|
|
return {
|
|
"code": 0, // 解析接口状态
|
|
"msg": '获取成功', // 解析提示文本
|
|
"count": res.total, // 解析数据长度
|
|
"data": res.list // 解析数据列表
|
|
};
|
|
},
|
|
cols: [
|
|
[
|
|
{
|
|
width: '5.9%',
|
|
title: "序号",
|
|
align: "center",
|
|
templet: function (d) {
|
|
return d.LAY_NUM;
|
|
},
|
|
},
|
|
{
|
|
field: "code",
|
|
width: '10%',
|
|
title: "计划编号",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "proName",
|
|
width: '15%',
|
|
title: "工程名称",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "needTime",
|
|
width: '10%',
|
|
title: "需用日期",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "creator",
|
|
width: '10%',
|
|
title: "申请人",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "createTime",
|
|
width: '15%',
|
|
title: "申请时间",
|
|
unresize: true,
|
|
align: "center",
|
|
},
|
|
{
|
|
field: "remark",
|
|
width: '14%',
|
|
title: "备注",
|
|
unresize: true,
|
|
align: "center",
|
|
templet: function (d) {
|
|
if (d.remark) {
|
|
if (d.remark.length > 100) {
|
|
return '<span title="' + d.remark + '">' + d.remark.substring(0, 60) + '...</span>'
|
|
} else {
|
|
return '<span title="' + d.remark + '">' + d.remark + '</span>'
|
|
}
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
},
|
|
{
|
|
field: "remark",
|
|
width: '10%',
|
|
title: "审核状态",
|
|
unresize: true,
|
|
align: "center",
|
|
templet: function (d) {
|
|
return getCheckStatus(d.statusType, d.status);
|
|
},
|
|
},
|
|
{
|
|
title: "操作",
|
|
width: '10%',
|
|
align: "center",
|
|
unresize: true,
|
|
templet: function (d) {
|
|
let html = "";
|
|
html += "<a onclick='applyPlanDetail(" + JSON.stringify(d) + ")'>详情</a>";
|
|
return html;
|
|
},
|
|
},
|
|
],
|
|
],
|
|
limits: [10, 15, 20, 25, 50, 100],
|
|
limit: 10,
|
|
page: true,
|
|
done: function (res, curr, count) {
|
|
pageNum = tableIns.config.page.curr;
|
|
table.resize("currentTableId");
|
|
},
|
|
});
|
|
}
|
|
|
|
// 导出
|
|
function exportExcel() {
|
|
let params = {
|
|
'keyWord': $('#keyWord').val(),
|
|
}
|
|
let url = dataUrl + "backstage/export/export";
|
|
exportExcelUtil(url, '需求计划申请', JSON.stringify(params));
|
|
}
|
|
|
|
|
|
|
|
//审核状态
|
|
function getCheckStatus(statusType, status) {
|
|
var company = "";
|
|
if (statusType === '1') {
|
|
return "<span style='color:#19BE6B;margin:0 5px 0 5px;font-size:16px;'>●</span>审核通过";
|
|
} else if (statusType === '2') {
|
|
company = "分公司";
|
|
} else if (statusType === '3') {
|
|
company = "项目管理中心";
|
|
} else if (statusType === '4') {
|
|
company = "机具公司";
|
|
}
|
|
if (status === '1') {
|
|
return "<span style='color:#FF9900;margin:0 5px 0 5px;font-size:16px'>●</span>待" + company + "审核";
|
|
} else if (status === '2') {
|
|
return "<span style='color:#19BE6B;margin:0 5px 0 5px;font-size:16px;'>●</span>审核通过";
|
|
} else if (status === '3') {
|
|
return "<span style='color:#F56C6C;margin:0 5px 0 5px;font-size:16px'>●</span>" + company + "审核驳回";
|
|
}
|
|
return "<span style='color:#FF9900;margin:0 5px 0 5px;font-size:16px'>●</span>待审核";
|
|
}
|
|
|
|
// 查询流程
|
|
function showProcess() {
|
|
openIframeByParamObj("show_process", "流程说明", "./child/show_process.html", "70%", "65%", null);
|
|
}
|
|
|
|
function applyPlan(obj) {
|
|
openIframeByParamObj("apply_plan", "机具需求计划申请", "./child/apply_plan_form.html", "92%", "95%", obj);
|
|
}
|
|
|
|
// 详情
|
|
function applyPlanDetail(obj) {
|
|
openIframeByParamObj("apply_plan_detail", "详情", "./child/apply_plan_detail.html", "92%", "95%", obj);
|
|
} |