// 工程类型默认为空、天气数据默认为空、作业票默认为当日、日计划默认为当日、定时刷新启动按钮 let form, layer, formSelects, laydate, proType = '', classType = '1', dayType = '3', scheduledTask = false, scheduledTask2 = false; // 存放地图作业点、天气集合 let mainMapPointList = [], mapPointList = [], weatherList = [], showWeatherList = [],gtList=[]; // echarts 展示的是否是地市地图 let isCity = false; // 默认展示周计划 let typeValue = '1'; // 周风险/日风险 历史记录 默认展示日 ; 作业票 历史记录 默认展示日 let dateType = '1', dateType2 = '1'; layui.config({ base: "../../js/layui/", //此处路径请自行处理, 可以使用绝对路径 }).extend({ formSelects: 'formSelects-v4' }).use(['form', 'layer', 'formSelects', 'laydate'], function () { form = layui.form; layer = layui.layer; formSelects = layui.formSelects; laydate = layui.laydate; laydate.render({ elem: '#weekRiskDate', //指定元素 元素选择器 type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒) trigger: 'click', format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss btns: ['clear', 'now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定 done: function (value, date) { //时间回调 myChart4.dispose(); myChart4 = echarts.init(document.getElementById('echarts-two')); getWeekRiskNumAjax(); } }); laydate.render({ elem: '#classDate', //指定元素 元素选择器 type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒) trigger: 'click', format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss btns: ['clear', 'now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定 done: function (value, date) { //时间回调 myChart7.dispose(); myChart7 = echarts.init(document.getElementById('echarts-five')); mergeData(); } }); $('#weekRiskDate').val(getNowTime()) $('#classDate').val(getNowTime()) loadData(); // 周计划下拉选监听 formSelects.on('city', function (id, val, vals) { getWeekRiskNumAjax(); }, true); // 天气切换 form.on('switch(weather)', function (data) { let terrainFlag = $(this).parent('.layui-form-item').next().find('input').eq(0).prop('checked') showWeatherList.splice(0, showWeatherList.length); mapPointList.splice(0, mapPointList.length); if (this.checked) { $.each(weatherList, function (index, item) { showWeatherList.push(item) }) if (!terrainFlag) { map([]); } else { clearOverlay(2) } } else { mapSearch(); if (!terrainFlag) { map(mapPointList); } else { clearOverlay(1) } } }); //地形切换 form.on('switch(terrain)', function (data) { let weatherFlag = $(this).parent('.layui-form-item').prev().find('input').eq(0).prop('checked') showWeatherList.splice(0, showWeatherList.length); mapPointList.splice(0, mapPointList.length); if (this.checked) { $('#allMap').css({ 'width': '100%', height: '100%' }); $('#content-box').css({ 'position': 'relative', 'top': '-100%' }); $('#left').css({ 'background': 'url("../../img/compreDisplay/left-back.png") no-repeat 0 0 / 100% 100%' }); $('#right').css({ 'background': 'url("../../img/compreDisplay/right-back.png") no-repeat 0 0 / 100% 100%' }); $('#echarts-map').css('display', 'none'); if (!weatherFlag) { mapSearch(); initMap(1) } else { $.each(weatherList, function (index, item) { showWeatherList.push(item) }) initMap(2) } } else { $('#allMap').empty().css({ 'width': '0', 'height': '0' }); $('#left').css({ 'background': 'transparent' }); $('#right').css({ 'background': 'transparent' }); $('#content-box').removeAttr('style'); $('#echarts-map').removeAttr('style'); if (!weatherFlag) { searchRiskData(); console.error(mapPointList); map(mapPointList); } else { $.each(weatherList, function (index, item) { showWeatherList.push(item) }) } } }); //地形切换 form.on('switch(terrain2)', function (data) { // let weatherFlag = $(this).parent('.layui-form-item').prev().find('input').eq(0).prop('checked') // showWeatherList.splice(0, showWeatherList.length); // mapPointList.splice(0, mapPointList.length); if (this.checked) { $('#allMap').css({ 'width': '100%', height: '100%' }); $('#content-box').css({ 'position': 'relative', 'top': '-100%' }); $('#left').css({ 'background': 'url("../../img/compreDisplay/left-back.png") no-repeat 0 0 / 100% 100%' }); $('#right').css({ 'background': 'url("../../img/compreDisplay/right-back.png") no-repeat 0 0 / 100% 100%' }); $('#echarts-map').css('display', 'none'); $('.bid-pro-select').removeAttr('style') // mapSearch(); initMap2(1) } else { $('#allMap').empty().css({ 'width': '0', 'height': '0' }); $('#left').css({ 'background': 'transparent' }); $('#right').css({ 'background': 'transparent' }); $('#content-box').removeAttr('style'); $('#echarts-map').removeAttr('style'); $('.bid-pro-select').css('display', 'none'); searchRiskData(); console.error(mapPointList); map(mapPointList); } }); form.on('select(bidPro)', function (data) { let value = data.value; let valueArr = value.split('@'); getSignProTowerAjax(valueArr[0],valueArr[1]); }); }) // 工程类型选中 $(".pro-type").click(function (e) { $('.pro-type').each(function () { if ($(this).hasClass('check-p')) { $(this).removeClass('check-p') } }) $(this).addClass('check-p'); proType = $(this).attr("proValue"); getProNumByType(proType, '', 1); getTicketNumAjax(); if (typeValue === '2') { getDayPlanNumAjax(); } }); // 周风险和日计划切换 $(".change-type").click(function (e) { $('.change-type').each(function () { if ($(this).hasClass('check-p')) { $(this).removeClass('check-p') } }) $(this).addClass('check-p'); typeValue = $(this).attr("typeValue"); if (typeValue === '1') { $('.main-box2').removeAttr('style'); $('.main-box').css('display', 'none'); myChart4.dispose(); myChart4 = echarts.init(document.getElementById('echarts-two')); getWeekRiskNumAjax(); loadHistoryAjax('1',dateType); } else if (typeValue === '2') { $('.main-box2').css('display', 'none'); $('.main-box').removeAttr('style'); myChart3.dispose(); myChart3 = echarts.init(document.getElementById('echarts-one')); getDayPlanNumAjax(); loadHistoryAjax('2',dateType); } }); // 周风险/日风险 历史记录 日/周/月 选中 $(".change-type2").click(function (e) { $('.change-type2').each(function () { if ($(this).hasClass('check-p')) { $(this).removeClass('check-p') } }) $(this).addClass('check-p'); dateType = $(this).attr("dateType"); myChart9.dispose(); myChart9 = echarts.init(document.getElementById('plan-echarts')); if (typeValue === '1') { loadHistoryAjax('1',dateType); } else if (typeValue === '2') { loadHistoryAjax('2',dateType); } }); // 作业票 历史记录 日/周/月 选中 $(".change-type3").click(function (e) { $('.change-type3').each(function () { if ($(this).hasClass('check-p')) { $(this).removeClass('check-p') } }) $(this).addClass('check-p'); dateType2 = $(this).attr("dateType"); myChart10.dispose(); myChart10 = echarts.init(document.getElementById('ticket-history-echarts')); loadHistoryAjax('3',dateType2); }); /*日计划选中*/ $(".date-type").click(function (e) { $('.date-type').each(function () { if ($(this).find('p').eq(0).hasClass('check-p2')) { $(this).find('p').eq(0).removeClass('check-p2') $(this).find('p').eq(0).next('img').css('display', 'none') } }) $(this).find('p').eq(0).addClass('check-p2') $(this).find('p').eq(0).next('img').removeAttr('style') dayType = $(this).find('p').attr("dayValue"); myChart3.dispose(); myChart3 = echarts.init(document.getElementById('echarts-one')); getDayPlanNumAjax(); }); /*站班会统计选中*/ $(".date3-type").click(function (e) { $('.date3-type').each(function () { if ($(this).find('p').eq(0).hasClass('check-p3')) { $(this).find('p').eq(0).removeClass('check-p3') $(this).find('p').eq(0).next('img').css('display', 'none') } }) classType = $(this).find('p').attr("classType") $(this).find('p').eq(0).addClass('check-p3') $(this).find('p').eq(0).next('img').removeAttr('style') if (classType === '2') { $('.date3-type img').css('width', '32px') } myChart7.dispose(); myChart7 = echarts.init(document.getElementById('echarts-five')); mergeData(); }); /*地图风险等级选中*/ $(".check-risk").click(function (e) { let checkedName = $(this).find('p').eq(0).attr("checkedName"); let isCheck = $(this).attr("isCheck"); if (checkedName === '' && isCheck === '1') { $('.check-risk').each(function () { if ($(this).attr("isCheck") === '1') { $(this).attr("isCheck", '0') let checkedValue = $(this).find('p').eq(0).attr("checkedName"); $(this).find('img').eq(0).attr("src", setRiskIcon(checkedValue, 1)) } }) } else if (checkedName === '' && isCheck === '0') { $('.check-risk').each(function () { if ($(this).attr("isCheck") === '0') { $(this).attr("isCheck", '1') let checkedValue = $(this).find('p').eq(0).attr("checkedName"); $(this).find('img').eq(0).attr("src", setRiskIcon(checkedValue, 2)) } }) } else if (checkedName !== '' && isCheck === '1') { $(this).attr("isCheck", '0') $(this).find('img').eq(0).attr("src", setRiskIcon(checkedName, 1)) } else if (checkedName !== '' && isCheck === '0') { $(this).attr("isCheck", '1') $(this).find('img').eq(0).attr("src", setRiskIcon(checkedName, 2)) } // let weatherFlag = $('.switch-form').find('.layui-form-item').eq(0).find('input').eq(0).prop('checked') let weatherFlag = false // let terrainFlag = $('.switch-form').find('.layui-form-item').eq(1).find('input').eq(0).prop('checked') let terrainFlag = $('.switch-form').find('.layui-form-item').eq(0).find('input').eq(0).prop('checked') if (!weatherFlag) { mapSearch(); if (!terrainFlag) { if (!isCity) { map(mapPointList) } else { let dataList = mapPointList.filter(item => { if (item.buildCode === clickCityCode) { return item } }) map2(dataList) } } else { clearOverlay(1) } } }); // 设置风险等级选中样式 function setRiskIcon(value, type) { console.log(value) if (value && type === 1) { return '../../img/title-btn/no-check/risk-' + value + '-nocheck.png'; } else if (!value && type === 1) { return '../../img/title-btn/no-check/risk-1-nocheck.png'; } else if (value && type === 2) { return '../../img/title-btn/check/risk-' + value + '-check.png'; } else if (!value && type === 2) { return '../../img/title-btn/check/risk-1-check.png'; } } /*返回echarts主地图*/ function back() { $('.switch-type').removeAttr('style'); $('.switch-btn').removeAttr('style'); $('.switch-type2').css('display', 'none'); $('.back').css('display', 'none'); echarts.init(document.getElementById('echarts-map2')).dispose(); clickCityName = null, clickCityCode = null; isCity = false; map(mapPointList); } /*建管单位赋值*/ function setOrg(orgList, type) { let city = formSelects.value('city', 'val'); let keys = []; $.each(orgList, function (index, item) { let temp = { "name": item.name + "(" + item.num + "," + item.rate + ")", "value": item.code, "titleName": item.name }; keys.push(temp); }) formSelects.data('city', 'local', { arr: keys }); if (type) { formSelects.value('city', city) } } /*地图关键字搜索*/ function searchRiskData() { mapSearch(); let weatherFlag = $('.switch-form').find('.layui-form-item').eq(0).find('input').eq(0).prop('checked') let terrainFlag = $('.switch-form').find('.layui-form-item').eq(1).find('input').eq(0).prop('checked') if (!weatherFlag) { if (!terrainFlag) { map(mapPointList) } else { clearOverlay(1) } } else { showWeatherList.splice(0, showWeatherList.length) $.each(weatherList, function (index, item) { showWeatherList.push(item) }) if (!terrainFlag) { map([]) } else { clearOverlay(2) } } } /*加载echarts图*/ initEchartsOne(); /*地图关键字搜索、风险等级选中*/ function mapSearch() { let selRiskList = []; mapPointList.splice(0, mapPointList.length); $('.check-risk').each(function () { if ($(this).attr("isCheck") === '1') { if ($(this).find('p').eq(0).attr("checkedName")) { selRiskList.push($(this).find('p').eq(0).attr("checkedName")) } } }) if (selRiskList.length) { $.each(selRiskList, function (index, item) { let dataList = mainMapPointList.filter(item2 => { if (item === '4') { return item2.riskType === '4' || item2.riskType === '5'; } else { return item2.riskType === item } }) $.each(dataList, function (index3, item3) { mapPointList.push(item3) }) }) } let keyWord = $('.keyWord').val(); if (keyWord) { let dataList = mapPointList.filter(item => { if (item.proName.indexOf(keyWord) != -1 || item.foreman.indexOf(keyWord) != -1) { return item } }) mapPointList.splice(0, mapPointList.length); if (dataList.length > 0) { $.each(dataList, function (index, item) { mapPointList.push(item) }) } } } // 加载页面数据 function loadData() { getProNumByType(proType, '', 1); getWeekRiskNumAjax(); getTicketNumAjax(); getDayAttendanceNumAjax(1); getRiskMapAjax(); // getWeatherMapAjax(); // getWeatherAlertAjax(); // getDayPlanNumAjax(); timedRefresh(); // timedRefresh2(); mergeData(); getTodayWarnInfo(); loadHistoryAjax('1','1'); loadHistoryAjax('3','1'); getGtList(); }