|  | @ -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,12 +91,13 @@ 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) => ({ |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     historicalData.value = data | 
		
	
		
			
				|  |  |  |  |  |       .sort((a, b) => a.ts - b.ts) | 
		
	
		
			
				|  |  |  |  |  |       .map((item) => ({ | 
		
	
		
			
				|  |  |         ...item, |  |  |         ...item, | 
		
	
		
			
				|  |  |       ts: dayjs(item.ts).format('YYYY-MM-DD HH:mm:ss') |  |  |  | 
		
	
		
			
				|  |  |  |  |  |         timeStr: dayjs(item.ts).format('YYYY-MM-DD HH:mm:ss') | 
		
	
		
			
				|  |  |       })) |  |  |       })) | 
		
	
		
			
				|  |  |   } catch (error) { |  |  |   } catch (error) { | 
		
	
		
			
				|  |  |     //   ElMessage.error(error.message) |  |  |     //   ElMessage.error(error.message) | 
		
	
	
		
			
				|  | @ -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,7 +163,8 @@ const gas = computed(() => { | 
		
	
		
			
				|  |  |     time |  |  |     time | 
		
	
		
			
				|  |  |   } |  |  |   } | 
		
	
		
			
				|  |  | }) |  |  | }) | 
		
	
		
			
				|  |  | const gasLineOptions = computed<EChartsOption>(() => ({ |  |  |  | 
		
	
		
			
				|  |  |  |  |  | const gasLineOptions = computed<EChartsOption>(() => { | 
		
	
		
			
				|  |  |  |  |  |   const option: EChartsOption = { | 
		
	
		
			
				|  |  |     title: { |  |  |     title: { | 
		
	
		
			
				|  |  |       text: '', |  |  |       text: '', | 
		
	
		
			
				|  |  |       left: 'center' |  |  |       left: 'center' | 
		
	
	
		
			
				|  | @ -230,13 +176,7 @@ const gasLineOptions = computed<EChartsOption>(() => ({ | 
		
	
		
			
				|  |  |         show: false |  |  |         show: false | 
		
	
		
			
				|  |  |       } |  |  |       } | 
		
	
		
			
				|  |  |     }, |  |  |     }, | 
		
	
		
			
				|  |  |   grid: { |  |  |  | 
		
	
		
			
				|  |  |     left: 20, |  |  |  | 
		
	
		
			
				|  |  |     right: 20, |  |  |  | 
		
	
		
			
				|  |  |     bottom: 20, |  |  |  | 
		
	
		
			
				|  |  |     top: 80, |  |  |  | 
		
	
		
			
				|  |  |     containLabel: true |  |  |  | 
		
	
		
			
				|  |  |   }, |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |     tooltip: { |  |  |     tooltip: { | 
		
	
		
			
				|  |  |       trigger: 'axis', |  |  |       trigger: 'axis', | 
		
	
		
			
				|  |  |       axisPointer: { |  |  |       axisPointer: { | 
		
	
	
		
			
				|  | @ -282,7 +222,39 @@ const gasLineOptions = computed<EChartsOption>(() => ({ | 
		
	
		
			
				|  |  |         animationEasing: 'cubicInOut' |  |  |         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 | 
		
	
	
		
			
				|  | 
 |