From 1612e3e1b64b9b7d20c7e6d42b67c8472abb7da9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 22 May 2026 20:24:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(iot):=20=E5=9C=BA=E6=99=AF=E8=81=94?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E4=BD=9C=E7=B1=BB=E5=9E=8B=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E6=B8=85=E7=90=86=E9=80=BB=E8=BE=91=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updateActionType 先调 onActionTypeChange(此时 action.type 仍是旧值) 再赋新值,修复 type guard 永远 false 导致切换执行器类型不清空旧 identifier;onActionTypeChange 内恒真的 type !== action.type 简化为 if (action.identifier) --- src/views/iot/rule/scene/form/sections/ActionSection.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/views/iot/rule/scene/form/sections/ActionSection.vue b/src/views/iot/rule/scene/form/sections/ActionSection.vue index 6357afebf..111999364 100644 --- a/src/views/iot/rule/scene/form/sections/ActionSection.vue +++ b/src/views/iot/rule/scene/form/sections/ActionSection.vue @@ -222,8 +222,9 @@ const removeAction = (index: number) => { * @param type 执行器类型 */ const updateActionType = (index: number, type: number) => { - actions.value[index].type = type - onActionTypeChange(actions.value[index], type) + const action = actions.value[index] + onActionTypeChange(action, type) // 须在赋新值前调用 ,内部依赖 action.type 旧值 + action.type = type } /** @@ -258,7 +259,7 @@ const onActionTypeChange = (action: Action, type: number) => { action.params = '' } // 如果从其他类型切换到设备控制类型,清空identifier(让用户重新选择) - if (action.identifier && type !== action.type) { + if (action.identifier) { action.identifier = undefined } } else if (isAlertAction(type)) {