let form, layer, laydate, checkedDate; let myChart4 = echarts.init(document.getElementById('voi-echarts')); layui.use(['form', 'laydate', 'layer'], function () { layer = layui.layer; form = layui.form; laydate = layui.laydate; laydate.render({ elem: '#createTime', //指定元素 元素选择器 type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒) trigger: 'click', range: true, format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss max: Date.parse(new Date()), btns: ['now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定 done: function (value, date) { //时间回调 let dateArr = value.split(' - '); setDateData(getAllDate(dateArr[0], dateArr[1])); getDaily(dateArr[1]); } }); checkedDate = getNowTime(); $('#createTime').val(getBeforeDate(9) + " - " + getNowTime()) setDateData(getAllDate(getBeforeDate(9), getNowTime())); getDaily(getNowTime()); }); // 设置日期数据 function setDateData(data) { let reverseData = data.reverse(); let html = ''; reverseData.forEach((item, index) => { if (index === 0) { html += '

' + item + '

'; } else { html += '

' + item + '

'; } }); $('.date-box').empty().append(html); } function dailyDetail(data, index) { $('.date-box').find('p').each(function () { if ($(this).hasClass('p-checked')) { $(this).removeClass('p-checked'); } }) $('.date' + index).addClass('p-checked'); $('.daily-box').css('display', 'none'); $('.download-btn').css('display', 'none'); getDaily(data); checkedDate = data; } // 刷新数据 function refreshData(){ let loadingMsg = layer.msg('数据更新中,请稍候...', {icon: 16, scrollbar: false, time: 0, offset: ['45%', '57%']}); $.ajax({ headers: { "encrypt": sm3(JSON.stringify({})) }, type: 'POST', url: dataUrl + "proteam/pot/dailyDutyReport/refreshData?token=" + token, data: {}, async: false, dataType: 'json', success: function (result) { layer.close(loadingMsg); if (result.code === 500) { return layer.alert(result.msg, {icon: 2}) } else if (result.code === 401) { logout(1) } else if (result.code === 200) { getDaily(getNowTime()); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { layer.close(loadingMsg); // 关闭提示层 layer.msg('数据刷新发生异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000}); } }); } // 下载日报 function downloadDaily() { let loadingMsg = layer.msg('日报下载中,请稍候...', {icon: 16, scrollbar: false, time: 0, offset: ['45%', '57%']}); let url = dataUrl + 'proteam/pot/dailyDutyReport/downloadDaily?currentDay=' + checkedDate + "&chineseDate=" + setDate(checkedDate) + "&token=" + token; let xhr = new XMLHttpRequest(); xhr.open("get", url, true); xhr.responseType = "blob"; // 转换流 xhr.setRequestHeader("encrypt", sm3(JSON.stringify({ currentDay: checkedDate, chineseDate: setDate(checkedDate) }))); 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 = "国网安徽电力基建安全日报" + setDate(checkedDate) + ".docx"; // 文件名 } else { layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000, offset: ['45%', '57%']}); } a.click() window.URL.revokeObjectURL(url) }; xhr.send(); } // 加载日报数据 function getDaily(currentDay) { let loadingMsg = layer.msg('数据加载中,请稍候...', {icon: 16, scrollbar: false, time: 0, offset: ['45%', '57%']}); $.ajax({ headers: { "encrypt": sm3(JSON.stringify({ currentDay: currentDay })) }, type: 'POST', url: dataUrl + "proteam/pot/dailyDutyReport/getDailyData?token=" + token, data: { currentDay: currentDay }, async: false, dataType: 'json', success: function (result) { layer.close(loadingMsg); if (result.code === 500) { setDailyData(currentDay, null); return layer.alert(data.msg, {icon: 2}) } else if (result.code === 401) { logout(1) } else if (result.code === 200) { if (result.data) { setDailyData(currentDay, result.data); } else { setDailyData(currentDay, null); } } }, error: function (XMLHttpRequest, textStatus, errorThrown) { layer.close(loadingMsg); // 关闭提示层 layer.msg('数据加载发生异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000}); setDailyData(currentDay, null); } }); } // 日报赋值 function setDailyData(data, dataMap) { $('.daily-date').html(setDate(data)); $('.daily-box').css('display', 'block'); $('.download-btn').css('display', 'block'); if(data === getNowTime()){ $('.refresh-btn').css('display', 'block'); }else{ $('.refresh-btn').css('display', 'none'); } setModuleOneData(dataMap); setModuleTwoData(dataMap); setModuleThreeData(dataMap); setModuleFourData(dataMap); setModuleFiveData(dataMap); setModuleSixData(dataMap); setModuleSevenData(dataMap); setModuleEightData(dataMap); setModuleNineData(dataMap); setModuleTenData(dataMap); setModuleElevenData(dataMap); initEchartsTwo(dataMap.moduleTwelve); setModuleThirteenData(dataMap); } /*安全质量检查总体情况赋值*/ function setModuleOneData(data) { if (data) { let moduleOne = data.moduleOne; $('#moduleOneNum').html(moduleOne.moduleOneNum); $('#moduleOneNum2').html(moduleOne.moduleOneNum2); $('#moduleOneNum3').html(moduleOne.moduleOneNum3); $('#moduleOneNum4').html(moduleOne.moduleOneNum4); $('#moduleOneNum5').html(moduleOne.moduleOneNum5); $('#moduleOneNum6').html(moduleOne.moduleOneNum6); } } /*班组及人员情况赋值*/ function setModuleTwoData(data) { if (data) { let moduleTwo = data.moduleTwo; $('#moduleTwoNum').html(moduleTwo.moduleTwoNum); $('#moduleTwoNum2').html(moduleTwo.moduleTwoNum2); $('#moduleTwoNum3').html(moduleTwo.moduleTwoNum3); } } /*作业计划执行情况-日计划实施赋值*/ function setModuleThreeData(data) { if (data) { let moduleThree = data.moduleThree; $('#moduleThreeNum').html(moduleThree.moduleThreeNum); $('#moduleThreeNum2').html(moduleThree.moduleThreeNum2); $('#moduleThreeNum3').html(moduleThree.moduleThreeNum3); $('#moduleThreeNum4').html(moduleThree.moduleThreeNum4); } } /*作业计划执行情况-今日视频监控接入情况赋值*/ function setModuleFourData(data) { if (data) { let moduleFour = data.moduleFour; $('.moduleFourNum').html(moduleFour.moduleFourNum); $('.moduleFourNum2').html(moduleFour.moduleFourNum2); $('#moduleFourNum3').html(moduleFour.moduleFourNum3); } } /*督查情况-总体情况赋值*/ function setModuleFiveData(data) { if (data) { let moduleFive = data.moduleFive; $('.moduleFiveNum').html(moduleFive.moduleFiveNum); $('#moduleFiveNum2').html(moduleFive.moduleFiveNum2); $('#moduleFiveNum3').html(moduleFive.moduleFiveNum3); $('#moduleFiveNum4').html(moduleFive.moduleFiveNum4); $('#moduleFiveNum5').html(moduleFive.moduleFiveNum5); } } /*关键措施照片上传和日报评价情况赋值*/ function setModuleSixData(data) { if (data) { let moduleSix = data.moduleSix; let html = ''; if (moduleSix) { moduleSix.forEach((item, index) => { html += '' + (index + 1) + '' + '' + item.name + '' + '' + item.num + '' + '' + item.num + '' + '' + item.rate + '' + '' + item.eval + '' }) } else { html += '' } $('.two-table tbody').empty().append(html); } } /*新进班组风险提示赋值*/ function setModuleSevenData(data) { if (data) { let moduleSeven = data.moduleSeven; let html = ''; if (moduleSeven.length > 0) { moduleSeven.forEach((item, index) => { html += '' + (index + 1) + '' + '' + setValue2(item.bidName) + '' + '' + setValue2(item.orgName) + '' + '' + setValue2(item.workManager) + '' }) } else { html += '' } $('.four-table tbody').empty().append(html); } } /*无作业班组核查赋值*/ function setModuleEightData(data) { if (data) { let moduleEight = data.moduleEight; let html = ''; if (moduleEight.length > 0) { moduleEight.forEach((item, index) => { html += '' + (index + 1) + '' + '' + setValue2(item.bidName) + '' + '' + setValue2(item.orgName) + '' + '' + setValue2(item.workManager) + '' + '' + '' }) } else { html += '' } $('.five-table tbody').empty().append(html); } } /*班组人员较大变化核查赋值*/ function setModuleNineData(data) { if (data) { let moduleNine = data.moduleNine; let html = ''; if (moduleNine.length > 0) { moduleNine.forEach((item, index) => { html += '' + (index + 1) + '' + '' + setValue2(item.bidName) + '' + '' + setValue2(item.orgName) + '' + '' + setValue2(item.workManager) + '' + '' + '' }) } else { html += '' } $('.six-table tbody').empty().append(html); } } /*二级风险到岗到位抽查情况赋值*/ function setModuleTenData(data) { if (data) { let moduleTen = data.moduleTen; let html = ''; if (moduleTen.length > 0) { moduleTen.forEach((item, index) => { html += '' + (index + 1) + '' + item.bidName + '' + arriveInPlace(item.yzNum) + '' + arriveInPlace(item.jlNum) + '' + arriveInPlace(item.sgNum) + '' }) } else { html += '' } html += '备注:“/”代表未到岗到位,“√”代表到岗到位。'; $('.seven-table tbody').empty().append(html); } } // 备注:“/”代表未到岗到位,“√”代表到岗到位。 function arriveInPlace(value) { if (parseInt(value) > 0) { return '√'; } return '/'; } function setModuleElevenData(data) { let html = ''; if(data.moduleEleven && data.moduleEleven.length > 0){ $.each(data.moduleEleven,function(index,item){ html += '' + '' + '' + '' + '' + '' + '' + '
'+item.levelId+'
违章现场'+item.proName+'
违章照片'+setVoiPhotos(item)+'
违章内容'+item.content+'
违章依据'+item.voiYj+'
'; }) }else{ html += '' + '' + '' + '' + '' + '' + '' + '
一般违章
违章现场
违章照片
违章内容
违章依据
'; } $('.general-voi-box').empty().append(html); if(data.moduleEleven && data.moduleEleven.length > 0){ $.each(data.moduleEleven,function(index,item){ let viewer = new Viewer(document.getElementById('general-voi'+index+''), { url: 'data-original', show: function () { viewer.update(); } }); }) } } /* 违章照片 */ function setVoiPhotos(obj){ let imgPath = obj.imgPath, imgPathArr = imgPath.split(','), cent = '' $.each(imgPathArr, function (index, item) { let path = photoUrl + item + '?token=' + token cent += '' }) return cent; } /* 违章数量 */ function setModuleThirteenData(data){ if(data.moduleThirteen){ let moduleThirteen = data.moduleThirteen; $('.fiveNum6').html(moduleThirteen.fiveNum6); $('#fiveNum7').html(moduleThirteen.fiveNum7); $('.fiveNum8').html(moduleThirteen.fiveNum8); $('#fiveNum9').html(moduleThirteen.fiveNum9); $('#fiveNum10').html(moduleThirteen.fiveNum10); $('#fiveNum11').html(moduleThirteen.fiveNum11); } } /*周风险echarts*/ function initEchartsTwo(dataList) { let xAxisList = []; let data = []; let data2 = []; let data3 = []; $.each(dataList, function (index, item) { xAxisList.push(item.orgName) data.push(item.num) data2.push(item.yzNum) data3.push(item.ybNum) }) let fontSize = '14'; // 基于准备好的dom,初始化echarts图表 let option = { backgroundColor: 'transparent', tooltip: { show: false }, legend: { // right: '3%', top: '92%', itemWidth: 10, itemHeight: 10, itemGap: 15, // 环图之间间隔,图例防抖动 inactiveBorderWidth: 0, itemStyle: { borderWidth: 0, }, selectedMode: false }, grid: { left: '3%', right: '3%', bottom: '10%', top: '15%', containLabel: true, }, calculable: true, xAxis: [{ type: 'category', axisLabel: { interval: 0, // 解决x轴名称过长问题 rotate: 45, textStyle: { color: '#262626', fontSize: 14, fontFamily: 'Alibaba PuHuiTi R' } }, axisLine: { show: false, lineStyle: { //y轴网格线设置 color: '#262626', width: 1, } }, data: xAxisList, }], yAxis: [{ type: 'value', // name: "单位/个", nameGap: 8, nameTextStyle: { color: "#262626", }, axisTick: { show: false, }, axisLine: { show: false, lineStyle: { //y轴网格线设置 color: '#2c2c2c', width: 1, } }, splitLine: { //保留网格线 show: true, lineStyle: { //y轴网格线设置 color: '#101C4A', width: 1, } }, axisLabel: { show: true, textStyle: { fontSize: 16, color: '#262626', //字体颜色 fontFamily: 'Alibaba PuHuiTi R' } }, }], series: [ { name: '作业现场', type: 'bar', z: 1, barWidth: 6, barGap: '100%', label: { show: true, position: 'top', textStyle: { color: '#262626' } }, itemStyle: { normal: { color: new echarts.graphic.LinearGradient( 0, 1, 0, 0, [{ offset: 0, color: '#4472c4' }, { offset: 1, color: '#4c87ef' } ] ) }, }, data: data, }, { name: '严重违章', type: 'bar', barGap: '100%', z: 1, barWidth: 6, label: { show: true, position: 'top', textStyle: { color: '#262626' } }, itemStyle: { normal: { color: new echarts.graphic.LinearGradient( 0, 1, 0, 0, [{ offset: 0, color: '#618b35' }, { offset: 1, color: '#97ec3e' } ] ) }, }, data: data2, }, { name: '一般违章', type: 'bar', barGap: '100%', z: 1, barWidth: 6, label: { show: true, position: 'top', textStyle: { color: '#262626' } }, itemStyle: { normal: { color: new echarts.graphic.LinearGradient( 0, 1, 0, 0, [{ offset: 0, color: '#a83232' }, { offset: 1, color: '#d02020' } ] ) }, }, data: data3, } ] }; myChart4.setOption(option, true); window.addEventListener("resize", function () { myChart4.resize(); }); }