From 7069ff06f3e28c615eba1b42015a4784d996dd05 Mon Sep 17 00:00:00 2001 From: 马宇豪 <978517621@qq.com> Date: 星期四, 08 五月 2025 13:13:16 +0800 Subject: [PATCH] 新修改 --- src/views/monitorData/gasData/index.vue | 159 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 147 insertions(+), 12 deletions(-) diff --git a/src/views/monitorData/gasData/index.vue b/src/views/monitorData/gasData/index.vue index 1baa150..026599f 100644 --- a/src/views/monitorData/gasData/index.vue +++ b/src/views/monitorData/gasData/index.vue @@ -34,7 +34,17 @@ <el-option v-for="item in state.tableData.positionList" :key="item.label" :label="item.value" :value="item.label"></el-option> </el-select> </el-form-item> - + <el-form-item label="单位:"> + <el-switch + v-model="state.tableData.isPpm" + class="ml-2" + inline-prompt + style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" + active-text="ppm" + inactive-text="ppb" + @change="initInfoData" + /> + </el-form-item> <el-button size="default" type="primary" class="ml10" @click="search()"> <el-icon> <ele-Search /> @@ -62,7 +72,11 @@ <el-table-column type="index" label="序号" width="80" /> <el-table-column align="center" prop="time" label="采集时间"/> <el-table-column align="center" prop="windSpeed" label="风速"/> - <el-table-column align="center" prop="windDirection" label="风向"/> + <el-table-column align="center" prop="windDirection" label="风向"> + <template #default="scope"> + {{ getDirection(scope.row.windDirection)+'('+ scope.row.windDirection +'度)' }} + </template> + </el-table-column> <el-table-column align="center" prop="name" label="气体名称"/> <el-table-column align="center" prop="gasValue" label="气体浓度"/> <el-table-column align="center" prop="position" label="方位"/> @@ -113,6 +127,7 @@ } }, gasList: [], + isPpm: true, positionList: [ { value: '方位1', @@ -121,10 +136,6 @@ { value: '方位2', label: 2 - }, - { - value: '方位3', - label: 3 }, ], excelData: [] @@ -181,6 +192,10 @@ const dataZoomEnd = ref(); const xData = ref([]); const yData = ref([]); +const tData = ref([]); +const hData = ref([]); +const wData = ref([]); +const pData = ref([]); const markLines = ref(0); const myChart = shallowRef(null) onMounted( @@ -197,6 +212,16 @@ eTime = `${eTime} ` + moment().format('HH:mm:ss') state.tableData.listQuery.searchParams.time = [sTime,eTime]; } + +const getDirection=(num:number)=>{ + const directionName = ['北', '北东北', '东北', '东东北', '东', '东东南', '东南','南东南','南','南西南','西南','西西南','西','西西北','西北','北西北'] + if(num<=348.75 ){ + return directionName[Math.floor((num + 11.25) / 22.5)] + }else{ + return '北' + } +} + const initInfoData = async () => { await exportGasData(); //折线图 @@ -212,13 +237,27 @@ xData.value = resChart.data.data.map((item: any) => { return item.time; }) - yData.value = resChart.data.data.map((item: any) => { + if(state.tableData.isPpm){ + yData.value = resChart.data.data.map((item: any) => { return item.gasValue; - }) + }) + }else{ + yData.value = resChart.data.data.map((item: any) => { + return item.gasValue * 1000; + }) + } + tData.value = resChart.data.data.map(i=>i.temp?i.temp:0) + hData.value = resChart.data.data.map(i=>i.humidity?i.humidity:0) + wData.value = resChart.data.data.map(i=>i.windSpeed?i.windSpeed:0) + pData.value = resChart.data.data.map(i=>i.pressure?i.pressure:0) dataZoomEnd.value = xData.value.length > 25 ? 30 : 100; }else { xData.value = []; yData.value = []; + tData.value = []; + hData.value = []; + wData.value = []; + pData.value = []; markLines.value = 0; dataZoomEnd.value = 100; } @@ -261,7 +300,6 @@ let res = await gasManageApi().getGas({}); if(res.data.code == 100) { state.tableData.gasList = res.data.data; - console.log("气体",state.tableData.gasList) //默认选择第一个气体 state.tableData.listQuery.searchParams.gas = state.tableData.gasList[0].id; markLines.value = state.tableData.gasList[0].threshold; @@ -347,12 +385,81 @@ type: 'category', data: xData.value }, - yAxis: { + legend: { + data: ['浓度', '温度','湿度','风速','气压'] + }, + yAxis: [ + { + name: '浓度', show: true, type: 'value', max: Math.max(markLines.value,...yData.value), min: Math.min(markLines.value,...yData.value) - }, + }, + { + name: '温度', + type: 'value', + position: 'right', + axisLine:{ + show: true + }, + splitLine: { + show: false + }, + axisLabel:{ + color: '#91CC75', + fontSize: 9 + } + }, + { + name: '湿度', + type: 'value', + offset : 25, + position: 'right', + axisLine:{ + show: true + }, + splitLine: { + show: false + }, + axisLabel:{ + color: '#FAC858', + fontSize: 9 + } + }, + { + name: '风速', + type: 'value', + offset : 50, + position: 'right', + axisLine:{ + show: true + }, + splitLine: { + show: false + }, + axisLabel:{ + color: '#EE6666', + fontSize: 9 + } + }, + { + name: '气压', + type: 'value', + offset : 75, + position: 'right', + axisLine:{ + show: true + }, + splitLine: { + show: false + }, + axisLabel:{ + color: '#73C0DE', + fontSize: 9 + } + } + ], graphic: { type: 'text', // 类型:文本 left: 'center', @@ -369,7 +476,7 @@ }, series: [ { - // name : '总计', + name : '浓度', data: yData.value, type: 'line', markLine: {//图表标线 @@ -388,6 +495,34 @@ },],//type: 'average', 平均值, min最小值, max 最大值, median中位数 }, }, + { + name: '温度', + yAxisIndex: 1, + data: tData.value, + type: 'line', + showSymbol: false, + }, + { + name: '湿度', + yAxisIndex: 2, + data: hData.value, + type: 'line', + showSymbol: false, + }, + { + name: '风速', + yAxisIndex: 3, + data: wData.value, + type: 'line', + showSymbol: false, + }, + { + name: '气压', + yAxisIndex: 4, + data: pData.value, + type: 'line', + showSymbol: false, + } ], dataZoom: [ { -- Gitblit v1.9.2