|  | @ -74,10 +74,14 @@ import Echart from '@/components/Echart/src/Echart.vue' | 
		
	
		
			
				|  |  | import { ElMessage } from 'element-plus' |  |  | import { ElMessage } from 'element-plus' | 
		
	
		
			
				|  |  | import dayjs from 'dayjs' |  |  | import dayjs from 'dayjs' | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  | export type tdStruct2 = tdStruct & { | 
		
	
		
			
				|  |  |  |  |  |   timeStr: string | 
		
	
		
			
				|  |  |  |  |  | } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  | const drawer = ref(false) |  |  | const drawer = ref(false) | 
		
	
		
			
				|  |  | const loading = ref(false) |  |  | const loading = ref(false) | 
		
	
		
			
				|  |  | const currentMarker = ref<MarkerData | null>() |  |  | const currentMarker = ref<MarkerData | null>() | 
		
	
		
			
				|  |  | const historicalData = ref<tdStruct[]>([]) |  |  |  | 
		
	
		
			
				|  |  |  |  |  | const historicalData = ref<tdStruct2[]>([]) | 
		
	
		
			
				|  |  | async function getData(row: MarkerData) { |  |  | async function getData(row: MarkerData) { | 
		
	
		
			
				|  |  |   try { |  |  |   try { | 
		
	
		
			
				|  |  |     const data = await tdengineApi.getHistoricalSn({ |  |  |     const data = await tdengineApi.getHistoricalSn({ | 
		
	
	
		
			
				|  | @ -87,13 +91,14 @@ async function getData(row: MarkerData) { | 
		
	
		
			
				|  |  |     }) |  |  |     }) | 
		
	
		
			
				|  |  |     if (!data || data.length === 0) { |  |  |     if (!data || data.length === 0) { | 
		
	
		
			
				|  |  |       ElMessage.error('没有数据') |  |  |       ElMessage.error('没有数据') | 
		
	
		
			
				|  |  |       //  drawer.value =  false |  |  |  | 
		
	
		
			
				|  |  |       return |  |  |  | 
		
	
		
			
				|  |  |  |  |  |       historicalData.value = [] | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  |     historicalData.value = data.map((item) => ({ |  |  |  | 
		
	
		
			
				|  |  |       ...item, |  |  |  | 
		
	
		
			
				|  |  |       ts: dayjs(item.ts).format('YYYY-MM-DD HH:mm:ss') |  |  |  | 
		
	
		
			
				|  |  |     })) |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     historicalData.value = data | 
		
	
		
			
				|  |  |  |  |  |       .sort((a, b) => a.ts - b.ts) | 
		
	
		
			
				|  |  |  |  |  |       .map((item) => ({ | 
		
	
		
			
				|  |  |  |  |  |         ...item, | 
		
	
		
			
				|  |  |  |  |  |         timeStr: dayjs(item.ts).format('YYYY-MM-DD HH:mm:ss') | 
		
	
		
			
				|  |  |  |  |  |       })) | 
		
	
		
			
				|  |  |   } catch (error) { |  |  |   } catch (error) { | 
		
	
		
			
				|  |  |     //   ElMessage.error(error.message) |  |  |     //   ElMessage.error(error.message) | 
		
	
		
			
				|  |  |   } finally { |  |  |   } finally { | 
		
	
	
		
			
				|  | @ -123,68 +128,8 @@ const reset = () => { | 
		
	
		
			
				|  |  |   ] |  |  |   ] | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | // const battery = computed(() => { |  |  |  | 
		
	
		
			
				|  |  | //   let value: number[] = [] |  |  |  | 
		
	
		
			
				|  |  | //   let time: string[] = [] |  |  |  | 
		
	
		
			
				|  |  | //   historicalData.value |  |  |  | 
		
	
		
			
				|  |  | //     .filter((item) => item.battery !== '') |  |  |  | 
		
	
		
			
				|  |  | //     .forEach((item) => { |  |  |  | 
		
	
		
			
				|  |  | //       value.push(Number(item.battery)) |  |  |  | 
		
	
		
			
				|  |  | //       time.push(item.ts as string) |  |  |  | 
		
	
		
			
				|  |  | //     }) |  |  |  | 
		
	
		
			
				|  |  | //   return { |  |  |  | 
		
	
		
			
				|  |  | //     value, |  |  |  | 
		
	
		
			
				|  |  | //     time |  |  |  | 
		
	
		
			
				|  |  | //   } |  |  |  | 
		
	
		
			
				|  |  | // }) |  |  |  | 
		
	
		
			
				|  |  | // const batteryLineOptions = computed<EChartsOption>(() => ({ |  |  |  | 
		
	
		
			
				|  |  | //   title: { |  |  |  | 
		
	
		
			
				|  |  | //     text: '', |  |  |  | 
		
	
		
			
				|  |  | //     left: 'center' |  |  |  | 
		
	
		
			
				|  |  | //   }, |  |  |  | 
		
	
		
			
				|  |  | //   xAxis: { |  |  |  | 
		
	
		
			
				|  |  | //     data: battery.value.time, |  |  |  | 
		
	
		
			
				|  |  | //     boundaryGap: false, |  |  |  | 
		
	
		
			
				|  |  | //     axisTick: { |  |  |  | 
		
	
		
			
				|  |  | //       show: false |  |  |  | 
		
	
		
			
				|  |  | //     } |  |  |  | 
		
	
		
			
				|  |  | //   }, |  |  |  | 
		
	
		
			
				|  |  | //   grid: { |  |  |  | 
		
	
		
			
				|  |  | //     left: 20, |  |  |  | 
		
	
		
			
				|  |  | //     right: 20, |  |  |  | 
		
	
		
			
				|  |  | //     bottom: 20, |  |  |  | 
		
	
		
			
				|  |  | //     top: 10, |  |  |  | 
		
	
		
			
				|  |  | //     containLabel: true |  |  |  | 
		
	
		
			
				|  |  | //   }, |  |  |  | 
		
	
		
			
				|  |  | //   tooltip: { |  |  |  | 
		
	
		
			
				|  |  | //     trigger: 'axis', |  |  |  | 
		
	
		
			
				|  |  | //     axisPointer: { |  |  |  | 
		
	
		
			
				|  |  | //       type: 'cross' |  |  |  | 
		
	
		
			
				|  |  | //     }, |  |  |  | 
		
	
		
			
				|  |  | //     padding: [5, 10] |  |  |  | 
		
	
		
			
				|  |  | //   }, |  |  |  | 
		
	
		
			
				|  |  | //   yAxis: { |  |  |  | 
		
	
		
			
				|  |  | //     axisTick: { |  |  |  | 
		
	
		
			
				|  |  | //       show: false |  |  |  | 
		
	
		
			
				|  |  | //     } |  |  |  | 
		
	
		
			
				|  |  | //   }, |  |  |  | 
		
	
		
			
				|  |  | //   //   legend: { |  |  |  | 
		
	
		
			
				|  |  | //   //     // data: [], |  |  |  | 
		
	
		
			
				|  |  | //   //     top: 50 |  |  |  | 
		
	
		
			
				|  |  | //   //   }, |  |  |  | 
		
	
		
			
				|  |  | //   series: [ |  |  |  | 
		
	
		
			
				|  |  | //     { |  |  |  | 
		
	
		
			
				|  |  | //       name: '电池电压', |  |  |  | 
		
	
		
			
				|  |  | //       smooth: true, |  |  |  | 
		
	
		
			
				|  |  | //       type: 'line', |  |  |  | 
		
	
		
			
				|  |  | //       data: battery.value.value |  |  |  | 
		
	
		
			
				|  |  | //     } |  |  |  | 
		
	
		
			
				|  |  | //   ] |  |  |  | 
		
	
		
			
				|  |  | // })) |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | const gasDateTimeRange = ref(['', '']) |  |  | const gasDateTimeRange = ref(['', '']) | 
		
	
		
			
				|  |  | const handleDateChange = (dates: string[]) => { |  |  |  | 
		
	
		
			
				|  |  |   // gasDateTimeRange.value = dates |  |  |  | 
		
	
		
			
				|  |  |  |  |  | const handleDateChange = () => { | 
		
	
		
			
				|  |  |   if (!currentMarker.value) { |  |  |   if (!currentMarker.value) { | 
		
	
		
			
				|  |  |     return |  |  |     return | 
		
	
		
			
				|  |  |   } |  |  |   } | 
		
	
	
		
			
				|  | @ -209,7 +154,7 @@ const gas = computed(() => { | 
		
	
		
			
				|  |  |         value.push(null) |  |  |         value.push(null) | 
		
	
		
			
				|  |  |       } |  |  |       } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |       time.push(item.ts as string) |  |  |  | 
		
	
		
			
				|  |  |  |  |  |       time.push(item.timeStr) | 
		
	
		
			
				|  |  |     }) |  |  |     }) | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |   return { |  |  |   return { | 
		
	
	
		
			
				|  | @ -218,71 +163,98 @@ const gas = computed(() => { | 
		
	
		
			
				|  |  |     time |  |  |     time | 
		
	
		
			
				|  |  |   } |  |  |   } | 
		
	
		
			
				|  |  | }) |  |  | }) | 
		
	
		
			
				|  |  | const gasLineOptions = computed<EChartsOption>(() => ({ |  |  |  | 
		
	
		
			
				|  |  |   title: { |  |  |  | 
		
	
		
			
				|  |  |     text: '', |  |  |  | 
		
	
		
			
				|  |  |     left: 'center' |  |  |  | 
		
	
		
			
				|  |  |   }, |  |  |  | 
		
	
		
			
				|  |  |   xAxis: { |  |  |  | 
		
	
		
			
				|  |  |     data: gas.value.time, |  |  |  | 
		
	
		
			
				|  |  |     boundaryGap: false, |  |  |  | 
		
	
		
			
				|  |  |     axisTick: { |  |  |  | 
		
	
		
			
				|  |  |       show: false |  |  |  | 
		
	
		
			
				|  |  |     } |  |  |  | 
		
	
		
			
				|  |  |   }, |  |  |  | 
		
	
		
			
				|  |  |   grid: { |  |  |  | 
		
	
		
			
				|  |  |     left: 20, |  |  |  | 
		
	
		
			
				|  |  |     right: 20, |  |  |  | 
		
	
		
			
				|  |  |     bottom: 20, |  |  |  | 
		
	
		
			
				|  |  |     top: 80, |  |  |  | 
		
	
		
			
				|  |  |     containLabel: true |  |  |  | 
		
	
		
			
				|  |  |   }, |  |  |  | 
		
	
		
			
				|  |  |   tooltip: { |  |  |  | 
		
	
		
			
				|  |  |     trigger: 'axis', |  |  |  | 
		
	
		
			
				|  |  |     axisPointer: { |  |  |  | 
		
	
		
			
				|  |  |       type: 'cross' |  |  |  | 
		
	
		
			
				|  |  |  |  |  | const gasLineOptions = computed<EChartsOption>(() => { | 
		
	
		
			
				|  |  |  |  |  |   const option: EChartsOption = { | 
		
	
		
			
				|  |  |  |  |  |     title: { | 
		
	
		
			
				|  |  |  |  |  |       text: '', | 
		
	
		
			
				|  |  |  |  |  |       left: 'center' | 
		
	
		
			
				|  |  |     }, |  |  |     }, | 
		
	
		
			
				|  |  |     padding: [5, 10] |  |  |  | 
		
	
		
			
				|  |  |   }, |  |  |  | 
		
	
		
			
				|  |  |   yAxis: [ |  |  |  | 
		
	
		
			
				|  |  |     { |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     xAxis: { | 
		
	
		
			
				|  |  |  |  |  |       data: gas.value.time, | 
		
	
		
			
				|  |  |  |  |  |       boundaryGap: false, | 
		
	
		
			
				|  |  |       axisTick: { |  |  |       axisTick: { | 
		
	
		
			
				|  |  |         show: false |  |  |         show: false | 
		
	
		
			
				|  |  |       } |  |  |       } | 
		
	
		
			
				|  |  |     }, |  |  |     }, | 
		
	
		
			
				|  |  |     { |  |  |  | 
		
	
		
			
				|  |  |       axisTick: { |  |  |  | 
		
	
		
			
				|  |  |         show: false |  |  |  | 
		
	
		
			
				|  |  |       } |  |  |  | 
		
	
		
			
				|  |  |     } |  |  |  | 
		
	
		
			
				|  |  |   ], |  |  |  | 
		
	
		
			
				|  |  |   legend: { |  |  |  | 
		
	
		
			
				|  |  |     // data: [], |  |  |  | 
		
	
		
			
				|  |  |     top: 50 |  |  |  | 
		
	
		
			
				|  |  |   }, |  |  |  | 
		
	
		
			
				|  |  |   series: [ |  |  |  | 
		
	
		
			
				|  |  |     { |  |  |  | 
		
	
		
			
				|  |  |       name: currentMarker.value?.gasChemical + '浓度', |  |  |  | 
		
	
		
			
				|  |  |       smooth: true, |  |  |  | 
		
	
		
			
				|  |  |       type: 'line', |  |  |  | 
		
	
		
			
				|  |  |       data: gas.value.value, |  |  |  | 
		
	
		
			
				|  |  |       animationDuration: 2800, |  |  |  | 
		
	
		
			
				|  |  |       symbol: 'none', |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |       animationEasing: 'cubicInOut' |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     tooltip: { | 
		
	
		
			
				|  |  |  |  |  |       trigger: 'axis', | 
		
	
		
			
				|  |  |  |  |  |       axisPointer: { | 
		
	
		
			
				|  |  |  |  |  |         type: 'cross' | 
		
	
		
			
				|  |  |  |  |  |       }, | 
		
	
		
			
				|  |  |  |  |  |       padding: [5, 10] | 
		
	
		
			
				|  |  |     }, |  |  |     }, | 
		
	
		
			
				|  |  |     { |  |  |  | 
		
	
		
			
				|  |  |       name: '电池电量', |  |  |  | 
		
	
		
			
				|  |  |       smooth: true, |  |  |  | 
		
	
		
			
				|  |  |       type: 'line', |  |  |  | 
		
	
		
			
				|  |  |       yAxisIndex: 1, |  |  |  | 
		
	
		
			
				|  |  |       symbol: 'none', |  |  |  | 
		
	
		
			
				|  |  |       data: gas.value.battery, |  |  |  | 
		
	
		
			
				|  |  |       animationDuration: 2800, |  |  |  | 
		
	
		
			
				|  |  |       animationEasing: 'cubicInOut' |  |  |  | 
		
	
		
			
				|  |  |     } |  |  |  | 
		
	
		
			
				|  |  |   ] |  |  |  | 
		
	
		
			
				|  |  | })) |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     yAxis: [ | 
		
	
		
			
				|  |  |  |  |  |       { | 
		
	
		
			
				|  |  |  |  |  |         axisTick: { | 
		
	
		
			
				|  |  |  |  |  |           show: false | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  |       }, | 
		
	
		
			
				|  |  |  |  |  |       { | 
		
	
		
			
				|  |  |  |  |  |         axisTick: { | 
		
	
		
			
				|  |  |  |  |  |           show: false | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |  |     ], | 
		
	
		
			
				|  |  |  |  |  |     legend: { | 
		
	
		
			
				|  |  |  |  |  |       // data: [], | 
		
	
		
			
				|  |  |  |  |  |       top: 50 | 
		
	
		
			
				|  |  |  |  |  |     }, | 
		
	
		
			
				|  |  |  |  |  |     series: [ | 
		
	
		
			
				|  |  |  |  |  |       { | 
		
	
		
			
				|  |  |  |  |  |         name: currentMarker.value?.gasChemical + '浓度', | 
		
	
		
			
				|  |  |  |  |  |         smooth: true, | 
		
	
		
			
				|  |  |  |  |  |         type: 'line', | 
		
	
		
			
				|  |  |  |  |  |         data: gas.value.value, | 
		
	
		
			
				|  |  |  |  |  |         animationDuration: 2800, | 
		
	
		
			
				|  |  |  |  |  |         symbol: 'none', | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |         animationEasing: 'cubicInOut' | 
		
	
		
			
				|  |  |  |  |  |       }, | 
		
	
		
			
				|  |  |  |  |  |       { | 
		
	
		
			
				|  |  |  |  |  |         name: '电池电量', | 
		
	
		
			
				|  |  |  |  |  |         smooth: true, | 
		
	
		
			
				|  |  |  |  |  |         type: 'line', | 
		
	
		
			
				|  |  |  |  |  |         yAxisIndex: 1, | 
		
	
		
			
				|  |  |  |  |  |         symbol: 'none', | 
		
	
		
			
				|  |  |  |  |  |         data: gas.value.battery, | 
		
	
		
			
				|  |  |  |  |  |         animationDuration: 2800, | 
		
	
		
			
				|  |  |  |  |  |         animationEasing: 'cubicInOut' | 
		
	
		
			
				|  |  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |  |     ] | 
		
	
		
			
				|  |  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  |  |   const grid = { | 
		
	
		
			
				|  |  |  |  |  |     left: 20, | 
		
	
		
			
				|  |  |  |  |  |     right: 20, | 
		
	
		
			
				|  |  |  |  |  |     bottom: 10, | 
		
	
		
			
				|  |  |  |  |  |     top: 80, | 
		
	
		
			
				|  |  |  |  |  |     containLabel: true | 
		
	
		
			
				|  |  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  |  |   if (gas.value.time.length >= 100) { | 
		
	
		
			
				|  |  |  |  |  |     grid.bottom = 50 | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |     // 缩放 | 
		
	
		
			
				|  |  |  |  |  |     option.dataZoom = [ | 
		
	
		
			
				|  |  |  |  |  |       { | 
		
	
		
			
				|  |  |  |  |  |         type: 'slider', | 
		
	
		
			
				|  |  |  |  |  |         xAxisIndex: [0], | 
		
	
		
			
				|  |  |  |  |  |         bottom: 10, | 
		
	
		
			
				|  |  |  |  |  |         start: 0, | 
		
	
		
			
				|  |  |  |  |  |         end: 100 | 
		
	
		
			
				|  |  |  |  |  |       }, | 
		
	
		
			
				|  |  |  |  |  |       { | 
		
	
		
			
				|  |  |  |  |  |         type: 'inside', | 
		
	
		
			
				|  |  |  |  |  |         xAxisIndex: [0], | 
		
	
		
			
				|  |  |  |  |  |         start: 0, | 
		
	
		
			
				|  |  |  |  |  |         end: 100 | 
		
	
		
			
				|  |  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |  |     ] | 
		
	
		
			
				|  |  |  |  |  |   } else { | 
		
	
		
			
				|  |  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  |  |   option.grid = grid | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |   return option | 
		
	
		
			
				|  |  |  |  |  | }) | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | defineExpose({ |  |  | defineExpose({ | 
		
	
		
			
				|  |  |   openDrawer |  |  |   openDrawer | 
		
	
	
		
			
				|  | 
 |