269 lines
8.9 KiB
JavaScript
269 lines
8.9 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%',
|
|
title: "序号",
|
|
align: "center",
|
|
templet: function (d) {
|
|
return d.LAY_NUM;
|
|
},
|
|
},
|
|
{
|
|
field: "code",
|
|
width: '10%',
|
|
title: "计划编号",
|
|
unresize: true,
|
|
align: "center",
|
|
sort: true,
|
|
},
|
|
{
|
|
field: "proName",
|
|
width: '15%',
|
|
title: "工程名称",
|
|
unresize: true,
|
|
align: "center",
|
|
sort: true,
|
|
},
|
|
{
|
|
field: "needTime",
|
|
width: '8%',
|
|
title: "需用日期",
|
|
unresize: true,
|
|
align: "center",
|
|
sort: true,
|
|
},
|
|
{
|
|
field: "creator",
|
|
width: '8%',
|
|
title: "申请人",
|
|
unresize: true,
|
|
align: "center",
|
|
sort: true,
|
|
},
|
|
{
|
|
field: "createTime",
|
|
width: '15%',
|
|
title: "申请时间",
|
|
unresize: true,
|
|
align: "center",
|
|
sort: true,
|
|
},
|
|
{
|
|
field: "remark",
|
|
width: '10%',
|
|
title: "备注",
|
|
unresize: true,
|
|
align: "center",
|
|
sort: true,
|
|
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",
|
|
sort: true,
|
|
templet: function (d) {
|
|
return getCheckStatus(d.statusType, d.status, d.mode);
|
|
},
|
|
},
|
|
{
|
|
field: "mode",
|
|
width: '8%',
|
|
title: "状态",
|
|
unresize: true,
|
|
align: "center",
|
|
sort: true,
|
|
templet: function (d) {
|
|
if (d.mode == '0') {
|
|
return "<span style='color:rgba(214,214,214,0.56);margin:0 5px 0 5px;font-size:16px'>●</span>草稿";
|
|
} else {
|
|
return "<span style='color:#19BE6B;margin:0 5px 0 5px;font-size:16px'>●</span>已提交";
|
|
}
|
|
|
|
|
|
},
|
|
},
|
|
{
|
|
title: "操作",
|
|
width: '10%',
|
|
align: "center",
|
|
unresize: true,
|
|
templet: function (d) {
|
|
let status = getCheckStatus(d.statusType, d.status);
|
|
let html = "";
|
|
html += "<a onclick='applyPlanDetail(" + JSON.stringify(d) + ")'>详情</a>";
|
|
if (status.indexOf('驳回') > -1 || status.indexOf('已撤回') > -1 || d.mode == '0') {
|
|
html += "<div class='splitLine'>|</div><a onclick='editApplyPlan(" + 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, mode) {
|
|
var company = "";
|
|
if (mode == '0') {
|
|
return "<span style='color:rgba(214,214,214,0.56);margin:0 5px 0 5px;font-size:16px'>●</span>未提交";
|
|
}
|
|
if (statusType === '0' && status === '0') {
|
|
return "<span style='color:#FF9900;margin:0 5px 0 5px;font-size:16px'>●</span>已撤回";
|
|
}
|
|
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 editApplyPlan(obj) {
|
|
openIframeByParamObj("editApplyPlan", "机具需求计划申请修改", "./child/apply_plan_edit_form.html", "92%", "95%", obj);
|
|
}
|
|
|
|
// 详情
|
|
function applyPlanDetail(obj) {
|
|
openIframeByParamObj("apply_plan_detail", "详情", "./child/apply_plan_detail.html", "92%", "95%", obj);
|
|
} |