gz_gqj_web/js/demandPlan/plan_check_list.js

210 lines
6.5 KiB
JavaScript

let form, table, element;
let tableIns;
let pageNum = 1; // 定义分页
layui.use(["form", "table", 'element'], function () {
form = layui.form;
table = layui.table;
element = layui.element;
// tab 切换事件
element.on('tab(demo-filter-tab)', function (data) {
let auditStatus = $(this).attr('value');
$('#auditStatus').val(auditStatus);
queryTable(1);
});
initTable();
});
// 查询/重置
function queryTable(type) {
if (type === 1) {
reloadTable(1);
} else if (type === 2) {
$('#keyWord').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(),
'auditStatus': $('#auditStatus').val(),
}),
},
},
);
}
// 初始化表格
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
height: "full-220",
url: dataUrl + "backstage/planAudit/findByPage",
where: {
encryptedData: JSON.stringify({
'keyWord': $('#keyWord').val(),
'auditStatus': $('#auditStatus').val(),
}),
},
request: {
pageName: 'pageNum',
limitName: 'pageSize'
},
parseData: function (res) { // res 即为原始返回的数据
return {
"code": 0, // 解析接口状态
"msg": '获取成功', // 解析提示文本
"count": res.total, // 解析数据长度
"data": res.list // 解析数据列表
};
},
cols: [
[
{
width: '6.9%',
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
field: "code",
width: '10%',
title: "计划单号",
unresize: true,
align: "center",
},
{
field: "proName",
width: '14%',
title: "工程名称",
unresize: true,
align: "center",
},
{
field: "projectPart",
width: '10%',
title: "项目部分",
unresize: true,
align: "center",
},
{
field: "allPrice",
width: '10%',
title: "审核状态",
unresize: true,
align: "center",
templet: function (d) {
return getCheckStatus(d.statusType, d.status);
;
},
},
{
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",
},
{
title: "操作",
width: '10%',
align: "center",
unresize: true,
templet: function (d) {
let html = "";
html += "<a onclick='planAuditDetail(" + JSON.stringify(d) + ")'>详情</a>";
let content = getCheckStatus(d.statusType, d.status);
if (!(content.indexOf('驳回') > -1 || content.indexOf('通过') > -1)) {
html += "<div class='splitLine'>|</div><a onclick='checkDetail(" + 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 = {
'proName': $('#proName').val(),
'status': $('#status').val()
}
let url = dataUrl + "backstage/planAudit/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 planAuditDetail(obj) {
openIframeByParamObj("plan_audit_detail", "详情", "./child/apply_plan_detail.html", "92%", "95%", obj);
}
// 需求计划申请审核
function checkDetail(obj) {
obj.checkType = 2;
openIframeByParamObj("check_detail", "审核", "./child/apply_plan_detail.html", "92%", "95%", obj);
}