gz_gqj_web/js/demandPlan/child/apply_plan_detail.js

322 lines
11 KiB
JavaScript
Raw Normal View History

2024-11-11 10:54:13 +08:00
let idParam, objParam;
let details;
2024-11-16 15:06:04 +08:00
let form, layer, table;
2024-11-11 10:54:13 +08:00
function setParams(obj) {
objParam = JSON.parse(obj);
2024-11-14 14:51:26 +08:00
if (objParam.checkType === 2) {
$('#print').before('<button type="button" class="layui-btn layui-bg-orange" onclick="check()">审核</button>');
}
2024-11-11 10:54:13 +08:00
idParam = objParam.id;
2024-11-16 15:06:04 +08:00
layui.use(['form', 'layer', 'table'], function () {
2024-11-11 10:54:13 +08:00
form = layui.form;
layer = layui.layer;
2024-11-16 15:06:04 +08:00
table = layui.table;
setCheckStatus();
getDetailById();
initTable();
2024-11-11 10:54:13 +08:00
});
}
// 基本信息
function setPlanBasicTableInfo(obj) {
$('#proName').html(obj.proName);
$('#projectPart').html(obj.projectPart);
$('#projectContent').html(obj.projectContent);
$('#needTime').html(obj.needTime);
$('#remark').html(obj.remark);
}
2024-11-16 15:06:04 +08:00
// 查询/重置
function queryTable(type) {
if (type === 1) {
reloadTable(1);
} else if (type === 2) {
$('#type').val('');
$('#model').val('');
layui.form.render();
reloadTable(1);
2024-11-11 10:54:13 +08:00
}
}
2024-11-16 15:06:04 +08:00
// 刷新页面数据
function reloadData() {
reloadTable(1);
2024-11-11 10:54:13 +08:00
}
2024-11-16 15:06:04 +08:00
// 重载表格
function reloadTable(pageNum) {
table.reload("currentTableId", {
page: {
curr: pageNum ? pageNum : 1,
},
where: {
encryptedData: JSON.stringify({
'type': $('#type').val(),
'model': $('#model').val(),
'id': objParam.id
}),
},
},
);
}
// 初始化表格
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
2024-11-16 15:10:03 +08:00
height: "full",
2024-11-16 15:06:04 +08:00
url: dataUrl + "backstage/planApplication/getPlanDetailsList",
where: {
encryptedData: JSON.stringify({
'type': $('#type').val(),
'model': $('#model').val(),
'id': objParam.id
}),
},
request: {
pageName: 'pageNum',
limitName: 'pageSize'
},
parseData: function (res) { // res 即为原始返回的数据
return {
"code": 0, // 解析接口状态
"msg": '获取成功', // 解析提示文本
"count": res.total, // 解析数据长度
"data": res.list // 解析数据列表
};
},
cols: [
[
{
2024-11-16 15:10:03 +08:00
width: '9.8%',
2024-11-16 15:06:04 +08:00
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
field: "typeName",
width: '15%',
title: "物机类型",
unresize: true,
align: "center",
},
{
field: "type",
width: '15%',
title: "物机名称",
unresize: true,
align: "center",
},
{
field: "module",
width: '15%',
title: "规格",
unresize: true,
align: "center",
},
{
field: "unit",
width: '10%',
title: "单位",
unresize: true,
align: "center",
templet: function (d) {
return setNullValue(d.unit);
},
},
{
field: "needNum",
width: '10%',
title: "需用量",
unresize: true,
align: "center",
},
{
field: "times",
width: '10%',
title: "需用天数",
unresize: true,
align: "center",
},
{
field: "remarks",
width: '15%',
title: "备注",
unresize: true,
align: "center",
},
],
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
done: function (res, curr, count) {
pageNum = tableIns.config.page.curr;
table.resize("currentTableId");
},
});
2024-11-11 10:54:13 +08:00
}
// 导出
function exportData() {
let params = {
2024-11-16 15:06:04 +08:00
"id": objParam.id,
'type': $('#type').val(),
'model': $('#model').val(),
2024-11-11 10:54:13 +08:00
}
2024-11-11 15:16:34 +08:00
let url = dataUrl + "backstage/export/exportDetail";
exportExcelUtil(url, '机具明细', JSON.stringify(params));
2024-11-11 10:54:13 +08:00
}
// 操作记录
function setOperRecordInfo(list, obj) {
let creator = obj.creator; // 发起人
let html = '';
if (list && list.length > 0) {
let imgUrl = '../../../images/user_head_icon.png';
let imgUrl2 = '../../../images/time_icon.png';
$.each(list, function (index, item) {
let operData = "";
let dept = '';
let minutes = item.minutes;
if (item.hours === 0 && item.minutes === 0) {
minutes = 1;
}
if (item.auditType === '0' || item.auditType === '1') {
dept = '项目部';
} else if (item.auditType === '2') {
dept = '分公司';
} else if (item.auditType === '3') {
dept = '项管中心';
} else if (item.auditType === '4') {
dept = '机具公司';
}
// 操作流程
if (item.auditType === '0') {
operData = '发起申请';
} else if (item.auditType === '1') {
operData = '重新提交申请';
} else if (item.auditType === '2' && item.auditStatus === '2') {
operData = '审核确认通过,共耗时:' + item.hours + '小时' + minutes + '分钟 原因备注:' + item.auditRemarks + '';
} else if (item.auditType === '2' && item.auditStatus === '3') {
operData = '驳回-给发起人' + creator + ',共耗时:' + item.hours + '小时' + minutes + '分钟 原因备注:' + item.auditRemarks + '';
} else if (item.auditType === '3' && item.auditStatus === '2') {
operData = '审核确认通过,共耗时:' + item.hours + '小时' + minutes + '分钟 原因备注:' + item.auditRemarks + '';
} else if (item.auditType === '3' && item.auditStatus === '3') {
operData = '驳回-给发起人' + creator + ',共耗时:' + item.hours + '小时' + minutes + '分钟 原因备注:' + item.auditRemarks + '';
} else if (item.auditType === '4' && item.auditStatus === '2') {
operData = '完结-审核确认通过,共耗时:' + item.hours + '小时' + minutes + '分钟 原因备注:' + item.auditRemarks + '';
} else if (item.auditType === '4' && item.auditStatus === '3') {
operData = '驳回-给发起人' + creator + ',共耗时:' + item.hours + '小时' + minutes + '分钟 原因备注:' + item.auditRemarks + '';
}
html += '<div class="layui-timeline-item">' +
'<i class="layui-icon layui-timeline-axis"></i>' +
'<div class="layui-timeline-content layui-text">' +
'<h3 class="layui-timeline-title">' + item.auditTime.substring(0, 10) + '</h3>' +
'<div class="layui-panel">' +
'<div class="oper-info layout">' +
'<div class="layout">' +
'<img src="' + imgUrl + '">' +
'</div>' +
'<div class="user-oper layout">' +
'<div style="width: 100%">' +
'<span>' + item.auditUser + '</span><span>' + item.phone + '</span><span>' + dept + '</span>' +
'</div>' +
'<div style="width: 100%">' +
'<span>' + operData + '</span>' +
'</div>' +
'</div>' +
'<div class="layout">' +
'<img src="' + imgUrl2 + '">' +
'<span style="margin: 0 5px 0 5px;">' + item.auditTime + '</span>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
})
}
$('.layui-timeline').empty().append(html);
}
// 设置计划编号/审核状态
function setCheckStatus() {
$('#code').empty().html(objParam.code);
$('#checkStatus').html(getCheckStatus(objParam.statusType, objParam.status));
}
// 审核状态
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 getDetailById() {
let params = {
encryptedData: JSON.stringify({
'id': idParam
})
};
let url = dataUrl + 'backstage/planApplication/getPlanDetails';
ajaxRequest(url, "POST", params, true, function () {
}, function (result) {
if (result.code === 200) {
2024-11-11 12:28:05 +08:00
setPlanBasicTableInfo(result.data);
setOperRecordInfo(result.data.auditList, result.data);
details = result.data.details;
2024-11-11 10:54:13 +08:00
}
}, function (xhr, status, error) {
errorFn(xhr, status, error)
}, null);
}
// 打印
function print() {
Print('#body', {
onStart: function () {
console.log('onStart', new Date())
},
onEnd: function () {
console.log('onEnd', new Date())
}
})
2024-11-14 14:51:26 +08:00
}
// 需求计划申请审核
function check() {
objParam.checkType = '2'; // 需求计划申请审核
openIframeByParamObj("check", "审核", "../../accessory/child/audit_form.html", "40%", "50%", objParam);
}
function closePage() {
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
window.parent.queryTable(1);
2024-11-16 14:39:44 +08:00
parent.layer.close(index); // 再执行关闭
2024-11-11 10:54:13 +08:00
}