IntelligentRecognition/ah-jjsp-web/.svn/pristine/7c/7c9e0971668a423af1ba00e9b37...

866 lines
32 KiB
Plaintext

// 站班会id、设备puid,督查角色类型,不同页面跳转类型,标段工程id
let idParam, puidParam, isSupParam, pageTypeParam, bidNoParam,teamId;
let form, layer, table, laydate;
// 作业票文件、标段工程名称、作业票编号、建管单位、班组负责人身份证号、班组名称、风险等级、标段编码、单项编码
let filePath, bidName, ticketNo, org, workManagerNum, teamName = null, riskLevel = null, bidCode = null, signCode = null;
// 统一视频编码18位、统一视频前端编码、统一设备协议编码、视频通道
let tCode, twCode, tdCode, passWay;
//班组长
let bzgg = ['52', '55', '4123', '0900102', '49', '0900101', '46', '50', '4116', '4103', '27'];
//特种作业
let tzzy = ['445', '4117', '4120', '0900106', '54'];
let warnInfo; // 告警信息
let lon, lat,jwd; // 球机经纬度
// 杆塔最大、最小距离单位m
let distanceList = getRiskLevelSelect('distance');
let content;
// 定义数组存储页面索引
let indexArr = [];
// 图片预览
let viewer, isViewer = false;
let viewer2, isViewer2 = false;
function setParams(id, puid, tCodeParam, twCodeParam, tdCodeParam, passWayParam, isSup, pageType, bidNo) {
// 页面加载自动获取焦点
$('#startTime').focus();
console.log(distanceList)
idParam = id;
puidParam = puid;
isSupParam = isSup;
pageTypeParam = pageType;
bidNoParam = bidNo;
setBtns();
console.log("classId:" + id + "puid:" + puid)
localStorage.setItem("esc", 'esc')
layui.use(['form', 'layer', 'table', 'laydate', 'util'], function () {
form = layui.form;
layer = layui.layer;
table = layui.table;
laydate = layui.laydate;
util = layui.util;
laydate.render({
elem: '#startTime', //指定元素 元素选择器
type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
trigger: 'click',
max: Date.parse(new Date()),
format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
btns: ['clear', 'now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定
done: function (value, date) { //时间回调
}
});
$('#startTime').val(getNowTime())
video(id, puid, tCodeParam, twCodeParam, tdCodeParam, passWayParam);
getZbhWarnAjax();
pages();
getZbhDetailAjax();
getZbhPeopleAjax();
getClassMettingSignAjax();
getZbhImageAjax();
getExceptionReportListAjax();
getSgProgramAjax();
//按钮点击事件
util.event('lay-active', {
photoLocal: function () {
screenshot();
}
});
})
}
// 控制按钮展示
function setBtns() {
let html = '', cent = '';
if ((isSupParam === '1' || isSupParam === '2') && pageTypeParam === 1) {
html = '<div>' +
'<button type="button" class="layui-btn layui-btn-normal" style="margin-left: 0;" onclick="openTeamEvaluate()">班组评价</button>' +
'<button type="button" class="layui-btn layui-btn-normal" onclick="openViolationForm(1)" style="width: 96px;">违章单下发</button>' +
'<button type="button" class="layui-btn layui-btn-normal" onclick="openExceptionReportForm()">异常报备</button>' +
// '<button type="button" class="layui-btn layui-btn-normal" style="width:100px;" onclick="openBidTowerMain()">标段杆塔维护</button>' +
'</div>' +
'<div style="margin-right: 20px;" class="layout">' +
'<input type="checkbox" name="focusTeam" id="focusTeam" style="margin-right: 10px;" onchange="updateImportTeam()">' +
'<p>重点巡查</p>' +
'</div>';
} else if ((isSupParam === '1' || isSupParam === '2') && pageTypeParam === 2) {
html = '<div>' +
'<button type="button" class="layui-btn layui-btn-normal" style="margin-left: 0;" onclick="openTeamEvaluate()">班组评价</button>' +
'<button type="button" class="layui-btn layui-btn-normal" onclick="openExceptionReportForm()">异常报备</button>' +
// '<button type="button" class="layui-btn layui-btn-normal" style="width:100px;" onclick="openBidTowerMain()">标段杆塔维护</button>' +
'</div>' +
'<div style="margin-right: 20px;" class="layout">' +
'<input type="checkbox" name="focusTeam" id="focusTeam" style="margin-right: 10px;" onchange="updateImportTeam()">' +
'<p>重点巡查</p>' +
'</div>';
} else if (isSupParam === '3') {
html = '<div>' +
'<button style="margin: 0;" type="button" class="layui-btn layui-btn-normal" onclick="openExceptionReportForm()">异常报备</button>' +
// '<button type="button" class="layui-btn layui-btn-normal" style="width:100px;" onclick="openBidTowerMain()">标段杆塔维护</button>' +
'<button type="button" class="layui-btn layui-btn-normal" style="width:100px;" onclick="openViolationForm(2)">违章自查</button>' +
'</div>';
}
if (isSupParam !== '3') {
cent += '<button style="width: 120px;" type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="editWarn()">编辑预警信息</button>';
}
cent += '<button style="width: 60px;" type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="editSwwz()">设置</button>';
cent += '<button style="width: 100px;" type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="setPosition(1)">设置守望位</button>';
cent += '<button style="width: 100px;" type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="setPosition(2)">前往守望位</button>';
$('.btn-box').append(html);
$('.btn-box2').append(cent);
// $('#warn-info').after(cent);
}
function video(id, puid, tCodeParam, twCodeParam, tdCodeParam, passWayParam) {
let passWay = localStorage.getItem("passWay");
if (passWay == null || passWay == '') {
passWay = 'to-2';
}
try {
initVideo();
setTimeout(function () {
videoObject.devCode = passWay === "to-1" ? tCodeParam : puid;
videoObject.videoType = passWay;
playVideo(1, videoObject.devCode, '', videoObject.videoType)
}, 1000);
} catch (e) {
}
}
/*更新是否重点关注班组*/
function updateImportTeam() {
let focusTeam = $('#focusTeam').prop('checked')
if (focusTeam) {
updateImportTeamAjax('1', workManagerNum)
} else {
updateImportTeamAjax('0', workManagerNum)
}
}
function set3DisTrue() {
let is3D = $('#3dset').prop('checked')
if (is3D) {
layer.msg('已开启3D云台', { icon: 1 })
} else {
layer.msg('已关闭3D云台', { icon: 1 })
}
localStorage.setItem("threeD", is3D);
}
/*查询球机当日上线记录*/
function queryBallOnlineRecord() {
pages();
}
// 球机当日上线记录
function pages() {
let params = {
createDay: $('#startTime').val(),
classId: idParam
}
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + "proteam/pot/todayTask/getBallTimeList?token=" + token,
data: params,
type: 'POST',
async: false,
success: function (result) {
if (result.code === 200) {
if (result.data) {
initBallOnlineRecordTable(result.data)
}
} else if (result.code === 500) {
layer.alert(result.msg, { icon: 2 })
} else if (result.code === 401) {
logout(1);
}
}, error: function () {
}
});
}
/*初始化球机当日上线记录表格*/
function initBallOnlineRecordTable(dataList) {
table.render({
elem: "#ballOnlineRecordTable",
id: "ballOnlineRecordTable",
height: "full-485",
data: dataList,
cols: [
[
{
field: "upTime",
title: "开机时间",
unresize: true,
width: 120,
align: "center",
},
{
field: "downTime",
title: "关机时间",
unresize: true,
width: 120,
align: "center",
},
{
field: "hours",
title: "在线时长",
unresize: true,
width: 120,
align: "center",
}
],
],
done: function (res, curr, count) {
table.resize("ballOnlineRecordTable");
count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block");
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
},
});
}
/*站班会预警信息赋值*/
function setClassWarnInfo(result) {
let html = '';
if (result) {
warnInfo = result;
let data = result.split(",");
if (data.length) {
$.each(data, function (index, item) {
if (item) {
var items = item.split("@");
if (items.length > 1) {
html += '<p style="color:green"> ' + items[0] + '</p>';
} else {
html += '<p style="color: #f67e7e;">' + item + '</p>';
}
}
})
}
} else {
html += '<p style="color: #14B93B;">正常施工</p>'
}
$('.early-waring-info').empty().append(html);
}
/*站班会详情赋值*/
function setClassDetailData(result) {
if (result) {
let data = JSON.parse(result);
console.log(data)
console.log(typeof (data.ztList) == 'undefined');
console.log(data.ztList);
if (typeof (data.ztList) != 'undefined') {
let ztList = data.ztList;
let p = "";
for (var i = 0; i < ztList.length; i++) {
let ztdata = ztList[i];
if (ztdata.ztsj != '' && ztdata.ztsj != null) {
p = p + "<p>暂停时间:<span >" + ztdata.ztsj + "</span></p>"
}
if (ztdata.ztyy != '' && ztdata.ztyy != null) {
p = p + "<p>暂停原因:<span >" + ztdata.ztyy + "</span></p>";
}
if (ztdata.xhzt != '' && ztdata.xhzt != null) {
p = p + "<p>信号状态:<span >" + ztdata.xhzt + "</span></p>";
}
}
$("#ztList").append(p);
}
let sgStatus = '';
if (data.sgStatus === '1') {
sgStatus = '开工'
} else if (data.sgStatus === '2') {
sgStatus = '暂停'
} else if (data.sgStatus === '3') {
sgStatus = '完工'
}
$('#sgStatus').html('(' + data.proStatus + ')')
$('#ticketNo').html(data.ticketNo)
$('#bidName').html(data.bidName)
$('#sgdw').html(data.sgdw)
$('#jldw').html(data.jldw)
$('#mainRisk').html(data.mainRisk)
$('#workDay').html(data.workDay)
$('#workingTime').html(data.startTime)
$('#stopTime').html(data.ztsj)
if (data.ztsj != null && data.ztsj != '' && typeof (data.ztsj) != 'undefined') {
$('#stopTimep').css("display", "")
}
$('#content').html(setValue2(data.workType) + '' + setValue2(data.workGx) + '' + setValue2(data.workContent))
$('#workManager').html(data.workManager)
$('#workManagePhone').html(data.workManagePhone)
$(safetyManagers(data.safetyManager)).appendTo('#addPostion')
$('#controll').html(setValue(data.controll))
$('#changes').html(setValue(data.changes))
filePath = data.filePath;
bidName = data.bidName;
ticketNo = data.ticketNo;
org = data.org;
workManagerNum = data.workManagerNum;
teamName = data.teamName;
teamId=data.teamId;
riskLevel = data.riskLevel;
bidCode = data.bidCode;
signCode = data.signCode;
lon = data.lat;
lat = data.lon;
jwd=data.jwd;
content = setValue2(data.workType) + '' + setValue2(data.workGx) + '' + setValue2(data.workContent);
console.log(lon + ',' + lat);
if (data.bidName.indexOf("线路") == '-1') {
// $("#gt_id").css("display","none");
$("#ai-box-1").css("display", "none");
}
// 获取距离球机最近的杆塔坐标
if (lon && lat && signCode) {
getBidTowerListAjax(signCode);
} else {
$('#towerName').html('无匹配杆塔');
}
if (data.importTeam === '1') {
$('#focusTeam').prop('checked', true)
}
setTeamLabelData(data.teamLabels);
}
}
// 班组标签
function setTeamLabelData(list) {
let html = '';
if (list && list.length > 0) {
$.each(list, function (index, item) {
let itemArr = item.split('@');
if (parseInt(itemArr[1]) > 1) {
html += '<p>' + itemArr[0] + '<span class="layui-badge">' + itemArr[1] + '</span></p>'
} else {
html += '<p>' + itemArr[0] + '</p>'
}
})
} else {
html = '<p style="background-color: transparent !important;width:100%;text-align:center;color:#262626 !important;border:none;">无班组标签</p>'
}
$('.teamLabelContent').empty().append(html);
}
// 获取安全监护人
function safetyManagers(value) {
let numArr = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十'];
let html = '';
if (value) {
let valueArr = value.split(",");
valueArr.forEach((o, index) => {
html += '<p>第' + numArr[index] + '作业面安全监护:' + o + '</p>';
});
return html;
} else {
return html;
}
}
function getSex(idCard) {
let sexStr = '';
if (parseInt(idCard.slice(-2, -1)) % 2 === 1) {
sexStr = '0'
} else {
sexStr = '1'
}
return sexStr;
}
/*参与施工人员签名、临时人员赋值*/
function setWorkerPersonData(result) {
let cent = '', cent2 = '';
if (result) {
let data = JSON.parse(result);
if (data.sgPeople.length) {
var bzz = '', tszyry = '', bzcy = '', wsg = '';
$.each(data.sgPeople, function (index, item) {
let lsryCode=item.lsry;//新增人员/临时人员标志
if('02'==lsryCode){
cent2 += setWorkPhoto("../../../img/remotePatrol/people-3.png", '#2F82FB', item)
}else{
if (bzgg.indexOf(item.peopleType) > -1) {
if (getSex(item.idNumber) === '0') {
bzz += setWorkPhoto("../../../img/remotePatrol/people-1-0.png", '#e90606', item);
} else {
bzz += setWorkPhoto("../../../img/remotePatrol/people-1-1.png", '#e90606', item);
}
} else if (tzzy.indexOf(item.peopleType) > -1) {
if (getSex(item.idNumber) === '0') {
tszyry += setWorkPhoto("../../../img/remotePatrol/people-2-3.png", '#70E180', item);
} else {
tszyry += setWorkPhoto("../../../img/remotePatrol/people-2-4.png", '#70E180', item);
}
} else if (item.peopleType === '未施工') {
if (getSex(item.idNumber) === '0') {
wsg += setWorkPhoto("../../../img/remotePatrol/people-4-0.png", '#BFBFBF', item);
} else {
wsg += setWorkPhoto("../../../img/remotePatrol/people-4-1.png", '#BFBFBF', item);
}
} else {
if (getSex(item.idNumber) === '0') {
bzcy += setWorkPhoto("../../../img/remotePatrol/people-3-0.png", '#2F82FB', item);
} else {
bzcy += setWorkPhoto("../../../img/remotePatrol/people-3-1.png", '#2F82FB', item);
}
}
}
})
cent = bzz + tszyry + bzcy + wsg;
} else {
cent += '<p>暂无数据</p>';
$('.work-people-sign').css('justify-content', 'center')
}
if (!cent2.length) {
cent2 += '<p>暂无数据</p>';
$('.temporary-people-photo').css('justify-content', 'center')
}
} else {
cent += '<p>暂无数据</p>';
$('.work-people-sign').css('justify-content', 'center')
cent2 += '<p>暂无数据</p>';
$('.temporary-people-photo').css('justify-content', 'center')
}
$('.work-people-sign').empty().append(cent);
$('.temporary-people-photo').empty().append(cent2);
}
/*施工人员签名*/
function setWorkPhoto(imgPath, color, item) {
return '<div class="work-people-type layout">' +
'<img style="height: 40px;width: 40px;" src="' + imgPath + '" title="' + item.typeName + '">' +
'<p style="color: ' + color + '">' + item.userName + '</p>' +
'</div>'
}
/*到岗到位签到表赋值*/
function setDutyTableData(result) {
let html = '<tr><td>职务</td><td>姓名</td><td>手机号</td><td>签到时间</td></tr>';
if (result.data.length) {
$.each(result.data, function (index, item) {
html += '<tr>' +
'<td>' + item.peopleType + '</td>' +
'<td>' + item.userName + '</td>' +
'<td>' + item.phone + '</td>' +
'<td>' + item.inTime + '</td>' +
'</tr>';
})
} else {
html += '<tr><td colspan="4" style="height: 50px;border-bottom: 1px solid #d9d9d9">暂无数据</td></tr>';
}
$('#onDutyTable').empty().append(html);
}
/*关键点措施赋值*/
function setKeyPointPhoto(result) {
// 站班会交底拍照、现场勘查、地脚螺栓、跨越架、有限空间、地锚
let photoList = [], photoList2 = [], photoList3 = [], photoList4 = [], photoList5 = [], photoList6 = [], photoList7 = [], photoList8 = [], photoList9 = [];
if (result) {
let data = JSON.parse(result);
let prefix = 'data:image/Jpeg;base64,';
if (data.length) {
$.each(data, function (index, item) {
let base64Path = prefix + item.imagePath;
if (item.imageType === '1') {
photoList.push('<img src="' + base64Path + '" data-original = "' + base64Path + '">')
} else if (item.imageType === '2') {
photoList2.push('<img src="' + base64Path + '" data-original = "' + base64Path + '">')
} else if (item.imageType === '3') {
photoList3.push('<img src="' + base64Path + '" data-original = "' + base64Path + '">')
} else if (item.imageType === '4') {
photoList4.push('<img src="' + base64Path + '" data-original = "' + base64Path + '">')
} else if (item.imageType === '5') {
photoList5.push('<img src="' + base64Path + '" data-original = "' + base64Path + '">')
} else if (item.imageType === '6') {
photoList6.push('<img src="' + base64Path + '" data-original = "' + base64Path + '">')
} else if (item.imageType === '7') {
photoList7.push('<img src="' + base64Path + '" data-original = "' + base64Path + '">')
} else if (item.imageType === '8') {
photoList8.push('<img src="' + base64Path + '" data-original = "' + base64Path + '">')
} else if (item.imageType === '9') {
photoList9.push('<img src="' + base64Path + '" data-original = "' + base64Path + '">')
}
})
}
}
setPhoto(photoList, 0);
setPhoto(photoList2, 1);
setPhoto(photoList3, 2);
setPhoto(photoList4, 3);
setPhoto(photoList5, 4);
setPhoto(photoList6, 5);
setPhoto(photoList7, 6);
setPhoto(photoList8, 7);
setPhoto(photoList9, 8);
viewer = new Viewer(document.getElementById('key-point'), {
url: 'data-original',
toolbar: true,
show: function () {
viewer.update();
},
shown: function () {
isViewer = true;
},
hidden: function () {
isViewer = false;
}
});
}
/*关键点措施照片*/
function setPhoto(data, index) {
if (data.length) {
let html = '';
$.each(data, function (index, item) {
html += item
})
$('.key-point-photo-type').eq(index).empty().append(html)
} else {
$('.key-point-photo-type').eq(index).empty().append('<p>暂无数据</p>').css('justify-content', 'center')
$('.key-point-photo-type').eq(index).find('p').eq(0).css('margin-top', '10px');
}
}
/*作业票文件下载*/
function downLoadTicketFile() {
if (filePath) {
showPdf('data:application/pdf;base64,' + filePath)
} else {
layer.msg('无作业票文件', { icon: 5 })
}
}
/*异常上报赋值*/
function setExceptionReport(result) {
let html = '';
if (result && result.length) {
$.each(result, function (index, item) {
html += '<div class="exceptionReporting-info layout">' +
'<div class="exceptionReporting-num"><p>' + (index + 1) + '</p></div>' +
'<div class="exceptionReporting-content layout">' +
'<div class="content-box layout"><p>上报时间:</p><p>' + item.uploadTime + '</p></div>' +
'<div class="content-box layout"><p>异常内容:</p><p>' + item.content + '</p></div>' +
'<div class="content-box layout"><p>异常图片:</p> <div class="exception-img layout">' +
setExceptionImg(item.imgPath) +
// setExceptionImg(item.base64List) +
'</div></div>' +
'</div>' +
'</div>';
})
} else {
html += '<p>暂无数据</p>'
}
$('.exceptionReporting-detail').empty().append(html);
viewer2 = new Viewer(document.getElementById('exceptionReporting'), {
url: 'data-original',
toolbar: true,
show: function () {
viewer2.update();
},
shown: function () {
isViewer2 = true;
},
hidden: function () {
isViewer2 = false;
}
});
}
function setExceptionImg(data) {
let html = '';
if (data) {
let imgArr = data.split(',');
$.each(imgArr, function (index, item) {
let path = photoUrl + item + "?token=" + token
html += '<img src="' + path + '" data-original = "' + path + '">'
})
}
/* if (data.length > 0) {
$.each(data, function (index, item) {
let base64Path = item;
html += '<img src="' + base64Path + '" data-original = "' + base64Path + '">'
// html += '<img src="' + item + '" data-original = "' + item + '">'
})
} */
return html;
}
/*刷新异常上报*/
function reloadExceptReport() {
getExceptionReportListAjax();
}
// 刷新预警信息
function reloadWarnInfo() {
getZbhWarnAjax();
}
// 施工方案赋值
function setSgProgramData(result) {
let html = ''
if (result && result !== 'null') {
let data = JSON.parse(result);
if (data.length) {
$.each(data, function (index, item) {
let obj = {
'fileId': item.fileId,
'bidNo': bidNoParam,
'fileName': item.fileName
}
if (item.fileName.indexOf("pdf") > 0) {
html += "<div class='program-file'>" +
"<div class='sgFileBox layout'>" +
"<img src='../../../img/program.png' onclick='openSgProgram(" + JSON.stringify(obj) + ")'>" +
"<button onclick='downLoadSgFile(" + JSON.stringify(obj) + ")'>下载</button>" +
"</div>" +
"<p>" + item.fileName + "</p>" +
"</div>"
} else if (item.fileName.indexOf("doc") > 0 || item.fileName.indexOf("docx") > 0) {
html += "<div class='program-file'>" +
"<div class='sgFileBox layout'>" +
"<img src='../../../img/program.png'>" +
"<button onclick='downLoadSgFile(" + JSON.stringify(obj) + ")'>下载</button>" +
"</div>" +
"<p>" + item.fileName + "</p>" +
"</div>"
}
})
if (!html) {
html = '<p>暂无数据</p>'
}
} else {
html = '<p>暂无数据</p>'
$('.sg-program-box').css('justify-content', 'center')
}
} else {
html = '<p>暂无数据</p>'
$('.sg-program-box').css('justify-content', 'center')
}
$('.sg-program-box').append(html)
}
// 赋值距离球机最近的杆塔
function setTowerData(data) {
let value = '无匹配杆塔';
let obj1,obj2;
console.log(jwd.split(",")[1], jwd.split(",")[0]);
if (data && data.length > 0) {
let list = [];
$.each(data, function (index, item) {
if (item.lon && item.lat) {
let objData = getDistances(lon, lat, item.lat, item.lon);
item.distance = objData.distance_m;
list.push(item);
}
})
let obj = getShortTower(list);
// 比较杆塔是否在设置的最大范围和最小范围之内
if (distanceList && distanceList.length > 0) {
let min, max;
$.each(distanceList, function (index, item) {
if (item.id === 'min_distance') {
min = item.name;
} else {
max = item.name;
}
})
let flag = compareDistance(parseFloat(max), parseFloat(min), parseFloat(obj.distance));
if (flag) {
if (content && content.indexOf(obj.towerName) >= 0) {//施工内容包含杆塔
value = obj.towerName;
} else {//施工内容不包含杆塔
value = "杆塔坐标不准确";
}
}
}
} else {
value = "杆塔坐标未维护";
}
$('#towerName').html(value);
}
// 更新重点关注班组请求异常后,重置复选框的值
function resetFocusTeam(focusTeam) {
if (focusTeam === "1") {
$('#focusTeam').prop('checked', false)
} else {
$('#focusTeam').prop('checked', true)
}
}
// 方法定义 lat,lng
function GetDistance( lat1, lng1, lat2, lng2){
var radLat1 = lat1*Math.PI / 180.0;
var radLat2 = lat2*Math.PI / 180.0;
var a = radLat1 - radLat2;
var b = lng1*Math.PI / 180.0 - lng2*Math.PI / 180.0;
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s *6378.137 ;// EARTH_RADIUS;
s = Math.round(s * 10000) / 10000;
return s;
}
// 下载施工方案
function downLoadSgFile(obj) {
let loadingMsg = layer.msg('文件下载中,请稍候...', { icon: 16, scrollbar: false, time: 0 });
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 openSgProgram(obj) {
sessionStorage.setItem("fileId", obj.fileId);
sessionStorage.setItem("fileType", '1');
sessionStorage.setItem("bidNo", obj.bidNo);
let href = '../../../pdfjs/web/viewer.html'
// window.open(href, '_blank');
let layerIndex = layui.layer.open({
title: '文件预览',
type: 2,
area: ['100%', '100%'], // 弹出框的宽高
fixed: false, // 是否固定
maxmin: true, // 是否允许最大化
shade: 0, // 隐藏弹框的遮罩层
content: href, // pdf的地址
success: function (layero, index) {
indexArr.push({ 'type': 'child', 'index': layerIndex });
},
end: function () {
if (indexArr && indexArr.length > 0) {
indexArr.forEach(function (item, index) {
if (item.index === layerIndex) indexArr.splice(index, 1);
})
}
$('#startTime').focus();
}
})
}
// 预览pdf
function showPdf(base64String) {
let pdfResult = base64String;
let layerIndex = layui.layer.open({
title: '文件预览',
type: 2,
area: ['100%', '100%'], // 弹出框的宽高
fixed: false, // 是否固定
maxmin: true, // 是否允许最大化
shade: 0, // 隐藏弹框的遮罩层
content: pdfResult, // pdf的地址
success: function (layero, index) {
indexArr.push({ 'type': 'child', 'index': layerIndex });
},
end: function () {
if (indexArr && indexArr.length > 0) {
indexArr.forEach(function (item, index) {
if (item.index === layerIndex) indexArr.splice(index, 1);
})
}
$('#startTime').focus();
}
})
// let pdfResult = base64String;
// let pdfWindow = window.open("");
// pdfWindow.document.write("<iframe width='100%' height='100%' src=" + pdfResult + "></iframe>");
// pdfWindow.document.title = "附件"
// pdfWindow.document.close();
}
function switchDiv() {
if ($('#switchBtn').val() === '打开') {
$('.left').css('width', '0%');
$("#switchBtn").css('transform', 'rotate(0deg)');
$('.center').css('width', '67.4%');
$('#switchBtn').val("关闭");
} else {
$(".left").css('width', '20%');
$("#switchBtn").css('transform', 'rotate(180deg)');
$('.center').css('width', '47.5%');
$('#switchBtn').val("打开");
init3D();
}
}
// 关闭页面
function closePage(type) {
// indexArr 不为空esc 逐层关闭页面,为空直接关闭页面
if (!type) {
if (isViewer) {
viewer.hide();
isViewer = false;
return;
}
if (isViewer2) {
viewer2.hide();
isViewer2 = false;
return;
}
if (indexArr && indexArr.length === 0) {
destoryPage();
} else {
let pageIndex = indexArr[indexArr.length - 1].index, pageType = indexArr[indexArr.length - 1].type;
if (pageType === 'parent') {
parent.layer.close(pageIndex);
indexArr.splice(indexArr.length - 1, 1);
} else {
layer.close(pageIndex);
indexArr.splice(indexArr.length - 1, 1);
}
}
} else {
destoryPage();
}
}
// 销毁页面
function destoryPage() {
// 关闭远程督查页面清空esc
localStorage.removeItem('esc');
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
}