IntelligentRecognition/ah-jjsp-web/.svn/pristine/b1/b1b98755693bb6a23d6e080524d...

176 lines
6.3 KiB
Plaintext
Raw Permalink Normal View History

2024-05-24 16:09:40 +08:00
let idParam, layer;
function setParams(id) {
layui.use(['layer'], function () {
layer = layui.layer;
idParam = id;
getNoticeVoiDetailById(idParam)
});
}
function getNoticeVoiDetailById() {
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify({
id: idParam
}))
},
url: dataUrl + 'proteam/pot/superStatistics/getNoticeVoiRectById?token=' + token,
data: {
id: idParam
},
type: 'POST',
async: false,
success: function (result) {
layer.close(loadingMsg);
if (result.code === 200) {
setData(result.data);
} else if (result.code === 500) {
layer.alert(result.msg, {icon: 2})
} else if (result.code === 401) {
logout(1)
}
}, error: function () {
layer.close(loadingMsg);
setData(null);
}
});
}
/*页面赋值*/
function setData(data) {
$('#status').html(data.status)
$('#createTime').html(data.createTime)
$('#voiType').html(data.voiType)
$('#levelId').html(data.levelId)
$('#type').html(data.type)
$('#org').html(data.org)
$('#vioUsers').html(data.vioUsers)
$('#voiYj').html(data.voiYj)
$('#content').html(data.content)
$('#recRequirement').html(data.recRequirement)
let imgPath = data.imgPath, imgPathArr = imgPath.split(','), html = ''
$.each(imgPathArr, function (index, item) {
let path = photoUrl + item + '?token=' + token
html += '<img src="' + path + '" data-original = "' + path + '">'
})
$('.supervision-img').append(html)
if (data.list) {
let html = '';
$.each(data.list, function (index, item) {
let cent = '整改照片', cent2 = '整改说明';
if (!item.dutyUnit) {
cent = '申诉照片', cent2 = '申诉说明';
}
html += '<div class="rect-content-info layout">' +
'<div style="width: 10px">' +
'<p style="color: #2F82FB;">' + (index + 1) + '</p>' +
'</div>' +
'<div style="width: calc(100% - 10px)">' +
'<input hidden value="' + item.id + '" id="rectId">' +
'<div class="rect-info-img layout">' +
'<p style="width: 14%;">' + cent + '</p>' +
'<div class="rect-img" style="width: 86%;">' +
setImg(item) +
'</div>' +
'</div>' +
setRectInfo(item.dutyUnit, item) +
'<div class="content-textarea layout">' +
'<p>' + cent2 + '</p>' +
'<p>' + item.rectExplain + '</p>' +
'</div>' +
'<div class="content-textarea layout">' +
'<p>审核意见:</p>' +
'<p>' + setValue2(item.checkOpinion) + '</p>' +
'</div>' +
'<hr>' +
'</div>' +
'</div>'
})
$('.rect-content').empty().append(html)
}
let viewer = new Viewer(document.getElementById('dc-img'), {
url: 'data-original',
show: function () {
viewer.update();
}
});
let viewer2 = new Viewer(document.getElementById('rect-content'), {
url: 'data-original',
show: function () {
viewer2.update();
}
});
}
function setRectInfo(dutyUnit, item) {
let html = '';
if (dutyUnit) {
html += '<div class="content-input layout">' +
'<p>责任单位:<span>' + item.dutyUnit + '</span></p>' +
'<p>责任人:<span>' + item.dutyUser + '</span></p>' +
'</div>' +
'<div class="content-input layout">' +
'<p>整改完成时间:<span>' + item.rectFinshTime + '</span></p>' +
'<p>联系人及电话:<span>' + item.contactPhone + '</span></p>' +
'</div>';
}
return html;
}
function setImg(data) {
let imgPath = data.imagePath, imgPathArr = imgPath.split(','), html = ''
$.each(imgPathArr, function (index, item) {
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
}
console.log(JSON.stringify(obj))
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>";
}
})
return html;
}
/*下载整改文件*/
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 closePage() {
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
}