diff --git a/ui/dasadmin/src/views/backend/equipment/equipmentManagement/measurement.vue b/ui/dasadmin/src/views/backend/equipment/equipmentManagement/measurement.vue index 551ca205..ea0bcd0e 100644 --- a/ui/dasadmin/src/views/backend/equipment/equipmentManagement/measurement.vue +++ b/ui/dasadmin/src/views/backend/equipment/equipmentManagement/measurement.vue @@ -41,12 +41,12 @@ - +
- + @@ -267,26 +267,12 @@ const getcurrentPage = () => { const openLineChart = (data: any) => { lineChartVisible.value = true + loading.value = false searchInfo.attr = data.attributeCode searchInfo.name = data.attributeName searchInfo.unit = data.unit } -watch( - () => props.show, - (newVal) => { - if (newVal) { - getCompleteData() - loading.value = false - } else { - autoUpdateTimer.value && clearInterval(autoUpdateTimer.value) - autoUpdateTimer.value = null - } - }, - { - immediate: true, - } -) const autoUpdateTimer: any = ref(null) watch( () => props.autoUpdate, @@ -343,29 +329,31 @@ const getChartData = () => { if (valid) { loading.value = true getRealValueRangeReq({ - startTime: dayjs(seachOptions.datePickerValue[0]).valueOf(), - endTime: dayjs(seachOptions.datePickerValue[1]).valueOf(), + startTime: dayjs(searchOptions.datePickerValue[0]).valueOf(), + endTime: dayjs(searchOptions.datePickerValue[1]).valueOf(), devices: [ { deviceId: props.deviceId, attributes: [searchInfo.attr], }, ], - interval: seachOptions.interval, - }).then((res) => { - initChart(res.data?.[props.deviceId]?.[searchInfo.attr]) - }).catch(()=>{ - ElMessage.error('获取数据失败') - loading.value = false + interval: searchOptions.interval, }) + .then((res) => { + initChart(res.data?.[props.deviceId]?.[searchInfo.attr]) + }) + .catch(() => { + ElMessage.error('获取数据失败') + loading.value = false + }) } }) } const chartRef = ref() let chartInstance: any = null -const seachOptions = reactive({ - datePickerValue: [0, 0], +const searchOptions = reactive<{ datePickerValue: Date[]; interval: string }>({ + datePickerValue: [], interval: '5m', }) @@ -485,7 +473,7 @@ const initChart = (data: { values: number[]; times: number[] }) => { }, smooth: 0.6, symbol: 'none', - data: data?.values ?? [] + data: data?.values ?? [], }, ], } @@ -504,6 +492,22 @@ watch( getCompleteData() } ) + +watch( + () => props.show, + (newVal) => { + if (newVal) { + getCompleteData() + searchOptions.datePickerValue = shortcuts[0].value() + } else { + autoUpdateTimer.value && clearInterval(autoUpdateTimer.value) + autoUpdateTimer.value = null + } + }, + { + immediate: true, + } +)