let status = '', ticketNo = '', ticketId = '', bidNo = '', selType = '1', user = getUser(), form, layer, table, formSelects, selObj = null, orgList = []; setBtn(); layui.config({ base: "../../js/layui/", //此处路径请自行处理, 可以使用绝对路径 }).extend({ formSelects: 'formSelects-v4', }).use(['form', 'layer', 'table', 'formSelects'], function () { form = layui.form; layer = layui.layer; table = layui.table; formSelects = layui.formSelects; orgList = getOrgSelect(); initBuildUnitCode(); getWorkPermitAndXhNumAjax(); pages(1, 10, true, 1); pages(1, 10, true, 2); setPersonAccessInfo(); layui.form.render(); }) // 设置骨干成绩单按钮 function setBtn() { let isSup = user.isSup, html = ''; if (isSup != '3') { html += ''; if (superUsers.indexOf(user.nickName) > -1) { html += ''; } } else { $('#btn-box').css('height', '0') } $('#btn-box').append(html); } // 查询 function query(type) { if (type === 1) { initPermitTable(1); } else if (type === 2) { initRiskConsumptionTable(2); } } // 作业许可表格数据赋值 function setPermitTableData(data) { let html = ''; if (data && data.length > 0) { data.forEach(function (item, index) { html += '' + (index + 1) + '' + item.projectName + '' + item.ticketNo + '' + setRiskLevelColor(item.riskLevel) + '' + item.workManager + '' + item.status + ''; }) } else { html += '暂无数据' } $('#permitTable tbody').empty().append(html); // 默认选中一行数据展示 if (data && data.length > 0) { if (selType === '1') { $('#indexIframe').removeAttr('style'); $('#no-ticket-file').css('display', 'none'); $('#essCondition-box').removeAttr('style') $('#permitTable tbody tr:nth-child(1)').css('background-color', '#a1bbf3') selObj = $('#permitTable tbody tr:nth-child(1)') status = $('#permitTable tbody tr:nth-child(1)').attr('status') ticketNo = $('#permitTable tbody tr:nth-child(1)').attr('ticketNo') ticketId = $('#permitTable tbody tr:nth-child(1)').attr('ticketId') bidNo = $('#permitTable tbody tr:nth-child(1)').attr('bidNo') selType = '1'; setEssConditionData(); } } else { if (selType === '1') { selObj = null, status = '', ticketNo = '', ticketId = '', bidNo = '', selType = '1'; $('#essCondition-box').css('display', 'none'); $('#indexIframe').css('display', 'none'); $('#no-ticket-file').removeAttr('style'); } } } // 作业许可表格数据赋值 function setRiskConsumptionTableData(data) { let html = ''; if (data && data.length > 0) { data.forEach(function (item, index) { html += '' + (index + 1) + '' + item.projectName + '' + item.ticketNo + '' + setRiskLevelColor(item.riskLevel) + '' + item.workManager + '已结束' + item.status + ''; }) } else { html += '暂无数据' } $('#riskConsumptionTable tbody').empty().append(html); // 默认选中一行数据展示 if (data && data.length > 0) { if (selType === '2') { $('#indexIframe').removeAttr('style'); $('#no-ticket-file').css('display', 'none'); $('#essCondition-box').removeAttr('style') $('#riskConsumptionTable tbody tr:nth-child(1)').css('background-color', '#a1bbf3') selObj = $('#riskConsumptionTable tbody tr:nth-child(1)') status = $('#riskConsumptionTable tbody tr:nth-child(1)').attr('status') ticketNo = $('#riskConsumptionTable tbody tr:nth-child(1)').attr('ticketNo') ticketId = $('#riskConsumptionTable tbody tr:nth-child(1)').attr('ticketId') bidNo = $('#riskConsumptionTable tbody tr:nth-child(1)').attr('bidNo') selType = '2'; setEssConditionData(); } } else { if (selType === '2') { selObj = null, status = '', ticketNo = '', ticketId = '', bidNo = '', selType = '2'; $('#essCondition-box').css('display', 'none'); $('#indexIframe').css('display', 'none'); $('#no-ticket-file').removeAttr('style'); } } } // 表格选中 function selTrData(that, type) { $('#indexIframe').removeAttr('style'); $('#no-ticket-file').css('display', 'none'); $('#essCondition-box').removeAttr('style'); $('#permitTable tbody tr').css('background-color', 'transparent') $('#riskConsumptionTable tbody tr').css('background-color', 'transparent') $(that).css('background-color', '#a1bbf3') status = $(that).attr('status'); ticketNo = $(that).attr('ticketNo') ticketId = $(that).attr('ticketId') bidNo = $(that).attr('bidNo') selType = type + ''; selObj = $(that) $('#openBtn').css('display', 'none') $('#closeBtn').css('display', 'none') $('#openBtn2').css('display', 'none') $('#closeBtn2').css('display', 'none') setEssConditionData(); } // 赋值必备条件 function setEssConditionData() { let value = 'block' if (user.isSup !== '3') { value = 'none' } let html = ''; if (status === '新开票') { for (let i = 1; i <= 5; i++) { changeStyle(i, 1) } } else { for (let i = 1; i <= 9; i++) { changeStyle(i, 2) } } initUploadComponent(); if (status === '新开票' && user.isSup === '3') { html += '
' + '

许可人:

' + '
' + '' + '' + '
' + '
'; } else if (status === '许可') { html += '
' + '

许可人:

' + '

许可工作时间:

' + '
'; } else if (status === '不许可') { html += '
' + '

许可人:

' + '
'; } else if (status === '未销号') { html += '
' + '

许可人:

' + '

许可工作时间:

' + '' + '
'; // 添加参数 let cent = setXhTable(1); $('#table-5').after(cent); let cent2 = setFileHtml(); $('#table-9').after(cent2); setParams(); } else if (status === '已销号') { html += '
' + '

许可人:

' + '

许可工作时间:

' + '

风险销号时间:

' + '
'; let cent = setXhTable(2); $('#table-5').after(cent); const cent2 = viewFileHtml(); $('#table-9').after(cent2); } $('#permit-box').empty().append(html) if (status !== '新开票') { getTicketEssenCondition(); } // 加载作业票文件、班组骨干、准入人员、已编制安全技术措施 viewTicket(); resetRadio(); getBackboneByIdList(); getAccessPeopleByIdList(); getSgProgramAjax(); } // 初始化上传组件 function initUploadComponent(){ for (let index = 6; index <= 9; index++) { $('#table-' + index).remove(); } $('.container').remove(); if(uploader){ // 销毁文件上传组件 uploader.destroy(); } fileArr.splice(0,fileArr.length); delFileArr.splice(0,delFileArr.length); currentFileCount = 0; } // 销号添加确认 function setXhTable(type){ let list = [{name:'作业完成确认',idx : 6},{name:'人员与设备清场',idx : 7},{name:'材料清理',idx : 8},{name:'场地恢复',idx : 9}]; let html = ''; $.each(list,function(index,item){ html+= '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + setCent(item) + '' + '
'+(item.idx)+'、'+(item.name)+'。
'; }) function setCent(item){ if(type === 1){ return '' + '
' + '
' + '' + '
' + '
' + '' + '
' + '
' + ''; }else{ return '' + '

' + ''; } } return html; } // 文件上传 function setFileHtml(){ let html = '
' + '
' + '
' + '
' + ' 选择文件' + '
' + '' + '
' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
文件名大小上传进度状态操作
暂无文件,请点击上方按钮添加文件
' + '
' + '
'; return html; } // 文件预览 function viewFileHtml(){ return '
'+ '

上传附件

' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
文件名大小操作
' + '
'; } function setTicketEssenConditionData(data) { $('#radioValue1').html(data.radioOne === '1' ? '是' : '否'); $('#radioValue2').html(data.radioTwo === '1' ? '是' : '否'); $('#radioValue3').html(data.radioThree === '1' ? '是' : '否'); $('#radioValue4').html(data.radioFour === '1' ? '是' : '否'); $('#radioValue5').html(data.radioFive === '1' ? '是' : '否'); $('#radioValue6').html(data.radioSix === '1' ? '是' : '否'); $('#radioValue7').html(data.radioSenve === '1' ? '是' : '否'); $('#radioValue8').html(data.radioEight === '1' ? '是' : '否'); $('#radioValue9').html(data.radioNine === '1' ? '是' : '否'); $('#permitUser').html(data.permitUser); $('#permitTime').html(data.permitTime); $('#cancelTime').html(data.cancelTime); initFileData(data.fileList); function initFileData(data) { let html = ''; if(data && data.length > 0){ $.each(data, function (index, item) { html += "" + "" + item.fileName + "" + "" + formatFileSize(item.fileSize || 0) + "" + "" + "预览" + "" + "" }) }else{ html += "" + "无文件数据" + "" } $('#fileList2').append(html); } } // 文件预览函数 function viewFile(item) { var fileExt = (item.fileSuffix).toLowerCase(); if (fileExt === 'pdf') { // pdf 预览 sessionStorage.setItem("fileUrlNew", item.filePath); let href = '../../pdfjs/web/viewer2.html' layui.layer.open({ title: 'PDF预览-' + item.fileName, type: 2, area: ['65%', '85%'], // 弹出框的宽高 fixed: false, // 是否固定 maxmin: true, // 是否允许最大化 shade: 0, // 隐藏弹框的遮罩层 content: href, // pdf的地址 move:false }) }else if (['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(fileExt)) { let imageUrl = photoUrl + item.filePath + '?token=' + token; layer.open({ type: 1, title: '图片预览 - ' + item.fileName, content: '
' + '' + '
', area: ['65%', '85%'], // 弹出框的宽高 move: false, shadeClose: true // 点击遮罩层关闭弹窗 }); } } function changeStyle(index, type) { if (type === 1) { $('#table-' + index + ' tr:nth-child(1)').find('td').eq(1).removeAttr('style'); $('#table-' + index + ' tr:nth-child(1)').find('td').eq(2).css('display', 'none'); } else if (type === 2) { $('#table-' + index + ' tr:nth-child(1)').find('td').eq(1).css('display', 'none'); $('#table-' + index + ' tr:nth-child(1)').find('td').eq(2).removeAttr('style'); } } // 许可/不许可 function permit(type) { let permitUser = $('#permitUser').val(); if (!permitUser) { return layer.msg('请输入许可人', { icon: 7 }) } let radio1 = $('input[name="radio1"]:checked').val() let radio2 = $('input[name="radio2"]:checked').val() let radio3 = $('input[name="radio3"]:checked').val() let radio4 = $('input[name="radio4"]:checked').val() let radio5 = $('input[name="radio5"]:checked').val() let params = { ticketNo: ticketNo, radioOne: radio1, radioTwo: radio2, radioThree: radio3, radioFour: radio4, radioFive: radio5, permitUser: permitUser, type: type + '', } premitAjax(params); } // 销号 function cancelNumber() { if(!isAllUpload){ return layer.msg('附件未全部上传完成,请稍后重试', { icon: 5 }); } let params = { ticketNo: ticketNo, type: '3', radioSix: $('input[name="radio6"]:checked').val(), radioSenve: $('input[name="radio7"]:checked').val(), radioEight: $('input[name="radio8"]:checked').val(), radioNine: $('input[name="radio9"]:checked').val(), } if(delFileArr.length > 0){ params.delFiles = JSON.stringify(delFileArr); } if(fileArr.length > 0){ params.files = JSON.stringify(fileArr); } premitAjax(params); } // 更新表格、必备条件数据 function reloadTableData(type) { if (type === '1') { status = '许可'; } else if (type === '2') { status = '不许可'; } else if (type === '3') { status = '已销号'; } /* if (selType === '1') { selObj.attr('status', status).find('td').eq(4).html(status) } else if (selType === '2') { selObj.attr('status', status).find('td').eq(5).html(status) } */ setEssConditionData(); if (type === '3') { queryTable(2); } else { queryTable(1); } getWorkPermitAndXhNumAjax(); } // 预览作业票文件 function viewTicket() { let params = { 'ticketId': ticketId } $.ajax({ headers: { "encrypt": sm3(JSON.stringify(params)) }, url: dataUrl + 'proteam/pot/todayTask/getTicketBase64?token=' + token, data: params, type: 'POST', async: true, success: function (result) { let data = result.data ? result.data : {}; if (result.code === 500) { return layer.alert(result.msg, { icon: 2 }) } else if (result.code === 401) { logout(1); } else if (result.code === 200) { if (data.File && data.File.filePath) { sessionStorage.setItem("fileId", ticketId); sessionStorage.setItem("fileType", '2'); let href = '../../pdfjs/web/viewer.html' $('#indexIframe').attr('src', href) } else { let href = './ticketInfo.html?ticketId=' + ticketId; $('#indexIframe').attr('src', href) } /* if (data.filePath) { sessionStorage.setItem("fileId", ticketId); sessionStorage.setItem("fileType", '2'); let href = '../../pdfjs/web/viewer.html' $('#indexIframe').attr('src', href) } else { let href = './ticketInfo.html?ticketId=' + ticketId; $('#indexIframe').attr('src', href) } */ } }, error: function () { } }); } // 骨干成绩单 function openBackboneScore() { let layerIndex = layer.open({ id: "backboneScore", title: false, type: 2, maxmin: false, content: '../dutyTask/backboneScore/backboneScore.html', area: ['100%', '100%'], move: false, closeBtn: 0, success: function (layero, index) { } }); } // 作业许可及销号列表 function openTicketEssenCondition() { let layerIndex = layer.open({ id: "ticketEssenCondition", title: false, type: 2, maxmin: false, content: '../dutyTask/backboneScore/ticketEssenCondition.html', area: ['100%', '100%'], move: false, closeBtn: 0, success: function (layero, index) { } }); } // 作业人员准入信息 function setPersonAccessInfo(data) { $('#table-2 tr:not(:first)').remove(); let html = '', accessNum = 0, noAccessNum = 0; if (data && data.length > 0) { data.forEach(function (item, index) { let className = item.accessInfo === '1' ? 'access-td' : 'no-access-td'; let accessValue = item.accessInfo === '1' ? '准入' : '未准入'; item.accessInfo === '1' ? accessNum++ : noAccessNum++; if (index < 5) { html += '' + (index + 1) + '' + item.name + '' + accessValue + '' } else { html += '' + (index + 1) + '' + item.name + '' + accessValue + '' } }) } else { html += '暂无数据' } if (data && data.length > 5) { $('#openBtn').css('display', 'block'); } $('#accessNum').html(accessNum); $('#noAccessNum').html(noAccessNum); $('#table-person').after(html); } // 班组骨干 function setBackboneScoreInfo(data) { $('#table-3 tr:not(:first)').remove(); let html = '', passNum = 0, noPassNum = 0; if (data && data.length > 0) { data.forEach(function (item, index) { let className = item.isPass === '1' ? 'access-td' : 'no-access-td'; let accessValue = item.isPass === '1' ? '已通过' : '未通过'; item.isPass === '1' ? passNum++ : noPassNum++; if (index < 5) { html += '' + (index + 1) + '' + item.name + '' + setNullValue(item.workType) + '' + accessValue + '' } else { html += '' + (index + 1) + '>' + item.name + '' + item.workType + '' + accessValue + '' } }) } else { html += '暂无数据' } if (data && data.length > 5) { $('#openBtn2').css('display', 'block'); } $('#passNum').html(passNum); $('#noPassNum').html(noPassNum); $('#table-person2').after(html); } function setNullValue(value) { if (value) { return value; } return ''; } // 已编制安全技术措施赋值 function setProgramData(result) { $('#table-5 tr:not(:first)').remove(); let html = '' if (result && result.length > 0 && result !== 'null') { let data = JSON.parse(result); if (data.length) { $.each(data, function (index, item) { let obj = { 'fileId': item.fileId, 'fileName': item.fileName } if (item.fileName.indexOf("pdf") > 0) { html += "" + item.fileName + "" } else if (item.fileName.indexOf("doc") > 0 || item.fileName.indexOf("docx") > 0) { html += "" + item.fileName + "" } }) if (!html) { html += '暂无数据' } } else { html += '暂无数据' } } else { html += '暂无数据' } $('#table-person3').after(html); } // 打开施工方案 function openFile(obj) { sessionStorage.setItem("fileId", obj.fileId); sessionStorage.setItem("fileType", '1'); let href = '../../pdfjs/web/viewer.html' window.open(href, '_blank'); } // 下载已编制安全技术措施 function downLoadFile(obj) { let loadingMsg = layer.msg('文件下载中,请稍候...', { icon: 16, scrollbar: false, time: 0, offset: ['45%', '57%'] }); let url = dataUrl + 'proteam/pot/todayTask/downLoadSgFile?fileId=' + obj.fileId + "&fileName=" + obj.fileName + "&token=" + token; let xhr = new XMLHttpRequest(); xhr.open("get", url, true); xhr.responseType = "blob"; // 转换流 xhr.setRequestHeader("encrypt", sm3(JSON.stringify({ fileId: obj.fileId, fileName: obj.fileName }))); xhr.onload = function () { layer.close(loadingMsg); if (this.status === 200) { let blob = this.response; var a = document.createElement("a"); var url = window.URL.createObjectURL(blob); a.href = url; a.download = obj.fileName; // 文件名 } else { layer.msg('服务异常,请稍后重试', { icon: 16, scrollbar: false, time: 2000 }); } a.click() window.URL.revokeObjectURL(url) }; xhr.send(); } // 展开作业人员准入情况 function openTableData() { $('#table-2 tr').each(function (index) { if (index > 5) { $(this).removeAttr('style'); } }); $('#openBtn').css('display', 'none'); $('#closeBtn').css('display', 'block'); } // 收起作业人员准入情况 function closeTableData() { $('#table-2 tr').each(function (index) { if (index > 5) { $(this).css('display', 'none'); } }); $('#openBtn').css('display', 'block'); $('#closeBtn').css('display', 'none'); } // 展开班组骨干 function openTableData2() { $('#table-3 tr').each(function (index) { if (index > 5) { $(this).removeAttr('style'); } }); $('#openBtn2').css('display', 'none'); $('#closeBtn2').css('display', 'block'); } // 重置必备条件单选框 function resetRadio() { $('input[name="radio1"][value="1"]').prop('checked', true) $('input[name="radio2"][value="1"]').prop('checked', true) $('input[name="radio3"][value="1"]').prop('checked', true) $('input[name="radio4"][value="1"]').prop('checked', true) $('input[name="radio5"][value="1"]').prop('checked', true) } // 收起作业人员准入情况 function closeTableData2() { $('#table-3 tr').each(function (index) { if (index > 5) { $(this).css('display', 'none'); } }); $('#openBtn2').css('display', 'block'); $('#closeBtn2').css('display', 'none'); } // 导出 function exportData(operType) { let loadingMsg = layer.msg("数据导出中,请稍候...", { icon: 16, scrollbar: false, time: 0, }); let params = { status: operType === 1 ? $('#permitStatus').val() : $('#consumptionStatus').val(), type: operType, orgList: operType === 1 ? formSelects.value('buildCode', 'val') : formSelects.value('buildCode2', 'val'), projectName: operType === 1 ? $('#proName').val().trim() : $('#proName2').val().trim(), currentUserId: user.userId + '', isSup: user.isSup, currentUserOrgId: user.orgId, token:token }; const queryString = objectToQueryString(params); console.log(queryString); let url = dataUrl + "proteam/pot/workPermit/exportExcelData" + queryString; let xhr = new XMLHttpRequest(); xhr.open("get", url, true); xhr.responseType = "blob"; // 转换流 xhr.setRequestHeader("encryption", "encryption"); $('.export').addClass("layui-btn-disabled").attr("disabled", true); xhr.onload = function () { layer.close(loadingMsg); $('.export').removeClass("layui-btn-disabled").attr("disabled", false); if (this.status === 200) { let blob = this.response; var a = document.createElement("a"); var url = window.URL.createObjectURL(blob); a.href = url; a.download = (operType === 1 ? "作业许可" : "风险销号") + getNowDate() + ".xlsx"; // 文件名 } else { layer.msg("数据发生异常,请稍后重试", { icon: 16, scrollbar: false, time: 2000 }); } a.click(); window.URL.revokeObjectURL(url); }; xhr.send(); } // 建管单位赋值 function initBuildUnitCode() { let keys = []; $.each(orgList, function (index, item) { let temp = { "name": item.name, "value": item.code }; keys.push(temp); }) formSelects.data('buildCode', 'local', { arr: keys }); formSelects.data('buildCode2', 'local', { arr: keys }); layui.form.render(); }