let status = '', ticketNo = '', ticketId = '', bidNo = '', selType = '1', user = getUser(), form, layer, selObj = null; setBtn(); layui.use(['form', 'layer'], function () { form = layui.form; layer = layui.layer; layui.form.render(); initPermitTable(1); getWorkPermitAndXhNumAjax(); initRiskConsumptionTable(2); setPersonAccessInfo(); }) // 设置骨干成绩单按钮 function setBtn() { let isSup = user.isSup, html = ''; if (isSup != '3') { html += ''; if (user.nickName === '!jysp' || user.nickName === 'jysp') { 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 <= 5; i++) { changeStyle(i, 2) } } if (status === '新开票' && user.isSup === '3') { html += '
' + '

许可人:

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

许可人:

' + '

许可工作时间:

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

许可人:张三

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

许可人:

' + '

许可工作时间:

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

许可人:张三

' + '

许可工作时间:

' + '

风险销号时间:

' + '
'; } $('#permit-box').empty().append(html) if (status !== '新开票') { getTicketEssenCondition(); } // 加载作业票文件、班组骨干、准入人员、已编制安全技术措施 viewTicket(); resetRadio(); getBackboneByIdList(); getAccessPeopleByIdList(); getSgProgramAjax(); } 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' ? '是' : '否'); $('#permitUser').html(data.permitUser); $('#permitTime').html(data.permitTime); $('#cancelTime').html(data.cancelTime); } 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() { let params = { ticketNo: ticketNo, type: '3', } premitAjax(params); } // 更新表格、必备条件数据 function reloadTableData(type) { if (type === '1') { status = '许可'; } else if (type === '2') { status = '不许可'; } else if (type === '3') { status = '已销号'; } setEssConditionData(); 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) } } // 预览作业票文件 function viewTicket() { sessionStorage.setItem("fileId", ticketId); sessionStorage.setItem("fileType", '2'); let href = '../../pdfjs/web/viewer.html' $('#indexIframe').attr('src', href) } // 骨干成绩单 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 + '' + 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 setProgramData(result) { $('#table-5 tr:not(:first)').remove(); let html = '' if (result && 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'); }