IntelligentRecognition/ah-jjsp-web/.svn/pristine/b4/b4f9993f2cb2dd3526235fae3f4...

470 lines
18 KiB
Plaintext

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 += '<button type="button" class="layui-btn layui-btn-normal" style="background-color: #2F82FB;" onclick="openBackboneScore()">骨干成绩单</button>';
if (user.nickName === '!jysp' || user.nickName === 'jysp') {
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 <= 5; i++) {
changeStyle(i, 2)
}
}
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>';
} 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>';
}
$('#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 += '<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>' + 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 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 += "<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');
}