| | |
| | | <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 /> |
| | |
| | | </el-icon> |
| | | 重置 |
| | | </el-button> |
| | | <vue3-json-excel |
| | | class="ml10" |
| | | :json-data="state.tableData.excelData" |
| | | :fields="fields" |
| | | name="气体数据.xls" |
| | | > |
| | | <el-button type="primary" :icon="Download" size="default">导出</el-button> |
| | | </vue3-json-excel> |
| | | </el-form> |
| | | </div> |
| | | <div :id="gasChart" style="height: 500px;width: auto"></div> |
| | |
| | | <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="方位"/> |
| | |
| | | import { gasManageApi } from "/@/api/basicDataManage/gasManage"; |
| | | import moment from "moment"; |
| | | import {gasDataApi} from "/@/api/monitorData/gasData"; |
| | | import {Download} from "@element-plus/icons-vue"; |
| | | |
| | | const state = reactive<TableGasState>({ |
| | | tableData: { |
| | |
| | | } |
| | | }, |
| | | gasList: [], |
| | | isPpm: true, |
| | | positionList: [ |
| | | { |
| | | value: '方位1', |
| | |
| | | value: '方位2', |
| | | label: 2 |
| | | }, |
| | | { |
| | | value: '方位3', |
| | | label: 3 |
| | | }, |
| | | ] |
| | | ], |
| | | excelData: [] |
| | | } |
| | | }); |
| | | const fields = ref({ |
| | | 'time':'dataReceivingTime', |
| | | '设备ID':'equipmentId', |
| | | '位置':'position', |
| | | '经度':'lng', |
| | | '纬度':'lat', |
| | | '角度': 'angle', |
| | | '温度': 'temp', |
| | | '湿度': 'humidity', |
| | | '风速':'windSpeed', |
| | | '风向':'windDirection', |
| | | '气压':'pressure', |
| | | '甲烷CH4':'gasName01', |
| | | 'gasValue01':'gasValue01', |
| | | '乙烷C2H6':'gasName02', |
| | | 'gasValue02':'gasValue02', |
| | | '丙烷C3H8':'gasName03', |
| | | 'gasValue03':'gasValue03', |
| | | '丁烷C4H10':'gasName04', |
| | | 'gasValue04':'gasValue04', |
| | | '硫化氢H2S':'gasName05', |
| | | 'gasValue05':'gasValue05', |
| | | '乙烯C2H4':'gasName06', |
| | | 'gasValue06':'gasValue06', |
| | | '异丁烷C4H10':'gasName07', |
| | | 'gasValue07':'gasValue07', |
| | | }); |
| | | const gasChart = ref("eChartgasN" + Date .now() + Math .random()) |
| | | |
| | |
| | | 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( |
| | |
| | | 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(); |
| | | //折线图 |
| | | const chartParam = { |
| | | startTime: moment(state.tableData.listQuery.searchParams.time[0]).format('YYYY-MM-DD HH:mm:ss'), |
| | |
| | | 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; |
| | | } |
| | |
| | | let res = await gasDataApi().getGasLinePage(pageParam); |
| | | if(res.data.code == 100) { |
| | | state.tableData.data = res.data.data; |
| | | state.tableData.total = res.data.total; |
| | | state.tableData.total = res.data.total == null ? 0 :res.data.total; |
| | | state.tableData.listQuery.pageIndex = res.data.pageIndex; |
| | | state.tableData.listQuery.pageSize = res.data.pageSize; |
| | | loading.value = false; |
| | |
| | | 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; |
| | | initInfoData(); |
| | | await initInfoData(); |
| | | |
| | | }else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | |
| | | }); |
| | | } |
| | | }; |
| | | const exportGasData = async () => { |
| | | const pageParam = { |
| | | startTime: moment(state.tableData.listQuery.searchParams.time[0]).format('YYYY-MM-DD HH:mm:ss'), |
| | | endTime: moment(state.tableData.listQuery.searchParams.time[1]).format('YYYY-MM-DD HH:mm:ss'), |
| | | ch4: state.tableData.listQuery.searchParams.gas == 1 ? 1 : 0, |
| | | c2h6: state.tableData.listQuery.searchParams.gas == 2 ? 1:0, |
| | | c3H8: state.tableData.listQuery.searchParams.gas == 3 ? 1:0, |
| | | c4h101: state.tableData.listQuery.searchParams.gas == 4 ? 1:0, |
| | | h2s: state.tableData.listQuery.searchParams.gas == 5 ? 1:0, |
| | | c2h4: state.tableData.listQuery.searchParams.gas == 6 ? 1:0, |
| | | c4h102: state.tableData.listQuery.searchParams.gas == 7 ? 1:0, |
| | | |
| | | // 发对应的编号,查询数据;null,不查询 |
| | | position1: state.tableData.listQuery.searchParams.position == 1 ? '1':null, |
| | | position2: state.tableData.listQuery.searchParams.position == 2 ? '2':null, |
| | | position3: state.tableData.listQuery.searchParams.position == 3 ? '3':null, |
| | | } |
| | | let res = await gasDataApi().exportGas(pageParam); |
| | | if(res.data.code == 200) { |
| | | state.tableData.excelData = res.data.data |
| | | console.log('excelData',state.tableData.excelData) |
| | | }else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | } |
| | | |
| | | const onHandleSizeChange = (val: number) => { |
| | | state.tableData.listQuery.pageSize = val; |
| | |
| | | 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', |
| | |
| | | }, |
| | | series: [ |
| | | { |
| | | // name : '总计', |
| | | name : '浓度', |
| | | data: yData.value, |
| | | type: 'line', |
| | | markLine: {//图表标线 |
| | |
| | | },],//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: [ |
| | | { |