feat(iot): refactor TimerConditionGroupConfig and PropertySelector for improved readability

This commit is contained in:
YunaiV
2026-01-29 19:39:19 +08:00
parent da969d3be7
commit 4c5825389e
2 changed files with 5 additions and 16 deletions

View File

@@ -15,9 +15,7 @@
<span>附加条件组</span> <span>附加条件组</span>
</div> </div>
<el-tag size="small" type="info">定时触发时需满足以下条件</el-tag> <el-tag size="small" type="info">定时触发时需满足以下条件</el-tag>
<el-tag size="small" type="warning"> <el-tag size="small" type="warning"> {{ conditionGroups?.length || 0 }} 个子条件组 </el-tag>
{{ conditionGroups?.length || 0 }} 个子条件组
</el-tag>
</div> </div>
<el-button <el-button
type="primary" type="primary"
@@ -138,12 +136,10 @@ const addConditionGroup = async () => {
if (!conditionGroups.value) { if (!conditionGroups.value) {
conditionGroups.value = [] conditionGroups.value = []
} }
// 检查是否达到最大条件组数量限制 // 检查是否达到最大条件组数量限制
if (conditionGroups.value.length >= maxGroups) { if (conditionGroups.value.length >= maxGroups) {
return return
} }
// 使用 nextTick 确保响应式更新完成后再添加新的条件组 // 使用 nextTick 确保响应式更新完成后再添加新的条件组
await nextTick() await nextTick()
if (conditionGroups.value) { if (conditionGroups.value) {
@@ -151,21 +147,14 @@ const addConditionGroup = async () => {
} }
} }
/** /** 移除条件组 */
* 移除条件组
* @param index 条件组索引
*/
const removeConditionGroup = (index: number) => { const removeConditionGroup = (index: number) => {
if (conditionGroups.value) { if (conditionGroups.value) {
conditionGroups.value.splice(index, 1) conditionGroups.value.splice(index, 1)
} }
} }
/** /** 更新条件组 */
* 更新条件组
* @param index 条件组索引
* @param group 条件组数据
*/
const updateConditionGroup = (index: number, group: TriggerCondition[]) => { const updateConditionGroup = (index: number, group: TriggerCondition[]) => {
if (conditionGroups.value) { if (conditionGroups.value) {
conditionGroups.value[index] = group conditionGroups.value[index] = group

View File

@@ -219,13 +219,13 @@ const thingModelTSL = ref<IotThingModelTSLResp | null>(null) // 物模型TSL数
const propertyGroups = computed(() => { const propertyGroups = computed(() => {
const groups: { label: string; options: any[] }[] = [] const groups: { label: string; options: any[] }[] = []
// 设备属性上报触发器定时触发器(条件组中的设备属性条件) // 设备属性上报触发器定时触发器(条件组中的设备属性条件)
if ( if (
props.triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_PROPERTY_POST || props.triggerType === IotRuleSceneTriggerTypeEnum.DEVICE_PROPERTY_POST ||
props.triggerType === IotRuleSceneTriggerTypeEnum.TIMER props.triggerType === IotRuleSceneTriggerTypeEnum.TIMER
) { ) {
const propertyOptions = propertyList.value.filter( const propertyOptions = propertyList.value.filter(
(p) => p.type === IoTThingModelTypeEnum.PROPERTY (property) => property.type === IoTThingModelTypeEnum.PROPERTY
) )
if (propertyOptions.length > 0) { if (propertyOptions.length > 0) {
groups.push({ groups.push({