diff --git a/src/views/iot/rule/scene/form/configs/DeviceControlConfig.vue b/src/views/iot/rule/scene/form/configs/DeviceControlConfig.vue index e1f5068ce..2d9c5f9ed 100644 --- a/src/views/iot/rule/scene/form/configs/DeviceControlConfig.vue +++ b/src/views/iot/rule/scene/form/configs/DeviceControlConfig.vue @@ -53,8 +53,8 @@ @@ -68,7 +68,7 @@ v-model="paramsValue" type="property" :config="{ properties: thingModelProperties }" - placeholder="请输入JSON格式的控制参数" + placeholder="请输入 JSON 格式的控制参数" /> diff --git a/src/views/iot/rule/scene/form/configs/MainConditionInnerConfig.vue b/src/views/iot/rule/scene/form/configs/MainConditionInnerConfig.vue index 757572f62..062507a84 100644 --- a/src/views/iot/rule/scene/form/configs/MainConditionInnerConfig.vue +++ b/src/views/iot/rule/scene/form/configs/MainConditionInnerConfig.vue @@ -59,13 +59,7 @@ - + - - - + + - - - - + + + + + + + + { return props.triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_STATE_UPDATE }) +// 计算属性:是否需要操作符选择(服务调用和事件上报不需要操作符) +const needsOperatorSelector = computed(() => { + const noOperatorTriggerTypes = [ + IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE, + IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST + ] as number[] + return !noOperatorTriggerTypes.includes(props.triggerType) +}) + +// 计算属性:是否需要宽列布局(服务调用和事件上报不需要操作符列,所以值输入列更宽) +const isWideValueColumn = computed(() => { + const wideColumnTriggerTypes = [ + IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE, + IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST + ] as number[] + return wideColumnTriggerTypes.includes(props.triggerType) +}) + +// 计算属性:值输入字段的标签文本 +const valueInputLabel = computed(() => { + return props.triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE + ? '服务参数' + : '比较值' +}) + // 计算属性:服务配置 - 用于 JsonParamsInput const serviceConfig = computed(() => { if ( @@ -261,9 +278,6 @@ const eventConfig = computed(() => { return undefined }) -const triggerTypeOptions = getTriggerTypeOptions() // 触发器类型选项 -const deviceStatusChangeOptions = getDeviceStatusChangeOptions() // 设备状态变化选项 - /** * 更新条件字段 * @param field 字段名 @@ -312,7 +326,7 @@ const handlePropertyChange = (propertyInfo: any) => { props.triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST || props.triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE ) { - condition.value.operator = '=' + condition.value.operator = IotRuleSceneTriggerConditionParameterOperatorEnum.EQUALS.value } } } diff --git a/src/views/iot/rule/scene/form/inputs/ValueInput.vue b/src/views/iot/rule/scene/form/inputs/ValueInput.vue index 27c067a0d..908141b30 100644 --- a/src/views/iot/rule/scene/form/inputs/ValueInput.vue +++ b/src/views/iot/rule/scene/form/inputs/ValueInput.vue @@ -196,7 +196,7 @@ const isNumericType = () => { IoTDataSpecsDataTypeEnum.INT, IoTDataSpecsDataTypeEnum.FLOAT, IoTDataSpecsDataTypeEnum.DOUBLE - ].includes(props.propertyType || '') + ].includes((props.propertyType || '') as any) } /** @@ -224,7 +224,7 @@ const getPlaceholder = () => { [IoTDataSpecsDataTypeEnum.INT]: '请输入整数', [IoTDataSpecsDataTypeEnum.FLOAT]: '请输入浮点数', [IoTDataSpecsDataTypeEnum.DOUBLE]: '请输入双精度数', - [IoTDataSpecsDataTypeEnum.STRUCT]: '请输入JSON格式数据', + [IoTDataSpecsDataTypeEnum.STRUCT]: '请输入 JSON 格式数据', [IoTDataSpecsDataTypeEnum.ARRAY]: '请输入数组格式数据' } return typeMap[props.propertyType || ''] || '请输入值' diff --git a/src/views/iot/utils/constants.ts b/src/views/iot/utils/constants.ts index 1fb434ae2..05871a047 100644 --- a/src/views/iot/utils/constants.ts +++ b/src/views/iot/utils/constants.ts @@ -267,7 +267,7 @@ export const IotRuleSceneTriggerTypeEnum = { } as const /** 触发器类型选项配置 */ -export const getTriggerTypeOptions = () => [ +export const triggerTypeOptions = [ { value: IotRuleSceneTriggerTypeEnum.DEVICE_STATE_UPDATE, label: '设备状态变更' @@ -492,13 +492,13 @@ export const getStatusOperatorOptions = () => [ ] /** 获取设备状态变更选项(用于触发器配置) */ -export const getDeviceStatusChangeOptions = () => [ +export const deviceStatusChangeOptions = [ { - label: '变为在线', + label: IoTDeviceStatusEnum.ONLINE.label, value: IoTDeviceStatusEnum.ONLINE.value }, { - label: '变为离线', + label: IoTDeviceStatusEnum.OFFLINE.label, value: IoTDeviceStatusEnum.OFFLINE.value } ] @@ -545,8 +545,7 @@ export const IotRuleSceneTriggerTimeOperatorEnum = { /** 获取触发器类型标签 */ export const getTriggerTypeLabel = (type: number): string => { - const options = getTriggerTypeOptions() - const option = options.find((item) => item.value === type) + const option = triggerTypeOptions.find((item) => item.value === type) return option?.label || '未知类型' }