From 58db3c7eb4bdbdb102a5b9b3e2df73bda5da0a8c Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Wed, 18 Mar 2026 16:32:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E9=A1=B5=E5=A2=9E=E5=8A=A0=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E7=AD=89=E7=BA=A7=E9=80=89=E6=8B=A9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持在 ROI 算法绑定中配置告警等级(紧急/重要/普通/轻微), 等级保存在 params JSON 中,各算法有默认等级。 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../roi/components/RoiAlgorithmBind.vue | 64 ++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/apps/web-antd/src/views/aiot/device/roi/components/RoiAlgorithmBind.vue b/apps/web-antd/src/views/aiot/device/roi/components/RoiAlgorithmBind.vue index f2d382322..85abb9b9f 100644 --- a/apps/web-antd/src/views/aiot/device/roi/components/RoiAlgorithmBind.vue +++ b/apps/web-antd/src/views/aiot/device/roi/components/RoiAlgorithmBind.vue @@ -22,6 +22,22 @@ import { import AlgorithmParamEditor from './AlgorithmParamEditor.vue'; +/** 告警等级选项 */ +const ALARM_LEVEL_OPTIONS = [ + { value: 0, label: '紧急', color: '#f5222d' }, + { value: 1, label: '重要', color: '#fa8c16' }, + { value: 2, label: '普通', color: '#1677ff' }, + { value: 3, label: '轻微', color: '#8c8c8c' }, +]; + +/** 算法默认告警等级 */ +const DEFAULT_ALARM_LEVELS: Record = { + intrusion: 1, + leave_post: 2, + illegal_parking: 1, + vehicle_congestion: 2, +}; + interface Props { roiId: string; bindings: AiotDeviceApi.RoiAlgoBinding[]; @@ -141,6 +157,35 @@ function getAlgoFrameRate(algoCode: string): string { }; return frameRates[algoCode] || '5帧/秒'; } + +/** 从 params JSON 中读取告警等级 */ +function getAlarmLevel(item: AiotDeviceApi.RoiAlgoBinding): number { + try { + const params = JSON.parse(item.bind.params || '{}'); + if (params.alarm_level !== undefined) return params.alarm_level; + } catch { /* empty */ } + return DEFAULT_ALARM_LEVELS[item.bind.algoCode || ''] ?? 2; +} + +/** 修改告警等级 */ +async function onAlarmLevelChange(item: AiotDeviceApi.RoiAlgoBinding, level: number) { + try { + let params: Record = {}; + try { + params = JSON.parse(item.bind.params || '{}'); + } catch { /* empty */ } + params.alarm_level = level; + await updateAlgoParams({ + bindId: item.bind.bindId!, + params: JSON.stringify(params), + }); + // 更新本地数据 + item.bind.params = JSON.stringify(params); + message.success('告警等级已更新'); + } catch { + message.error('更新告警等级失败'); + } +}