let table, layer, form,laydate; let fontSize = '14', fontFamily = 'Alibaba PuHuiTi R', fontColor = '#fff'; const bidCode = parent.$('#bidPro').val(); layui.use(["layer", "table", "form", "laydate"], function () { layer = layui.layer; table = layui.table; form = layui.form; laydate = layui.laydate; laydate.render({ elem: "#ID-laydate-rangeLinked", range: ["#ID-laydate-start-date-1", "#ID-laydate-end-date-1"], rangeLinked: true, // 开启日期范围选择时的区间联动标注模式 --- 2.8+ 新增 }); // $("#ID-laydate-start-date-1").val(getNowTime()) // $("#ID-laydate-end-date-1").val(getNowTime()) $("#ID-laydate-start-date-1").val('2024-05-28') $("#ID-laydate-end-date-1").val('2024-06-02') let startTime = ""; let endTime = ""; if ($("#ID-laydate-start-date-1").val() != "") { startTime = $("#ID-laydate-start-date-1").val(); endTime = $("#ID-laydate-end-date-1").val(); } else { startTime = ""; endTime = ""; } getProEnvironment(startTime, endTime); }); function query(){ let startTime = ""; let endTime = ""; if ($("#ID-laydate-start-date-1").val() != "") { startTime = $("#ID-laydate-start-date-1").val(); endTime = $("#ID-laydate-end-date-1").val(); } else { startTime = ""; endTime = ""; } getProEnvironment(startTime, endTime); } function getProEnvironment(startTime, endTime) { const url = commonUrl + "screen/proEnvironment/selectProEnvironment?startDate=" + startTime + "&endDate=" + endTime + "&bidCode=" + '1512P017007Y01'; ajaxRequestGet( url, "GET", true, function () { }, function (result) { if (result.code === 200) { setData(result.data); } else if (result.code === 500) { console.error("实时监测" + result.msg); setData(null); } else if (result.code === 401) { loginout(1); } }, function (xhr, status, error) { errorFn(xhr, status, error); setData(null); }, aqEnnable ); /* 实时检测赋值 */ function setData(data) { if (data) { let pmTwo = data["PM2.5"]; let pmTen = data["PM10"]; getAirQualityChart(pmTwo, pmTen) let noise = data["噪声"]; getNoiseChart(noise); let temperature = data["温度"]; let humidity = data["湿度"]; getTemperatureHumidityChart(temperature,humidity) let warning = data["预警"]; warningList(warning); let windSpeed = data["风速"]; getWindSpeedChart(windSpeed); } } } function getTemperatureHumidityChart(temperature,humidity) { let timeData = []; let timeData1 = []; let timeData2 = []; let temperatureData = []; let humidityData = []; if (temperature) { for (let i = 0; i < temperature.length; i++){ timeData1.push(temperature[i].hour +':00'); temperatureData.push(temperature[i].val) } } if( humidity){ for (let i = 0; i < humidity.length; i++){ timeData2.push(humidity[i].hour +':00'); humidityData.push(humidity[i].val) } } if(timeData1.length>0){ timeData = timeData1 }else{ timeData = timeData2 } initTemperatureHumidityChart(timeData, temperatureData, humidityData) } function initTemperatureHumidityChart(timeData, temperatureData, humidityData) { if(timeData.length<=0){ return ""; } const myChart = echarts.init(document.getElementById("temperatureHumidityChart")); const option = { grid: { left: "8%", right: "8%", top: "20%", bottom: "5%", containLabel: true, }, legend: { data: ["温度", "湿度"], top: "12%", right: "15%", textStyle: { color: "#ffffff", fontSize: 12, }, itemWidth: 14, itemHeight: 4, icon: "rect", }, xAxis: { type: "category", data: timeData, axisLine: { lineStyle: { color: "#A6B8BB", }, }, axisLabel: { color: "#A6B8BB", fontSize: 14, }, axisTick: { show: false, }, }, yAxis: [ { type: "value", name: "°C", nameTextStyle: { color: "#ffffff", fontSize: 12, }, axisLine: { show: false, }, axisLabel: { color: "#A6B8BB", fontSize: 12, }, splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.2)', type: 'dashed' } }, }, { type: "value", name: "%", nameTextStyle: { color: "#ffffff", fontSize: 12, }, axisLine: { show: false, }, axisLabel: { color: "#A6B8BB", fontSize: 12, }, splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.2)', type: 'dashed' } }, }, ], "dataZoom": [{ "show": true, "height": 12, "xAxisIndex": [ 0 ], bottom:'8%', "start": 10, "end": 90, handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z', handleSize: '110%', handleStyle:{ color:"#d3dee5", }, textStyle:{ color:"#fff"}, borderColor:"#90979c" }, { "type": "inside", "show": true, "height": 15, "start": 1, "end": 35 }], series: [ { name: "温度", type: "bar", data: temperatureData, barWidth: "35%", itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 1, color: "#134045"}, {offset: 0.5, color: "#3EB2BB"}, {offset: 0, color: "#59E1FF"}, ]), borderRadius: [4, 4, 0, 0], }, }, { name: "湿度", type: "line", yAxisIndex: 1, data: humidityData, smooth: true, lineStyle: { color: "#00ff88", width: 3, shadowColor: "rgba(0, 255, 136, 0.5)", shadowBlur: 10, }, itemStyle: { color: "#00ff88", borderWidth: 2, borderColor: "#00ff88", }, symbolSize: 0, }, ], } myChart.setOption(option) // 响应窗口大小变化 window.addEventListener('resize', function () { myChart.resize(); }); } function getNoiseChart(noise) { var timeData = []; var noiseData = []; if (noise) { for (let i = 0; i < noise.length; i++){ timeData.push(noise[i].hour +':00'); noiseData.push(noise[i].val) } } initNoiseChart(timeData, noiseData); } function initNoiseChart(timeData, noiseData) { var myChart = echarts.init(document.getElementById('noiseChart')); var option = { grid: { left: '5%', right: '5%', bottom: '5%', top: '23%', containLabel: true }, xAxis: { type: 'category', data: timeData, axisLine: { lineStyle: { color: '#A6B8BB' } }, axisLabel: { color: '#A6B8BB', fontSize: 12 }, axisTick: { show: false } }, yAxis: { type: 'value', name: '分贝', nameTextStyle: { color: '#ffffff', fontSize: 12, }, axisLine: { show: false, }, axisLabel: { color: '#A6B8BB', fontSize: 12, }, splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.2)', type: 'dashed' } } }, "dataZoom": [{ "show": true, "height": 12, "xAxisIndex": [ 0 ], bottom:'8%', "start": 10, "end": 90, handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z', handleSize: '110%', handleStyle:{ color:"#d3dee5", }, textStyle:{ color:"#fff"}, borderColor:"#90979c" }, { "type": "inside", "show": true, "height": 15, "start": 1, "end": 35 }], series: [ { name: '噪声', type: 'line', data: noiseData, symbolSize: 0, lineStyle: { color: "#00FEFC", width: 3, shadowColor: "rgba(0, 255, 136, 0.5)", shadowBlur: 10, }, itemStyle: { color: "#00ff88", borderWidth: 2, borderColor: "#00ff88", }, areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#1ED6FF'}, {offset: 1, color: 'rgba(30,214,255,0)'} ]) } }] }; myChart.setOption(option); // 响应窗口大小变化 window.addEventListener('resize', function () { myChart.resize(); }); } function getWindSpeedChart(windSpeed) { var timeData = []; var noiseData = []; if (windSpeed) { for (let i = 0; i < windSpeed.length; i++){ timeData.push(windSpeed[i].hour +':00'); noiseData.push(windSpeed[i].val) } } initWindSpeedChart(timeData, noiseData); } function initWindSpeedChart(timeData, noiseData) { var myChart = echarts.init(document.getElementById('windSpeedChart')); var option = { grid: { left: '5%', right: '5%', bottom: '5%', top: '23%', containLabel: true }, xAxis: { type: 'category', data: timeData, axisLine: { lineStyle: { color: '#A6B8BB' } }, axisLabel: { color: '#A6B8BB', fontSize: 12 }, axisTick: { show: false } }, yAxis: { type: 'value', name: 'm/s', nameTextStyle: { color: '#ffffff', fontSize: 12, }, axisLine: { show: false, }, axisLabel: { color: '#A6B8BB', fontSize: 12, }, splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.2)', type: 'dashed' } } }, "dataZoom": [{ "show": true, "height": 12, "xAxisIndex": [ 0 ], bottom:'8%', "start": 10, "end": 90, handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z', handleSize: '110%', handleStyle:{ color:"#d3dee5", }, textStyle:{ color:"#fff"}, borderColor:"#90979c" }, { "type": "inside", "show": true, "height": 15, "start": 1, "end": 35 }], series: [ { name: '噪声', type: 'line', data: noiseData, symbolSize: 0, lineStyle: { color: "#1CFFA3 ", width: 3, shadowColor: "rgba(0, 255, 136, 0.5)", shadowBlur: 10, }, itemStyle: { color: "#00ff88", borderWidth: 2, borderColor: "#00ff88", }, areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#1CFFA3'}, {offset: 1, color: 'rgba(28,255,163,0)'} ]) } }] }; myChart.setOption(option); // 响应窗口大小变化 window.addEventListener('resize', function () { myChart.resize(); }); } function getAirQualityChart(pmTwo, pmTen) { var timeData = []; var timeData1 = []; var timeData2 = []; var pm25Data = []; var pm10Data = []; if (pmTwo) { for (let i = 0; i < pmTwo.length; i++){ timeData1.push(pmTwo[i].hour +':00'); pm25Data.push(pmTwo[i].val) } } if (pmTen) { for (let i = 0; i < pmTen.length; i++){ timeData2.push(pmTen[i].hour +':00'); pm10Data.push(pmTen[i].val) } } if (timeData1){ timeData = timeData1; } else { timeData = timeData2; } initAirQualityChart(timeData, pm25Data, pm10Data); } function initAirQualityChart(timeData, pm25Data, pm10Data) { var myChart = echarts.init(document.getElementById('airQualityChart')); var option = { legend: { data: ['PM2.5', 'PM10'], top: "12%", right: "5%", textStyle: { color: "#ffffff", fontSize: 12, }, itemWidth: 14, itemHeight: 4, icon: "rect", }, grid: { left: '5%', right: '5%', bottom: '5%', top: '22%', containLabel: true }, xAxis: { type: 'category', data: timeData, axisLine: { lineStyle: { color: '#A6B8BB' } }, axisLabel: { color: '#A6B8BB', fontSize: 12 }, axisTick: { show: false } }, yAxis: { type: 'value', name: 'Jpg/m³', nameTextStyle: { color: 'rgba(255,255,255,0.8)', fontSize: 12 }, axisLine: { show:false, }, axisLabel: { color: '#A6B8BB', fontSize: 12, formatter: '{value}' }, splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.2)', type: 'dashed' } } }, "dataZoom": [{ "show": true, "height": 12, "xAxisIndex": [ 0 ], bottom:'8%', "start": 10, "end": 90, handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z', handleSize: '110%', handleStyle:{ color:"#d3dee5", }, textStyle:{ color:"#fff"}, borderColor:"#90979c" }, { "type": "inside", "show": true, "height": 15, "start": 1, "end": 35 }], series: [ { name: 'PM2.5', type: 'line', data: pm25Data, symbolSize: 0, color: '#00FEFC', // 添加color属性 lineStyle: { color: '#00FEFC', width: 3 }, areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#1ED6FF'}, {offset: 1, color: 'rgba(30,214,255,0)'} ]) } }, { name: 'PM10', type: 'line', data: pm10Data, color: '#1CFFA3', // 添加color属性 symbolSize: 0, lineStyle: { color: '#1CFFA3', width: 3 }, areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#1CFFA3'}, {offset: 1, color: 'rgba(28,255,163,0)'} ]) } } ] }; // 使用配置项和数据显示图表 myChart.setOption(option); // 响应窗口大小变化 window.addEventListener('resize', function () { myChart.resize(); }); } function warningList(warning){ // 确保 efficiency 是数组且不为空 const tableData = warning && warning.length > 0 ? warning : []; if (tableData.length === 0) { console.log('没有数据可显示'); // 可以显示空数据提示 document.getElementById('dome1').innerHTML = '