From 18758628f19bb5f5e43afdc4ba70699a5f4aeb04 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 1 Jul 2025 21:04:40 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90IoT=20=E7=89=A9=E8=81=94?= =?UTF-8?q?=E7=BD=91=E3=80=91=E5=9C=BA=E6=99=AF=E8=81=94=E5=8A=A8=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=99=A8=E4=BC=98=E5=8C=96=E5=AF=B9=E9=BD=90=E5=90=8E?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/action/ActionExecutor.vue | 51 ++++++++++++------- .../scene/components/action/AlertAction.vue | 21 +++++++- .../components/action/DeviceControlAction.vue | 46 ++++++++++++++--- 3 files changed, 90 insertions(+), 28 deletions(-) diff --git a/src/views/iot/rule/scene/components/action/ActionExecutor.vue b/src/views/iot/rule/scene/components/action/ActionExecutor.vue index a3644c49c..e3b26a833 100644 --- a/src/views/iot/rule/scene/components/action/ActionExecutor.vue +++ b/src/views/iot/rule/scene/components/action/ActionExecutor.vue @@ -19,19 +19,13 @@ /> -
+
产品 {{ product ? product.name : '选择产品' }}
-
+
设备 {{ isEmpty(deviceList) ? '选择设备' : deviceList.map((d) => d.deviceName).join(',') }} @@ -47,7 +41,8 @@ @@ -101,28 +97,47 @@ const actionConfig = useVModel(props, 'modelValue', emits) as Ref const message = useMessage() +/** 计算属性:判断是否为设备相关执行类型 */ +const isDeviceAction = computed(() => { + return [ + IotRuleSceneActionTypeEnum.DEVICE_PROPERTY_SET, + IotRuleSceneActionTypeEnum.DEVICE_SERVICE_INVOKE + ].includes(actionConfig.value.type as any) +}) + +/** 计算属性:判断是否为告警相关执行类型 */ +const isAlertAction = computed(() => { + return [ + IotRuleSceneActionTypeEnum.ALERT_TRIGGER, + IotRuleSceneActionTypeEnum.ALERT_RECOVER + ].includes(actionConfig.value.type as any) +}) + /** 初始化执行器结构 */ const initActionConfig = () => { if (!actionConfig.value) { - actionConfig.value = { type: IotRuleSceneActionTypeEnum.DEVICE_CONTROL } as ActionConfig + actionConfig.value = { type: IotRuleSceneActionTypeEnum.DEVICE_PROPERTY_SET } as ActionConfig } // 设备控制执行器初始化 - if ( - actionConfig.value.type === IotRuleSceneActionTypeEnum.DEVICE_CONTROL && - !actionConfig.value.deviceControl - ) { + if (isDeviceAction.value && !actionConfig.value.deviceControl) { actionConfig.value.deviceControl = { productKey: '', deviceNames: [], - type: IotDeviceMessageTypeEnum.PROPERTY, - identifier: IotDeviceMessageIdentifierEnum.PROPERTY_SET, + type: + actionConfig.value.type === IotRuleSceneActionTypeEnum.DEVICE_PROPERTY_SET + ? IotDeviceMessageTypeEnum.PROPERTY + : IotDeviceMessageTypeEnum.SERVICE, + identifier: + actionConfig.value.type === IotRuleSceneActionTypeEnum.DEVICE_PROPERTY_SET + ? IotDeviceMessageIdentifierEnum.PROPERTY_SET + : IotDeviceMessageIdentifierEnum.SERVICE_INVOKE, data: {} } as ActionDeviceControl } // 告警执行器初始化 - if (actionConfig.value.type === IotRuleSceneActionTypeEnum.ALERT && !actionConfig.value.alert) { + if (isAlertAction.value && !actionConfig.value.alert) { actionConfig.value.alert = {} as ActionAlert } } diff --git a/src/views/iot/rule/scene/components/action/AlertAction.vue b/src/views/iot/rule/scene/components/action/AlertAction.vue index d2fa7e454..ff964dc4c 100644 --- a/src/views/iot/rule/scene/components/action/AlertAction.vue +++ b/src/views/iot/rule/scene/components/action/AlertAction.vue @@ -1,5 +1,15 @@