From 526fac503bae5db262ed12a3e90c81e2bdf3dea6 Mon Sep 17 00:00:00 2001 From: hwj Date: Mon, 26 Jan 2026 10:07:05 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E6=95=B0=E6=8D=AE=E9=87=87?= =?UTF-8?q?=E9=9B=86-=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2-=E9=87=87=E9=9B=86=E6=97=B6=E9=97=B4=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=9C=80=E8=BF=91=E5=9B=9B=E5=B0=8F=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../historyData/HistorySingleDeviceDialog.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/views/iot/historyData/HistorySingleDeviceDialog.vue b/src/views/iot/historyData/HistorySingleDeviceDialog.vue index 7e0e7e3e..5056053e 100644 --- a/src/views/iot/historyData/HistorySingleDeviceDialog.vue +++ b/src/views/iot/historyData/HistorySingleDeviceDialog.vue @@ -103,6 +103,23 @@ const recordGroups = ref([]) const collectionTimeRange = ref([]) +const formatDateTime = (date: Date) => { + const pad = (value: number) => String(value).padStart(2, '0') + const y = date.getFullYear() + const m = pad(date.getMonth() + 1) + const d = pad(date.getDate()) + const h = pad(date.getHours()) + const mi = pad(date.getMinutes()) + const s = pad(date.getSeconds()) + return `${y}-${m}-${d} ${h}:${mi}:${s}` +} + +const buildLastHoursRange = (hours: number) => { + const end = new Date() + const start = new Date(end.getTime() - hours * 60 * 60 * 1000) + return [formatDateTime(start), formatDateTime(end)] +} + const toGroupMap = (value: any): Record => { if (!value || typeof value !== 'object' || Array.isArray(value)) { return {} @@ -206,6 +223,7 @@ watch( if (!visible) { return } + collectionTimeRange.value = buildLastHoursRange(4) fetchHistory() } )