【修复】IoT 场景联动:事件触发器比较值改普通文本输入,允许留空(事件发生即匹配)
parent
418f0c4f52
commit
6232330c81
|
|
@ -128,13 +128,19 @@ const validateTriggers = (_rule: any, value: any, callback: any) => {
|
|||
callback(new Error(`触发器 ${i + 1}: 物模型标识符不能为空`))
|
||||
return
|
||||
}
|
||||
if (!trigger.operator) {
|
||||
callback(new Error(`触发器 ${i + 1}: 操作符不能为空`))
|
||||
return
|
||||
}
|
||||
if (trigger.value === undefined || trigger.value === null || trigger.value === '') {
|
||||
callback(new Error(`触发器 ${i + 1}: 参数值不能为空`))
|
||||
return
|
||||
// 事件上报 / 服务调用:operator 由前端自动设为 '=',参数值留空表示"事件 / 调用发生即匹配"
|
||||
const isEventOrService =
|
||||
trigger.type === IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST ||
|
||||
trigger.type === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE
|
||||
if (!isEventOrService) {
|
||||
if (!trigger.operator) {
|
||||
callback(new Error(`触发器 ${i + 1}: 操作符不能为空`))
|
||||
return
|
||||
}
|
||||
if (trigger.value === undefined || trigger.value === null || trigger.value === '') {
|
||||
callback(new Error(`触发器 ${i + 1}: 参数值不能为空`))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,14 +80,20 @@
|
|||
:config="serviceConfig"
|
||||
placeholder="请输入 JSON 格式的服务参数"
|
||||
/>
|
||||
<!-- 事件上报参数配置 -->
|
||||
<JsonParamsInput
|
||||
v-else-if="triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST"
|
||||
v-model="condition.value"
|
||||
type="event"
|
||||
:config="eventConfig"
|
||||
placeholder="请输入 JSON 格式的事件参数"
|
||||
/>
|
||||
<!-- 事件上报比较值:标量填裸值;结构体/数组填 JSON 整体相等;留空则事件发生即匹配 -->
|
||||
<template v-else-if="triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST">
|
||||
<el-input
|
||||
:model-value="condition.value"
|
||||
@update:model-value="(value) => updateConditionField('value', value)"
|
||||
placeholder="留空则事件发生即匹配"
|
||||
/>
|
||||
<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
|
||||
v-else
|
||||
|
|
@ -276,19 +282,6 @@ const serviceConfig = computed(() => {
|
|||
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 字段名
|
||||
|
|
|
|||
Loading…
Reference in New Issue