From c709e3310a786033efeb19581bf539660fb62fa3 Mon Sep 17 00:00:00 2001 From: fl <3098731433@qq.com> Date: Wed, 23 Jul 2025 22:24:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=AF=E5=A2=83=E7=9B=91=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/pages/newDataAnalysis/environDetection.js | 548 ++++++++----------- pages/newDataAnalysis/environDetection.html | 174 ++++-- 2 files changed, 367 insertions(+), 355 deletions(-) diff --git a/js/pages/newDataAnalysis/environDetection.js b/js/pages/newDataAnalysis/environDetection.js index 557ad94..f6c4ad6 100644 --- a/js/pages/newDataAnalysis/environDetection.js +++ b/js/pages/newDataAnalysis/environDetection.js @@ -4,343 +4,255 @@ layui.use(['layer', 'table', 'form'], function () { layer = layui.layer; table = layui.table; form = layui.form; - let bidCode = parent.parent.$('#bidPro').val() - let filterList = dataList.filter(item => { - return item.bidCode === bidCode; - }); - initTable(filterList[0].list || []); - initEcharts(filterList[0].list[0]); + initEcharts(); }); -function initTable(data) { - table.render({ - elem: '#demo2', - id: 'demo2', - skin: 'line', - page: true, - height: 'full-140', - headers: { - "decrypt": "decrypt", - "Authorization": token - }, - data: data, - cols: [[ - { type: 'numbers', title: '序号', width: '10%' }, // 添加序号列 - { field: 'userName', title: '工人', align: 'center', width: '10%' }, - { field: 'teamName', title: '班组', align: 'center', width: '10%' }, - { field: 'postName', title: '工种', align: 'center', width: '10%' }, - { field: 'attDay', title: '出勤天数', align: 'center', width: '10%' }, - { - field: 'workTime', title: '工作时长', align: 'center', width: '10%', - templet: function (d) { - return d.workTime + '小时'; - } - }, - { - field: 'completeWorkload', title: '完成工作量', align: 'center', width: '10%', - templet: function (d) { - return d.completeWorkload + d.completeWorkloadUnit; - } - }, - { - field: 'unitTimeOutput', title: '单位时间产量', align: 'center', width: '10%', - templet: function (d) { - return d.unitTimeOutput + d.unitTimeOutputUnit; - } - }, - { - field: 'unitTimeOutput', title: '单位时间标准产量', align: 'center', width: '10%', - templet: function (d) { - return d.standardTimeOutput + d.unitTimeOutputUnit; - } - }, - { - field: 'rateLevel', title: '效率评级', align: 'center', width: '10%', - templet: function (d) { - let color = ''; - if (d.rateLevel === '高效') { - color = 'green'; - } else if (d.rateLevel === '达标') { - color = 'yellow'; - } else if (d.rateLevel === '低效') { - color = 'red'; - } - return '

' + d.rateLevel + '

'; - } - - } - ]], - initComplete: function () { - // 在表格渲染完成后,重新渲染序号列 - var that = this.elem.next(); - var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table'); - tool.find("tr").each(function (index, item) { - $(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1); - }); - }, - done: function (res, curr, count, origin) { - // console.log(res); - } - }) - table.on('rowDouble(demo2)', function (obj) { - initEcharts(obj.data); - }); -} - -function query(type) { - let userName = $('#userName').val(); - let bidCode = parent.parent.$('#bidPro').val() - let filterList = dataList.filter(item => { - return item.bidCode === bidCode; - }); - let list = filterList[0].list || [] - let data = []; - if (userName) { - data = list.filter(item => { - return item.userName.indexOf(userName) > -1; - }); - } else { - data = list; - } - initTable(data); - if(data && data.length > 0){ - initEcharts(data[0]); - } -} - // 初始化 echarts -function initEcharts(data) { - if (myChart && myChart2) { - myChart.dispose(); - myChart2.dispose(); - } - myChart = echarts.init(document.getElementById("oneEcharts")); - myChart2 = echarts.init(document.getElementById("twoEcharts")); - initEchartsOne(data); +function initEcharts() { + // 后端查询数据 + const url = commonUrl + "screen/largeScreen/environment/getEnvironmentList?currentDay="+ "2025-07-23" + "&hour=" + "8"+ "&proId=" + "1"; + ajaxRequest(url, "get", null , true, function () { + }, function (result) { + if (result.code === 200) { + console.log(result.data); + initEchartsOne(result.data); + } else if (result.code === 500) { + layer.msg(result.msg, { icon: 2 }); + } + }, function (xhr) { + layer.msg(xhr, { icon: 2 }); + }); + } function initEchartsOne(obj) { - const data = [obj.unitTimeOutput]; - const data2 = [obj.standardTimeOutput]; - const colorArr1 = ["rgba(11, 83, 128)", "rgba(2, 143, 224)", "#2a7fcc"]; - const colorArr2 = ["rgb(12, 109, 122)", "rgba(1, 241, 228)", "#5ce1d6"]; - var color1 = { - type: "linear", - x: 0, - x2: 1, - y: 0, - y2: 0, - colorStops: [ - { - offset: 0, - color: colorArr1[0], - }, - { - offset: 0.5, - color: colorArr1[0], - }, - { - offset: 0.5, - color: colorArr1[1], - }, - { - offset: 1, - color: colorArr1[1], - }, - ], - }; - var color2 = { - type: "linear", - x: 0, - x2: 1, - y: 0, - y2: 0, - colorStops: [ - { - offset: 0, - color: colorArr2[0], - }, - { - offset: 0.5, - color: colorArr2[0], - }, - { - offset: 0.5, - color: colorArr2[1], - }, - { - offset: 1, - color: colorArr2[1], - }, - ], - }; - var barWidth = 18; - const option = { - backgroundColor: 'transparent', - legend: { - top: '3%', - right: '3%', + const dateInput = document.querySelector('input[type="datetime-local"]'); + dateInput.addEventListener('change', function () { + const selectedDate = new Date(this.value); + const formattedDate = selectedDate.toLocaleString('zh-CN', { + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit' + }); + }); + const trendChart = echarts.init(document.getElementById('trendChart')); + const gisChart = echarts.init(document.getElementById('gisChart')); + const spaceChart = echarts.init(document.getElementById('spaceChart')); + const trendOption = { + animation: false, + backgroundColor: 'transparent', textStyle: { - fontSize: '12px', - color: '#FFF', - } - }, - tooltip: { - trigger: 'axis', - formatter: function (params) { - var str = params[0].name + ":"; - params.filter(function (item) { - if (item.componentSubType == "bar") { - str += "
" + item.seriesName + ":" + item.value + obj.unitTimeOutputUnit; + color: '#00C6BE' + }, + tooltip: { + trigger: 'axis' + }, + legend: { + data: ['温度', '湿度', '空气质量', '噪音', '光照度'] + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + xAxis: { + type: 'category', + boundaryGap: false, + data: ['1月14日', '1月15日', '1月16日', '1月17日', '1月18日', '1月19日', '1月20日'] + }, + yAxis: [ + { + type: 'value', + name: '温度/湿度', + }, + { + type: 'value', + name: '其他指标', + splitLine: { + show: false } - }); - return str; - }, - }, - //图表大小位置限制 - grid: { - x: '10%', - x2: '5%', - y: '15%', - y2: '15%', - }, - xAxis: { - data: [obj.userName], - //坐标轴 - axisLine: { - show: true, - lineStyle: { - width: 1, - color: '#214776' + } + ], + series: [ + { + name: '温度', + type: 'line', + smooth: true, + data: [23, 24, 23.5, 22, 23.5, 24.5, 23.5] }, - textStyle: { - color: '#fff', - fontSize: '10' + { + name: '湿度', + type: 'line', + smooth: true, + data: [75, 78, 80, 82, 85, 83, 85] + }, + { + name: '空气质量', + type: 'line', + yAxisIndex: 1, + smooth: true, + data: [65, 70, 75, 72, 68, 73, 75] + }, + { + name: '噪音', + type: 'line', + yAxisIndex: 1, + smooth: true, + data: [60, 62, 65, 63, 61, 64, 65] + }, + { + name: '光照度', + type: 'line', + yAxisIndex: 1, + smooth: true, + data: [1800, 1900, 2000, 1950, 1850, 1950, 2000] + } + ] + }; + const gisOption = { + animation: false, + backgroundColor: 'transparent', + textStyle: { + color: '#00C6BE' + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' } }, - type: 'category', - axisLabel: { - textStyle: { - color: '#C5DFFB', - fontWeight: 500, - fontSize: '14' - } + legend: { + data: ['实时值', '标准值'] }, - axisTick: { - textStyle: { - color: '#fff', - fontSize: '16' - }, - show: false, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true }, - axisLine: { - //坐标轴轴线相关设置。数学上的x轴 - show: true, - lineStyle: { - type: 'dashed',//线的类型 虚线 - color: '#DEDEDE', - }, + xAxis: { + type: 'category', + data: ['温度 (℃)', '湿度 (%)', '粉尘度 (mg/m³)'] }, - }, - yAxis: { - name: '效率对标分析', - nameTextStyle: { - color: '#DEDEDE', - fontSize: 12, - padding: 10, + yAxis: { + type: 'value' }, - min: 0,//最小 - max: obj.max,//最大 - interval: obj.interval,//相差 - type: 'value', - splitLine: { - show: true, - lineStyle: { - type: 'dashed',//线的类型 虚线0 - opacity: 0.2//透明度 - }, - }, - axisTick: { - show: false - }, - axisLine: { - show: false, - }, - //坐标值标注 - axisLabel: { - show: true, - textStyle: { - color: '#C5DFFB', - } - }, - }, - series: [ - { - z: 1, - name: '单位时间产量', - type: "bar", - barWidth: barWidth, - barGap: "0%", - data: data, - itemStyle: { - normal: { - color: color1, + series: [ + { + name: '实时值', + type: 'bar', + barGap: 0, + data: [23.5, 45, 0.08], + itemStyle: { + color: '#2563eb' } }, + { + name: '标准值', + type: 'bar', + data: [25, 50, 0.10], + itemStyle: { + color: '#94a3b8' + } + } + ] + }; + const spaceOption = { + animation: false, + backgroundColor: 'transparent', + textStyle: { + color: '#00C6BE' }, - { - z: 3, - name: '单位时间产量', - type: "pictorialBar", - symbolPosition: "end", - data: data, - symbol: "diamond", - symbolOffset: ["-75%", "-60%"], - symbolSize: [18, 12], - itemStyle: { - normal: { - borderWidth: 2, - color: colorArr1[2] + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + }, + formatter: function (params) { + const units = { + '氧气': '%', + '一氧化碳': 'ppm', + '硫化氢': 'ppm', + '可燃气体': '%LEL' + }; + let result = params[0].axisValueLabel + '
'; + params.forEach(param => { + result += param.marker + param.seriesName + ': ' + param.value + ' ' + units[param.axisValueLabel] + '
'; + }); + return result; + } + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + xAxis: [ + { + type: 'category', + data: ['氧气 (%)', '一氧化碳 (ppm)', '硫化氢 (ppm)', '可燃气体 (%LEL)'], + axisTick: { + alignWithLabel: true }, - }, - }, - { - z: 1, - name: '单位时间标准产量', - type: "bar", - barWidth: barWidth, - barGap: "50%", - data: data2, - itemStyle: { - normal: { - color: color2, + axisLabel: { + interval: 0, + rotate: 15 } - }, - }, - { - z: 3, - name: '单位时间标准产量', - type: "pictorialBar", - symbolPosition: "end", - data: data2, - symbol: "diamond", - symbolOffset: ["75%", "-60%"], - symbolSize: [18, 12], - itemStyle: { - normal: { - borderWidth: 2, - color: colorArr2[2] - }, - }, - tooltip: { - show: false, - }, - }, - ], - } - myChart.setOption(option, true); - window.addEventListener("resize", function () { - myChart.resize(); - }); + } + ], + yAxis: [ + { + type: 'value', + name: '监测值', + } + ], + series: [ + { + name: '监测值', + type: 'bar', + barWidth: '60%', + data: [20.9, 0.5, 0.2, 0.8], + itemStyle: { + color: '#2563eb' + } + } + ] + }; + const lineChartBtn = document.getElementById('lineChartBtn'); + const barChartBtn = document.getElementById('barChartBtn'); + const updateChartType = (type) => { + const newOption = { ...trendOption }; + newOption.series = newOption.series.map(series => ({ + ...series, + type: type + })); + trendChart.setOption(newOption); + }; + lineChartBtn.addEventListener('click', () => { + lineChartBtn.classList.add('bg-primary/10', 'text-primary'); + lineChartBtn.classList.remove('text-gray-600', 'hover:bg-gray-100'); + barChartBtn.classList.remove('bg-primary/10', 'text-primary'); + barChartBtn.classList.add('text-gray-600', 'hover:bg-gray-100'); + updateChartType('line'); + }); + barChartBtn.addEventListener('click', () => { + barChartBtn.classList.add('bg-primary/10', 'text-primary'); + barChartBtn.classList.remove('text-gray-600', 'hover:bg-gray-100'); + lineChartBtn.classList.remove('bg-primary/10', 'text-primary'); + lineChartBtn.classList.add('text-gray-600', 'hover:bg-gray-100'); + updateChartType('bar'); + }); + trendChart.setOption(trendOption); + gisChart.setOption(gisOption); + spaceChart.setOption(spaceOption); + window.addEventListener('resize', function () { + trendChart.resize(); + gisChart.resize(); + spaceChart.resize(); + }); } \ No newline at end of file diff --git a/pages/newDataAnalysis/environDetection.html b/pages/newDataAnalysis/environDetection.html index 4167e0c..5699d73 100644 --- a/pages/newDataAnalysis/environDetection.html +++ b/pages/newDataAnalysis/environDetection.html @@ -1,62 +1,162 @@ - + + 历史环境监测数据 + + + - + + + + + + + + - - - 环境检测 + + - -
-
-