let idParam, objParam; let details; let form, layer, laydate; function setParams(obj) { objParam = JSON.parse(obj); console.log(objParam.checkType); if (objParam.checkType === 2) { $('#print').before(''); } idParam = objParam.id; layui.use(['form', 'layer', 'laydate'], function () { form = layui.form; layer = layui.layer; laydate = layui.laydate; }); setCheckStatus(); getDetailById(); } // 基本信息 function setPlanBasicTableInfo(obj) { $('#proName').html(obj.proName); $('#projectPart').html(obj.projectPart); $('#projectContent').html(obj.projectContent); $('#needTime').html(obj.needTime); $('#remark').html(obj.remark); } // 查询 function search() { let keyWord = $('#keyWord').val(); let keyWord2 = $('#keyWord2').val(); if (!keyWord && !keyWord2) { getbaseList(details); } else if (keyWord && !keyWord2) { let dataList = details.filter(item => { console.log(item.type.indexOf(keyWord)); return item.type.indexOf(keyWord) > -1; }) getbaseList(dataList); } else if (!keyWord && keyWord2) { let dataList = details.filter(item => { console.log(item.module.indexOf(keyWord2)); return item.module.indexOf(keyWord2) > -1; }) getbaseList(dataList); } else if (keyWord && keyWord2) { let dataList = details.filter(item => { console.log(item.module.indexOf(keyWord2)); console.log(item.type.indexOf(keyWord)); return item.type.indexOf(keyWord) > -1 && item.module.indexOf(keyWord2) > -1;; }) getbaseList(dataList); } } // 重置 function resetSearch() { $('#keyWord').val(''); $('#keyWord2').val(''); getbaseList(details); } function getbaseList(results) { var html = ""; if (results && results.length > 0) { for (var i = 0; i < results.length; i++) { var l = results[i]; html += ""; html += "" + (i + 1) + ""; html += "" + l.typeName + ""; html += "" + l.type + ""; html += "" + l.module + ""; html += "" + setNullValue(l.unit) + ""; html += "" + l.needNum + ""; html += "" + l.times + ""; html += "" + setNullValue(l.remarks) + ""; html += ""; } } else { html += "没有相关数据"; } $("#baseTable tbody").empty().append(html); } // 导出 function exportData() { let params = { "id": idParam } let url = dataUrl + "backstage/export/exportDetail"; exportExcelUtil(url, '机具明细', JSON.stringify(params)); } // 操作记录 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 += '
' + '' + '
' + '

' + item.auditTime.substring(0, 10) + '

' + '
' + '
' + '
' + '' + '
' + '
' + '
' + '' + item.auditUser + '(' + item.phone + ')' + dept + '' + '
' + '
' + '' + operData + '' + '
' + '
' + '
' + '' + '' + item.auditTime + '' + '
' + '
' + '
' + '
' + '
'; }) } $('.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 "审核通过"; } else if (statusType === '2') { company = "分公司"; } else if (statusType === '3') { company = "项目管理中心"; } else if (statusType === '4') { company = "机具公司"; } if (status === '1') { return "待" + company + "审核"; } else if (status === '2') { return "审核通过"; } else if (status === '3') { return "" + company + "审核驳回"; } return "待审核"; } // 详情 function getDetailById() { let params = { encryptedData: JSON.stringify({ 'id': idParam }) }; let url = dataUrl + 'backstage/planApplication/getPlanDetails'; ajaxRequest(url, "POST", params, true, function () { }, function (result) { console.log(result); if (result.code === 200) { setPlanBasicTableInfo(result.data); getbaseList(result.data.details); setOperRecordInfo(result.data.auditList, result.data); details = result.data.details; } }, 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()) } }) } // 需求计划申请审核 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); parent.layer.close(index); // 再执行关闭 }