let num = 0; let noNum = 0; let all = 0; let idParam; let util, dtree, form, layer, table, laydate; let bidCode; // 作业票文件、标段工程名称、作业票编号、建管单位、班组负责人身份证号 let filePath, bidName, ticketNo, org, workManagerNum; //initMap(); let pageNum = 1, limitSize = 30; //班组长 let bzgg = ['52', '55', '4123', '4115', '49', '4111', '46', '50', '4116', '4103', '27']; //特种作业 let tzzy = ['445', '4117', '4120', '4113', '54']; layui.extend({ dtree: '{/}../../js/layui_dtree/dtree/dtree' }).use(['form', 'layer', 'table', 'laydate', 'util', 'dtree'], function () { util = layui.util; dtree = layui.dtree; form = layui.form; layer = layui.layer; table = layui.table; laydate = layui.laydate; try { getConnect(); } catch (e) { console.error(e.message) } initTree(); pages(1, 30, ""); util.event('lay-active', { platform: function () { toPage(); }, query: function () { $('.right_table').removeClass('layui-hide'); $('.classmeeting-info').addClass('layui-hide'); } }); table.on('row(table)', function (obj) { idParam = obj.data.classId getZbhWarnAjax(); getZbhDetailAjax(); getZbhPeopleAjax(); getClassMettingSignAjax(); getZbhImageAjax(); getExceptionReportListAjax(); $('.right_table').addClass('layui-hide'); $('.classmeeting-info').removeClass('layui-hide'); }); dtree.on("node('tree')", function (obj) { if ($.isEmptyObject(obj.param.recordData.bidCode)) { obj.param.recordData.bidCode = ""; layer.alert("此无人机未绑定工程!!!", {icon: 2}) } pages(1, limitSize, obj.param.recordData.bidCode) }); dtree.on("nodedblclick('tree')", function (obj) { toVideoPage(obj.param.recordData.puId,obj.param.recordData.tCode); }); }); function pages(pageNum, pageSize, bidCode) { let params = getReqParams(pageNum, pageSize, bidCode); $.ajax({ headers: { "encrypt": sm3(JSON.stringify(params)) }, url: dataUrl + "proteam/pot/uav/getClass" + '?token=' + token, data: params, type: 'POST', async: false, success: function (result) { if (result.code === 200) { if (result.rows) { initTable(result.rows, limitSize, pageNum) laypages(result.total, pageNum, limitSize) } } else if (result.code === 500) { layer.alert(result.msg, {icon: 2}) } else if (result.code === 401) { logout(1); } }, error: function () { } }); } function laypages(total, page, limit) { layui.use(['laypage'], function () { let laypage = layui.laypage; laypage.render({ elem: 'voi-page', count: total, curr: page, limit: limit, limits: [30, 50, 100], layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'], groups: 5, jump: function (obj, first) { if (!first) { pageNum = obj.curr, limitSize = obj.limit; pages(obj.curr, obj.limit, null); } } }); }) } // 获取参数 function getReqParams(page, limit, bidCode) { return { pageNum: page + "", pageSize: limit + "", bidCode: bidCode }; } function initTable(dataList, limit, page) { table.render({ elem: "#table", id: "table", height: "full-80", limit: limit, //默认十条数据一页 data: dataList, cols: [ [//表头 { field: "number", type: "numbers", title: "序号", minWidth: 50, unresize: true, align: "center", }, { field: "bidName", title: "工程名称", unresize: true, minWidth: 200, align: "center", }, { field: 'workManager', title: "班组长", unresize: true, minWidth: 100, align: "center", templet: function (d) { return "" + d.workManager + "
" + transformNull(d.workManagerPhone) + ""; }, }, { field: "riskLevel", title: "风险等级", unresize: true, minWidth: 50, align: "center" } ], ], done: function (res, curr, count) { }, parseData: function (res) { return { "code": res.code === 200 ? 0 : res.code, "msg": res.msg, "count": res.total, "data": res.rows }; } }); } function initTree() { Ajax().post({ headers: { "encrypt": sm3(JSON.stringify({})) }, url: dataUrl + 'proteam/pot/uav/getUavData', success: function (data) { calleArr(data.data); let treeData = [{ id: "top", title: '无人机  (在线:' + num + '  ' + " 不在线:" + '' + noNum + '  ' + " 总数:" + all + ')', checkArr: "0", parentId: "-1", children: data.data, iconClass: 'iconfont icon-a-iconwurenjixunhang', spread: true, }]; dtree.render({ elem: "#tree", data: treeData, initLevel: 1, checkbar: false,//开启复选框 menubar: false, ficon: ['2'], skin: "lay", record: true, done: function (res, $ul, first) { $('.icon-a-iconwurenjixunhang1').next().css('color', "#2f82fb"); $('div[data-id$="top"]').addClass('top'); } }); } }); } /** * 遍历树数据 * @param treeData */ function calleArr(treeData) { console.log(treeData); num = 0; noNum = 0; all = 0; for (let i in treeData) { let obj = treeData[i]; obj.id = obj.puId; obj.parentId = 'top'; if (!isEmpty(obj.isOnline) && obj.isOnline == '1') { //在线图标 obj.iconClass = 'iconfont icon-a-iconwurenjixunhang1'; getUavGps(obj.puId); num++; } else { //不在线图标 obj.iconClass = 'iconfont icon-a-iconwurenjixunhang'; noNum++; } } } /** * 跳转无人机绑定页面 * @param classId 站班会id * @param idNumber 身份证号 * @param teamName 班组名称 */ function toPage() { let width = '40%', height = '50%'; layer.open({ title: ['工程绑定', 'font-size:24px;'], type: 2, skin: 'shadows', content: 'child/bandPro.html', area: [width, height], maxmin: false, success: function (layero, index) { let body = layer.getChildFrame('body', index); let iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象,执行iframe页的方法: }, end: function () { initTree(); } }); } /** * 跳转无人机绑定页面 */ function toVideoPage(puid,tCode) { let width = '50%', height = '70%'; layer.open({ title: ['视频播放', 'font-size:24px;'], type: 2, skin: 'shadows', content: 'child/UAV_Video.html', area: [width, height], maxmin: false, success: function (layero, index) { let body = layer.getChildFrame('body', index); let iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象,执行iframe页的方法: iframeWin.setParams(puid,tCode); }, end: function () { initTree(); } }); } /*站班会预警信息赋值*/ function setClassWarnInfo(result) { let html = ''; if (result) { warnInfo = result; let data = result.split(","); if (data.length) { $.each(data, function (index, item) { if (item) { html += '

' + item + '

'; } }) } } else { html += '

正常施工

' } $('.early-waring-info').empty().append(html); } /*站班会详情赋值*/ function setClassDetailData(result) { if (result) { let data = JSON.parse(result) console.log(data) let sgStatus = ''; if (data.sgStatus === '1') { sgStatus = '开工' } else if (data.sgStatus === '2') { sgStatus = '暂停' } else if (data.sgStatus === '3') { sgStatus = '完工' } $('#sgStatus').html('(' + sgStatus + ')') $('#ticketNo').html(data.ticketNo) $('#bidName').html(data.bidName) $('#workDay').html(data.workDay) $('#workingTime').html(data.startTime) $('#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; } } // 获取安全监护人 function safetyManagers(value) { let numArr = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十']; let html = ''; if (value) { let valueArr = value.split(","); valueArr.forEach((o, index) => { html += '

第' + numArr[index] + '作业面安全监护:' + o + '

'; }); return html; } else { return html; } } /*参与施工人员签名、临时人员赋值*/ 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) { 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", '#2F82FB', item); } else { tszyry += setWorkPhoto("../../img/remotePatrol/people-2-4.png", '#2F82FB', 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 += '

暂无数据

'; $('.work-people-sign').css('justify-content', 'center') } if (data.lsPeople.length) { $.each(data.lsPeople, function (index, item) { cent2 += setWorkPhoto("../../img/remotePatrol/people-3.png", '#2F82FB', item) }) } else { cent2 += '

暂无数据

'; $('.temporary-people-photo').css('justify-content', 'center') } } else { cent += '

暂无数据

'; $('.work-people-sign').css('justify-content', 'center') cent2 += '

暂无数据

'; $('.temporary-people-photo').css('justify-content', 'center') } $('.work-people-sign').empty().append(cent); $('.temporary-people-photo').empty().append(cent2); } function isRyTrue(value, allValue){ value=value+"@"; if(allValue.indexOf(value)!='-1'){//包含 return true; } return false; } /*施工人员签名*/ function setWorkPhoto(imgPath, color, item) { return '
' + '' + '

' + item.userName + '

' + '
' } function getSex(idCard) { let sexStr = ''; if (parseInt(idCard.slice(-2, -1)) % 2 === 1) { sexStr = '0' } else { sexStr = '1' } return sexStr; } /*到岗到位签到表赋值*/ function setDutyTableData(result) { let html = '职务姓名手机号签到时间'; if (result.data.length) { $.each(result.data, function (index, item) { html += '' + '' + item.peopleType + '' + '' + item.userName + '' + '' + item.phone + '' + '' + item.inTime + '' + ''; }) } else { html += '暂无数据'; } $('#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) { console.log(item); let base64Path = prefix + item.imagePath; if (item.imageType === '1') { photoList.push('') } else if (item.imageType === '2') { photoList2.push('') } else if (item.imageType === '3') { photoList3.push('') } else if (item.imageType === '4') { photoList4.push('') } else if (item.imageType === '5') { photoList5.push('') } else if (item.imageType === '6') { photoList6.push('') }else if (item.imageType === '7') { photoList7.push('') }else if (item.imageType === '8') { photoList8.push('') }else if (item.imageType === '9') { photoList9.push('') } }) } } 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); } /*关键点措施照片*/ 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('

暂无数据

').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}) } } // 预览pdf function showPdf(base64String) { let pdfResult = base64String; let pdfWindow = window.open(""); pdfWindow.document.write(""); pdfWindow.document.title = "附件" pdfWindow.document.close(); } /*异常上报赋值*/ function setExceptionReport(result) { let html = ''; if (result && result.length) { $.each(result, function (index, item) { html += '
' + '

' + (index + 1) + '

' + '
' + '

上报时间:

' + item.uploadTime + '

' + '

异常内容:

' + item.content + '

' + '

异常图片:

' + setExceptionImg(item.imgPath) + '
' + '
' + '
'; }) } else { html += '

暂无数据

' } $('.exceptionReporting-detail').empty().append(html); } function setExceptionImg(data) { let html = ''; if (data) { let imgArr = data.split(','); $.each(imgArr, function (index, item) { html += '' }) } return html; } /*刷新异常上报*/ function reloadExceptReport() { getExceptionReportListAjax(); } // 关闭页面 function closePage() { let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引 parent.layer.close(index); //再执行关闭 } function setValue(value) { if (!value) { return "暂无数据" } return value; } function setValue2(value) { if (!value) { return ''; } return value; } /** * 获取清晰物联token */ function getUavGps(puId) { let settings = { "url": qxUrl+"icvs2/GPS/C_GS_QueryLastGPSData?token=" + qxToken, "method": "POST", "timeout": 0, "headers": { "Content-Type": "application/json", }, "data": JSON.stringify({ "equipment": [ { "puid": puId, "idx": 0, "type": "无线编码器" } ] }), }; $.ajax(settings).done(function (response) { getTerminal(response); }); } /** * 创建清新平台连接 */ function getConnect() { var passWay = localStorage.getItem("passWay"); if (passWay == null || passWay == '') { passWay = 'to-2'; } let params = { "address": _cf.connParams.address, "port": _cf.connParams.port, "user": _cf.connParams.user, "password": _cf.connParams.password, "epid": _cf.connParams.epid, "fixaddr": _cf.connParams.bfix } if (passWay == 'to-2' || passWay == 'to-4') { posts(_cf.q2http_urlN, 'login', params, function (rv) { let result = { errcode: -1, token: '' } let respJSON = JSON.parse(rv.responseText); if (respJSON.hasOwnProperty('errcode')) { result.errcode = respJSON.errcode; } if (respJSON.hasOwnProperty('token')) { result.token = respJSON.token; result.errcode = 0; if (!isEmpty(result.token)) { qxUrl = _cf.q2http_urlN; qxToken = result.token; getUavGps(puId) } } }); } if (passWay == 'to-2' || passWay == 'to-3') { posts(_cf.q2http_url, 'login', params, function (rv) { let result = { errcode: -1, token: '' } let respJSON = JSON.parse(rv.responseText); if (respJSON.hasOwnProperty('errcode')) { result.errcode = respJSON.errcode; } if (respJSON.hasOwnProperty('token')) { result.token = respJSON.token; result.errcode = 0; if (!isEmpty(result.token)) { qxUrl = _cf.q2http_url; qxToken = result.token; getUavGps(puId) } } }); } }