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 @@