【修复】IoT 场景联动:事件触发器比较值改普通文本输入,允许留空(事件发生即匹配)

pull/876/head
YunaiV 2026-05-02 14:32:42 +08:00
parent d2e82b710b
commit 192a118823
2 changed files with 27 additions and 28 deletions

View File

@ -128,6 +128,11 @@ const validateTriggers = (_rule: any, value: any, callback: any) => {
callback(new Error(`触发器 ${i + 1}: 物模型标识符不能为空`)) callback(new Error(`触发器 ${i + 1}: 物模型标识符不能为空`))
return return
} }
// / operator '='" / "
const isEventOrService =
trigger.type === IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST ||
trigger.type === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE
if (!isEventOrService) {
if (!trigger.operator) { if (!trigger.operator) {
callback(new Error(`触发器 ${i + 1}: 操作符不能为空`)) callback(new Error(`触发器 ${i + 1}: 操作符不能为空`))
return return
@ -137,6 +142,7 @@ const validateTriggers = (_rule: any, value: any, callback: any) => {
return return
} }
} }
}
// //
if (trigger.type === IotRuleSceneTriggerTypeEnum.TIMER) { if (trigger.type === IotRuleSceneTriggerTypeEnum.TIMER) {

View File

@ -80,14 +80,20 @@
:config="serviceConfig" :config="serviceConfig"
placeholder="请输入 JSON 格式的服务参数" placeholder="请输入 JSON 格式的服务参数"
/> />
<!-- 事件上报参数配置 --> <!-- 事件上报比较值标量填裸值结构体数组填 JSON 整体相等留空则事件发生即匹配 -->
<JsonParamsInput <template v-else-if="triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST">
v-else-if="triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST" <el-input
v-model="condition.value" :model-value="condition.value"
type="event" @update:model-value="(value) => updateConditionField('value', value)"
:config="eventConfig" placeholder="留空则事件发生即匹配"
placeholder="请输入 JSON 格式的事件参数"
/> />
<div class="text-12px text-[var(--el-text-color-secondary)] mt-4px leading-relaxed">
标量事件值填裸值
<code class="px-2px">normal</code>结构体数组事件值填合法
JSON
<code class="px-2px">{"level":"high"}</code>
</div>
</template>
<!-- 普通值输入 --> <!-- 普通值输入 -->
<ValueInput <ValueInput
v-else v-else
@ -276,19 +282,6 @@ const serviceConfig = computed(() => {
return undefined return undefined
}) })
// - JsonParamsInput
const eventConfig = computed(() => {
if (propertyConfig.value && props.triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST) {
return {
event: {
name: propertyConfig.value.name || '事件',
outputParams: propertyConfig.value.outputParams || []
}
}
}
return undefined
})
/** /**
* 更新条件字段 * 更新条件字段
* @param field 字段名 * @param field 字段名