cc-jjsp-web/bns/js/dutyTask/workPermit.js

779 lines
30 KiB
JavaScript
Raw Normal View History

2025-09-23 09:28:02 +08:00
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 += '<button type="button" class="layui-btn layui-btn-normal" style="background-color: #2F82FB;" onclick="openBackboneScore()">骨干成绩单</button>';
if (superUsers.indexOf(user.nickName) > -1) {
html += '<button type="button" class="layui-btn layui-btn-normal" style="background-color: #2F82FB;" onclick="openTicketEssenCondition()">作业许可及销号</button>';
}
} 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 += '<tr onclick="selTrData(this,1)" bidNo = "' + item.bidNo + '" ticketId ="' + item.ticketId + '" status="' + item.status + '" ticketNo="' + item.ticketNo + '"><td>' + (index + 1) + '</td><td title="' + item.projectName + '">' + item.projectName + '</td><td title="' + item.ticketNo + '">' + item.ticketNo + '</td><td>' + setRiskLevelColor(item.riskLevel) + '</td><td>' + item.workManager + '</td><td>' + item.status + '</td></tr>';
})
} else {
html += '<tr><td colspan="6">暂无数据</td></tr>'
}
$('#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 += '<tr onclick="selTrData(this,2)" bidNo = "' + item.bidNo + '" ticketId ="' + item.ticketId + '" status="' + item.status + '" ticketNo="' + item.ticketNo + '"><td>' + (index + 1) + '</td><td title="' + item.projectName + '">' + item.projectName + '</td><td title="' + item.ticketNo + '">' + item.ticketNo + '</td><td>' + setRiskLevelColor(item.riskLevel) + '</td><td>' + item.workManager + '</td><td>已结束</td><td>' + item.status + '</td></tr>';
})
} else {
html += '<tr><td colspan="7">暂无数据</td></tr>'
}
$('#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 += '<div class="permit-info layout">' +
'<div class="layout"><p style="letter-spacing: 10px;">许可人:</p><input placeholder="请输入许可人" autocomplete="off" maxlength="122" style="width: 300px;height: 30px;" id="permitUser" value="' + user.nickName + '"></div>' +
'<div class="layout" style="margin-top: 10px;width: 100%;justify-content: center;">' +
'<button id="permit" style="background-color: #2F82FB;border-color: #2F82FB;" onclick="permit(1)">许可</button>' +
'<button id="noPermit" style="background-color: rgb(248,179,24);border-color: rgb(248,179,24);" onclick="permit(2)">不许可</button>' +
'</div>' +
'</div>';
} else if (status === '许可') {
html += '<div class="permit-info" style="margin-top: 10px;">' +
'<p style="letter-spacing: 10px;">许可人:<span id="permitUser" style="letter-spacing: 1px;"></span></p>' +
'<p style="letter-spacing: 1px;margin-top: 5px;">许可工作时间:<span id="permitTime"></span></p>' +
'</div>';
} else if (status === '不许可') {
html += '<div class="permit-info" style="margin-top: 10px;">' +
'<p style="letter-spacing: 10px;">许可人:<span id="permitUser" style="letter-spacing: 1px;"></span></p>' +
'</div>';
} else if (status === '未销号') {
html += '<div class="permit-info" style="margin-top: 10px;">' +
'<p style="letter-spacing: 10px;">许可人:<span id="permitUser" style="letter-spacing: 1px;"></span></p>' +
'<p style="letter-spacing: 1px;margin-top: 5px;">许可工作时间:<span id="permitTime"></span></p>' +
'<button style="background-color: #2F82FB;border-color: #2F82FB;margin-top: 10px;margin-left: 80%;display: ' + value + '" onclick="cancelNumber()">确认销号</button>' +
'</div>';
// 添加参数
let cent = setXhTable(1);
$('#table-5').after(cent);
let cent2 = setFileHtml();
$('#table-9').after(cent2);
setParams();
} else if (status === '已销号') {
html += '<div class="permit-info" style="margin-top: 10px;">' +
'<p style="letter-spacing: 10px;">许可人:<span id="permitUser" style="letter-spacing: 1px;"></span></p>' +
'<p style="letter-spacing: 1px;margin-top: 5px;">许可工作时间:<span id="permitTime"></span></p>' +
'<p style="letter-spacing: 1px;margin-top: 5px;">风险销号时间:<span id="cancelTime"></span></p>' +
'</div>';
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+= '<table id="table-'+(item.idx)+'" class="essCondition-table">' +
'<colgroup>' +
'<col width="10%">' +
'<col width="22.5%">' +
'<col width="22.5%">' +
'<col width="22.5%">' +
'<col width="22.5%">' +
'</colgroup>' +
'<tr>' +
'<td colspan="4">'+(item.idx)+'、'+(item.name)+'。</td>' +
setCent(item) +
'</tr>' +
'</table>';
})
function setCent(item){
if(type === 1){
return '<td>' +
'<div class="radio-box layout">' +
'<div class="radio-box-child layout">' +
'<input type="radio" name="radio'+(item.idx)+'" value="1" id="true'+(item.idx)+'" checked><label for="true'+(item.idx)+'">是</label>' +
'</div>' +
'<div class="radio-box-child layout">' +
'<input type="radio" name="radio'+(item.idx)+'" value="2" id="false'+(item.idx)+'"><label for="false'+(item.idx)+'">否</label>' +
'</div>' +
'</div>' +
'</td>';
}else{
return '<td>' +
'<p id="radioValue'+(item.idx)+'"></p>' +
'</td>';
}
}
return html;
}
// 文件上传
function setFileHtml(){
let html = '<div class="container">' +
'<div class="upload-panel">' +
'<div class="upload-actions">' +
'<div id="picker" class="btn btn-primary">' +
'<i class="iconfont icon-add"></i> 选择文件' +
'</div>' +
'<button id="startUpload" class="btn btn-success" disabled>' +
'<i class="iconfont icon-upload"></i> 开始上传' +
'</button>' +
'<div id="fileCounter" class="file-counter"></div>' +
'</div>' +
'</div>' +
'<table class="upload-table">' +
'<thead>' +
'<tr>' +
'<th width="22%">文件名</th>' +
'<th width="15%">大小</th>' +
'<th width="20%">上传进度</th>' +
'<th width="23%">状态</th>' +
'<th width="15%">操作</th>' +
'</tr>' +
'</thead>' +
'<tbody id="fileList">' +
'<tr id="noFiles">' +
'<td colspan="5" class="no-files">暂无文件,请点击上方按钮添加文件</td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>' +
'<div id="toast" class="toast"></div>';
return html;
}
// 文件预览
function viewFileHtml(){
return '<div class="container">'+
'<p>上传附件</p>' +
'<table class="upload-table">' +
'<thead>' +
'<tr>' +
'<th width="55%">文件名</th>' +
'<th width="25%">大小</th>' +
'<th width="20%">操作</th>' +
'</tr>' +
'</thead>' +
'<tbody id="fileList2">' +
'</tbody>' +
'</table>' +
'</div>';
}
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 += "<tr class='files'>" +
"<td>" + item.fileName + "</td>" +
"<td>" + formatFileSize(item.fileSize || 0) + "</td>" +
"<td>" +
"<a href='javascript:;' style='margin: 0 5px;color: #0a58ca;' onclick='viewFile(" + JSON.stringify(item) + ")'>预览</a>" +
"</td>" +
"</tr>"
})
}else{
html += "<tr class='files'>" +
"<td colspan='3' style='text-align: center;'>无文件数据</td>" +
"</tr>"
}
$('#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: '<div style="text-align:center;height:100%;display:flex;align-items:center;justify-content:center;">' +
'<img src="' + imageUrl + '" style="max-width:98%;max-height:98%;object-fit:contain;margin:auto;" />' +
'</div>',
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 += '<tr><td>' + (index + 1) + '</td><td colspan="2">' + item.name + '</td><td colspan="2" class="' + className + '">' + accessValue + '</td></tr>'
} else {
html += '<tr style="display: none;"><td>' + (index + 1) + '</td><td colspan="2">' + item.name + '</td><td colspan="2" class="' + className + '">' + accessValue + '</td></tr>'
}
})
} else {
html += '<tr><td colspan="5">暂无数据</td></tr>'
}
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 += '<tr><td>' + (index + 1) + '</td><td>' + item.name + '</td><td>' + setNullValue(item.workType) + '</td><td colspan="2" class="' + className + '">' + accessValue + '</td></tr>'
} else {
html += '<tr style="display: none;"><td>' + (index + 1) + '</td>><td>' + item.name + '</td><td>' + item.workType + '</td><td colspan="2" class="' + className + '">' + accessValue + '</td></tr>'
}
})
} else {
html += '<tr><td colspan="5">暂无数据</td></tr>'
}
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 += "<tr style='text-align: left;'><td colspan='5' title='双击查看' style='cursor: pointer;color: #2F82FB;' ondblclick='openFile(" + JSON.stringify(obj) + ")'>" + item.fileName + "</td></tr>"
} else if (item.fileName.indexOf("doc") > 0 || item.fileName.indexOf("docx") > 0) {
html += "<tr style='text-align: left;'><td colspan='5' title='双击下载查看' style='cursor: pointer;color: #2F82FB;' ondblclick='downLoadFile(" + JSON.stringify(obj) + ")'>" + item.fileName + "</td></tr>"
}
})
if (!html) {
html += '<tr><td colspan="5">暂无数据</td></tr>'
}
} else {
html += '<tr><td colspan="5">暂无数据</td></tr>'
}
} else {
html += '<tr><td colspan="5">暂无数据</td></tr>'
}
$('#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();
}