From 92a6031e72852b92c156a9001d88dfed259c128e Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Fri, 13 Feb 2026 10:29:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(aiot):=20=E4=BF=AE=E5=A4=8D=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E5=88=97=E8=A1=A8=E8=87=AA=E5=8A=A8=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=20-=20duration=5Fms=E4=B8=BANULL=E6=97=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题描述: - 前端告警列表对于新触发的告警(duration_ms=null)仍然显示"5分"等具体时长 - 这是因为前端在显示时没有正确处理null值 解决方案: - 修改 formatDuration 函数,显式检查 duration_ms 是否为 null/undefined - 当 duration_ms 为 null 时,返回"进行中"而不是"--" - 简化模板代码,直接调用 formatDuration 函数处理所有情况 影响范围: - 告警列表表格的持续时长列 - 告警详情弹窗的持续时长字段 Co-Authored-By: Claude Opus 4.6 --- .../src/views/aiot/alarm/list/index.vue | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/apps/web-antd/src/views/aiot/alarm/list/index.vue b/apps/web-antd/src/views/aiot/alarm/list/index.vue index 7347eae3b..8636f71cc 100644 --- a/apps/web-antd/src/views/aiot/alarm/list/index.vue +++ b/apps/web-antd/src/views/aiot/alarm/list/index.vue @@ -22,8 +22,10 @@ import { defineOptions({ name: 'AiotAlarmList' }); /** 格式化持续时长(毫秒 → 可读文本) */ -function formatDuration(ms: number): string { - if (!ms || ms <= 0) return '--'; +function formatDuration(ms: number | null | undefined): string { + // 当 duration_ms 为 null 时,说明告警仍在进行中 + if (ms === null || ms === undefined) return '进行中'; + if (ms <= 0) return '--'; if (ms < 60000) { return `${Math.round(ms / 1000)} 秒`; } @@ -218,10 +220,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ @@ -333,11 +332,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
持续时长: - {{ - currentAlert.durationMs != null && currentAlert.durationMs > 0 - ? formatDuration(currentAlert.durationMs) - : '-' - }} + {{ formatDuration(currentAlert.durationMs) }}
触发时间: