【修复】IoT 场景联动:事件触发器比较值改普通文本输入,允许留空(事件发生即匹配)
parent
d2e82b710b
commit
192a118823
|
|
@ -128,13 +128,19 @@ const validateTriggers = (_rule: any, value: any, callback: any) => {
|
||||||
callback(new Error(`触发器 ${i + 1}: 物模型标识符不能为空`))
|
callback(new Error(`触发器 ${i + 1}: 物模型标识符不能为空`))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!trigger.operator) {
|
// 事件上报 / 服务调用:operator 由前端自动设为 '=',参数值留空表示"事件 / 调用发生即匹配"
|
||||||
callback(new Error(`触发器 ${i + 1}: 操作符不能为空`))
|
const isEventOrService =
|
||||||
return
|
trigger.type === IotRuleSceneTriggerTypeEnum.DEVICE_EVENT_POST ||
|
||||||
}
|
trigger.type === IotRuleSceneTriggerTypeEnum.DEVICE_SERVICE_INVOKE
|
||||||
if (trigger.value === undefined || trigger.value === null || trigger.value === '') {
|
if (!isEventOrService) {
|
||||||
callback(new Error(`触发器 ${i + 1}: 参数值不能为空`))
|
if (!trigger.operator) {
|
||||||
return
|
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"
|
: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 字段名
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue