IntelligentRecognition/ah-jjsp-web/bns/js/dutyTask/violation/noticeSheetCheck.js

267 lines
12 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let idParam, layer, form, serNo, org, status, classIdParam, voiStatus, typeParam;
function setParams(id, classId, type) {
idParam = id;
classIdParam = classId;
typeParam = type;
if (type === '1') {
$('.layui-form').removeAttr('style');
$('.btn-box').removeAttr('style');
} else if (type === '2') {
$('#checkRemarkDiv').removeAttr('style');
}
layui.use(['layer', 'form'], function () {
layer = layui.layer;
form = layui.form;
getNoticeVoiDetailById()
form.on('submit(formData)', function (data) {
submitData();
})
})
}
function getNoticeVoiDetailById() {
let loadingMsg = layer.msg("数据加载中,请稍候...", { icon: 16, scrollbar: false, time: 0, });
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify({
id: idParam,
classId: classIdParam
}))
},
url: dataUrl + 'proteam/pot/superStatistics/getNoticeSheet?token=' + token,
data: {
id: idParam,
classId: classIdParam
},
type: 'POST',
async: true,
success: function (result) {
layer.close(loadingMsg);
if (result.code === 200) {
setVoiRectNoticeData(result);
status = result.data.noticeVioEntity.status;
if (result.data.noticeVioEntity.status === '5') {
$('.voi-rect-feedback').removeAttr('style');
// setVoiRectFeedbackData(result);
}
} else if (result.code === 500) {
layer.alert(result.msg, { icon: 2 })
} else if (result.code === 401) {
logout(1)
}
}, error: function () {
layer.close(loadingMsg);
}
});
}
/*违章整改通知单(远程督查)赋值*/
function setVoiRectNoticeData(result) {
let html = '';
if (result.data.noticeVioEntity) {
let obj = result.data.noticeVioEntity;
$('#voiRectNoticeNo').html(obj.serNo);
serNo = obj.serNo, org = obj.org;
html += '<colgroup><col/><col/><col/><col/><col/></colgroup>'
html += '<tr><td>检查项目</td><td colspan="4">' + obj.proName + '</td></tr>'
html += '<tr><td>检查时间</td><td colspan="4">' + obj.createTime + '</td></tr>'
html += '<tr><td>施工内容及施工部位</td><td colspan="4">' + (obj.workContent ? obj.workContent : '') + '</td></tr>'
html += '<tr><td>主送单位</td><td colspan="4">' + obj.org + '</td></tr>'
html += '<tr><td>施工单位</td><td colspan="4">' + (obj.sgUnit ? obj.sgUnit : '') + '</td></tr>'
html += '<tr><td>监理单位</td><td colspan="4">' + (obj.jlUnit ? obj.jlUnit : '') + '</td></tr>'
html += '<tr><td>序号</td><td colspan="2">发现问题</td><td colspan="2">违反条款</td></tr>'
let imgPath = obj.imgPath, imgPathArr = imgPath.split(','), cent = ''
$.each(imgPathArr, function (index, item) {
let path = photoUrl + item + '?token=' + token
cent += '<tr style="height: 400px;"><td colspan="4" class="voi-img"><img src="' + path + '" data-original = "' + path + '"></td></tr>'
})
html += '<tr><td rowspan="' + (imgPathArr.length + 1) + '">1</td><td colspan="2">' + obj.content + '</td><td colspan="2">' + obj.voiYj + '</td></tr>'
html += cent
html += '<tr><td>整改要求</td><td colspan="4">' + obj.recRequirement + '</td></tr>'
html += '<tr><td>签发单位</td><td colspan="4">' + obj.issuingUnit + '</td></tr>'
}
$('#table1').empty().append(html);
let viewer = new Viewer(document.getElementById('table1'), {
url: 'data-original',
show: function () {
viewer.update();
}
});
let obj = result.data.noticeVioEntity;
let remark = obj.remark;
if (remark) {
let strArr = remark.split('@');
if (strArr.length === 1) {
$('#checkRemark').html(strArr[0]);
} else {
$('#checkRemark').html(strArr[1]);
}
}
}
/*违章整改反馈单赋值*/
function setVoiRectFeedbackData(result) {
let html = '', cent = '';
if (result.data.noticeVoiRectEntity) {
let obj = result.data.noticeVioEntity;
let obj2 = result.data.noticeVoiRectEntity;
$('#voiRectFeedbackNo').html(obj.serNo);
html += '<colgroup>col style="width: 5%"/><col style="width: 15%"/><col style="width: 35%"/><col style="width: 15%"/><col style="width: 15%"/><col style="width: 15%"/></colgroup>'
html += '<tr><td colspan="2">受检项目</td><td colspan="4">' + obj.proName + '</td></tr>'
html += '<tr><td colspan="2">受检时间</td><td colspan="4">' + obj.createTime + '</td></tr>'
html += '<tr><td colspan="2">主送单位</td><td colspan="4">' + obj.org + '</td></tr>'
html += '<tr><td style="padding: 0">序号</td><td>被查问题</td><td>整改措施</td><td>责任单位<br>(部门)</td><td>责任人</td><td>整改完<br>成时间</td></tr>'
html += '<tr><td>1</td><td>' + obj.content.substring(obj.content.indexOf("】") + 1, obj.content.length) + '</td><td>' + obj2.rectExplain + '</td><td>' + obj2.dutyUnit + '</td><td>' + obj2.dutyUser + '</td><td>' + obj2.rectFinshTime + '</td></tr>'
html += '<tr><td colspan="2">联系人</td><td>' + obj2.contactPhone + '</td><td></td><td colspan="2"></td></tr>'
cent += '<colgroup><col style="width: 50%"/><col style="width: 50%"/></colgroup>'
let imgPath = obj.imgPath, imgPathArr = imgPath.split(','), imgCent = '',
imagePath = obj2.imagePath, imgPathArr2 = imagePath.split(','), imgCent2 = ''
$.each(imgPathArr, function (index, item) {
let path = photoUrl + item + '?token=' + token
imgCent += '<img src="' + path + '" data-original = "' + path + '">'
})
$.each(imgPathArr2, function (index, item) {
let html = '';
// let path = photoUrl + item + '?token=' + token
// imgCent2 += '<img src="' + path + '">'
if (item && item.indexOf("jpg") > 0) { // 照片
let path = photoUrl + item + '?token=' + token
html += '<img src="' + path + '" data-original = "' + path + '">'
} else if (item && item.indexOf("docx") > 0) { // 文件
let obj = {
fileName: item
}
html += "<div class='file-box'>" +
"<div class='file-download'><button title='下载附件查看' onclick='uploadRectFile(" + JSON.stringify(obj) + ")'>下载</button></div>" +
"<img src='../../../img/docx-back.png' width='64px' height='64px'>" +
"<p>整改附件</p>" +
"</div>";
}
imgCent2 += html;
})
cent += '<tr><td><div class="issue-img">' + imgCent + '</td><td><div class="rect-img">' + imgCent2 + '</td></tr>'
cent += '<tr><td>' + obj.content.substring(obj.content.indexOf("】") + 1, obj.content.length) + '</td><td>' + obj2.status + '</td></tr>'
}
$('#table2').empty().append(html);
$('#table3').empty().append(cent);
let viewer = new Viewer(document.getElementById('table1'), {
url: 'data-original',
show: function () {
viewer.update();
}
});
let viewer2 = new Viewer(document.getElementById('table3'), {
url: 'data-original',
show: function () {
viewer2.update();
}
});
}
/*下载整改文件*/
function uploadRectFile(obj) {
let fileName = obj.fileName;
let downloadFileName = '整改附件_' + getNowDate() + '.' + fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length);
let loadingMsg = layer.msg('整改文件下载中,请稍候...', { icon: 16, scrollbar: false, time: 0 });
let url = dataUrl + 'proteam/pot/superStatistics/uploadRectFile?token=' + token + '&fileName=' + encodeURIComponent(fileName);
let xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
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 = downloadFileName; // 文件名
} else if (this.status === 401) {
localStorage.removeItem("token");
backLogin();
} else {
layer.msg('整改文件下载发生异常,请稍后重试', { icon: 16, scrollbar: false, time: 2000 });
}
a.click()
window.URL.revokeObjectURL(url)
};
xhr.send();
}
function downLoadNoticeSheet() {
let fileName = '违章通知单';
if (status === '5') {
fileName = '违章整改反馈单';
}
let loadingMsg = layer.msg("通知单导出中,请稍候...", { icon: 16, scrollbar: false, time: 0 });
let url = dataUrl + 'proteam/pot/superStatistics/downLoadNoticeSheet?token=' + token + "&id=" + idParam + "&classId=" + classIdParam;
let xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.setRequestHeader("encrypt",
sm3(JSON.stringify({
id: idParam,
classId: classIdParam,
})));
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 = serNo + fileName + "" + org.replace('供电', '') + "" + ".docx"; // 文件名
} else {
layer.msg("服务异常,请稍后重试", { icon: 16, scrollbar: false, time: 2000 });
}
a.click();
window.URL.revokeObjectURL(url);
};
xhr.send();
}
function saveData(type) {
voiStatus = type;
$('#formSubmit').trigger('click')
}
// 保存数据
function submitData() {
let loadingMsg = layer.msg('数据上传中,请稍候...', { icon: 16, scrollbar: false, time: 0 });
let url = dataUrl + 'proteam/pot/superStatistics/checkVoiStatus';
let params = {
'id': idParam,
'status': voiStatus,
'remark': $('#remark').val()
};
ajaxRequest(url, "POST", params, true, function () {
$('.save').addClass("layui-btn-disabled").attr("disabled", true);
$('.cancel').addClass("layui-btn-disabled").attr("disabled", true);
}, function (result) {
layer.close(loadingMsg); // 关闭提示层
if (result.code === 200) {
closePage(1);
parent.layer.msg(result.msg, { icon: 1 });
} else if (result.code === 500) {
layer.alert(result.msg, { icon: 2 })
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
}
}, function (xhr) {
layer.close(loadingMsg); // 关闭提示层
$('.save').removeClass("layui-btn-disabled").attr("disabled", false);
$('.cancel').removeClass("layui-btn-disabled").attr("disabled", false);
error(xhr)
});
}
// 关闭页面
function closePage(type) {
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
if (type === 1) {
window.parent.reloadData()
}
}