From 2b5b05f2795079f16401777cc805f031556b3f5f Mon Sep 17 00:00:00 2001 From: guoapeng Date: Fri, 4 Jul 2025 22:43:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/home/LineChart.vue | 10 +++++----- src/views/home/chart.vue | 37 ++++++++++++++++++++----------------- src/views/home/index.vue | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/components/home/LineChart.vue b/src/components/home/LineChart.vue index 3f8cd8a..73efbb0 100644 --- a/src/components/home/LineChart.vue +++ b/src/components/home/LineChart.vue @@ -42,7 +42,7 @@ watch( xAxis: { type: 'category', boundaryGap: false, - data: newValue.data.map(item => formatDateTime('HH:mm:ss', item.timestamp)), + data: newValue.data?.map(item => formatDateTime('HH:mm:ss', item.timestamp)), }, yAxis: { type: 'value', @@ -51,7 +51,7 @@ watch( { name: '温度', type: 'line', - data: newValue.data.map(item => item.temp.toFixed(2)), + data: newValue.data?.map(item => item.temp.toFixed(2)), symbol: 'circle', symbolSize: 2, lineStyle: { @@ -62,7 +62,7 @@ watch( { name: '湿度', type: 'line', - data: newValue.data.map(item => item.rh.toFixed(2)), + data: newValue.data?.map(item => item.rh.toFixed(2)), symbol: 'circle', symbolSize: 2, lineStyle: { @@ -73,7 +73,7 @@ watch( { name: 'H2O2浓度', type: 'line', - data: newValue.data.map(item => item.h2o2.toFixed(2)), + data: newValue.data?.map(item => item.h2o2.toFixed(2)), symbol: 'circle', symbolSize: 2, lineStyle: { @@ -84,7 +84,7 @@ watch( { name: 'H2O2饱和度', type: 'line', - data: newValue.data.map(item => item.rs.toFixed(2)), + data: newValue.data?.map(item => item.rs.toFixed(2)), symbol: 'circle', symbolSize: 2, lineStyle: { diff --git a/src/views/home/chart.vue b/src/views/home/chart.vue index b9d62ab..3dc9c13 100644 --- a/src/views/home/chart.vue +++ b/src/views/home/chart.vue @@ -27,20 +27,12 @@ const curStateRemainTime = ref(homeStore.curStateRemainTime) const disinfectFormulaVisible = ref(false) const isDeviceIdle = ref(homeStore.isDeviceIdle) const loading = ref(false) -const h2O2SensorData = ref(homeStore.h2O2SensorData) watchEffect(() => { formulaInfo.value = formulaStore.currentSelectedFormulaInfo disinfectionState.value = homeStore.disinfectionState curStateRemainTime.value = homeStore.curStateRemainTime isDeviceIdle.value = homeStore.isDeviceIdle - h2O2SensorData.value = homeStore.h2O2SensorData.map((item, index) => { - return { - ...item, - title: index === 0 ? '仓内' : `探头${index}`, - chartId: index === 0 ? 'inside' : `env${index}`, - } - }) }) const onDisinfectConfig = () => { @@ -72,7 +64,7 @@ const onSave = () => { } const goHome = () => { - router.back() + router.push('/home') } const onClose = () => { disinfectFormulaVisible.value = false @@ -85,15 +77,17 @@ const operationState = computed(() => { let poll = null -const getData = async () => { +const getData = async (type?: string) => { const data = await syncSendCmd({ className: 'H2O2SensorMgr', fnName: 'getH2O2SensorList', }) - chartList.value = data.rely - for (let i = 0; i < chartList.value.length; i++) { - const item: any = chartList.value[i] - const list = await syncSendCmd({ + + const list = data.rely + !type && (chartList.value = list.map(item => ({ ...item, data: [] }))) + for (let i = 0; i < list.length; i++) { + const item: any = list[i] + const res = await syncSendCmd({ className: 'H2O2SensorMgr', fnName: 'getDisinfectionH2O2DataRecordList', params: { @@ -102,18 +96,23 @@ const getData = async () => { interval: 30, }, }) - chartList.value[i].data = list.rely + item.data = res.rely } + chartList.value = list console.log(chartList.value) } + +const chartLoading = ref(false) onMounted(async () => { + chartLoading.value = true await getData() + chartLoading.value = false poll = setInterval(() => { if (operationState.value) { clearInterval(poll) return } - getData() + getData('interval') }, 1000 * 30) }) @@ -145,7 +144,11 @@ onUnmounted(() => { -
+
diff --git a/src/views/home/index.vue b/src/views/home/index.vue index cb7324b..3538f11 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -190,7 +190,7 @@ const deviceType = computed(() => { && homeStore.h2O2SensorData.length === 3, 'card-center-2': index === 0 - && deviceType !== deviceStore.deviceTypeMap.LargeSpaceDM_B + && deviceType === deviceStore.deviceTypeMap.LargeSpaceDM_B && homeStore.h2O2SensorData.length === 5, }" >