From 6bfd888b548ce5ffcc1d927f9486e372b69b8590 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Thu, 14 Aug 2025 18:21:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90IoT=20=E7=89=A9=E8=81=94?= =?UTF-8?q?=E7=BD=91=E3=80=91=E5=9C=BA=E6=99=AF=E8=81=94=E5=8A=A8=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BA=A7=E5=93=81=E5=88=87=E6=8D=A2=E6=97=B6=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E9=A1=B9=E6=B2=A1=E8=A7=A6=E5=8F=91=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/configs/MainConditionInnerConfig.vue | 9 -- .../scene/form/selectors/OperatorSelector.vue | 14 ++- .../scene/form/selectors/PropertySelector.vue | 110 +++++++++--------- 3 files changed, 63 insertions(+), 70 deletions(-) diff --git a/src/views/iot/rule/scene/form/configs/MainConditionInnerConfig.vue b/src/views/iot/rule/scene/form/configs/MainConditionInnerConfig.vue index f6eb65f90..0b7c8f4a2 100644 --- a/src/views/iot/rule/scene/form/configs/MainConditionInnerConfig.vue +++ b/src/views/iot/rule/scene/form/configs/MainConditionInnerConfig.vue @@ -65,7 +65,6 @@ :model-value="condition.operator" @update:model-value="(value) => updateConditionField('operator', value)" :property-type="propertyType" - @change="handleOperatorChange" /> @@ -326,12 +325,4 @@ const handlePropertyChange = (propertyInfo: any) => { } } } - -// TODO @puhui999:这个貌似没用上 -/** - * 处理操作符变化事件 - */ -const handleOperatorChange = () => { - // 操作符变化处理 -} diff --git a/src/views/iot/rule/scene/form/selectors/OperatorSelector.vue b/src/views/iot/rule/scene/form/selectors/OperatorSelector.vue index 0b70c5247..df98de664 100644 --- a/src/views/iot/rule/scene/form/selectors/OperatorSelector.vue +++ b/src/views/iot/rule/scene/form/selectors/OperatorSelector.vue @@ -222,7 +222,9 @@ const availableOperators = computed(() => { if (!props.propertyType) { return allOperators } - return allOperators.filter((op) => op.supportedTypes.includes(props.propertyType!)) + return allOperators.filter((op) => + (op.supportedTypes as any[]).includes(props.propertyType || '') + ) }) // 计算属性:当前选中的操作符 @@ -243,10 +245,12 @@ watch( () => props.propertyType, () => { // 如果当前选择的操作符不支持新的属性类型,则清空选择 - if (localValue.value && selectedOperator.value) { - if (!selectedOperator.value.supportedTypes.includes(props.propertyType || '')) { - localValue.value = '' - } + if ( + localValue.value && + selectedOperator.value && + !(selectedOperator.value.supportedTypes as any[]).includes(props.propertyType || '') + ) { + localValue.value = '' } } ) diff --git a/src/views/iot/rule/scene/form/selectors/PropertySelector.vue b/src/views/iot/rule/scene/form/selectors/PropertySelector.vue index 99f05a63f..51f2117a6 100644 --- a/src/views/iot/rule/scene/form/selectors/PropertySelector.vue +++ b/src/views/iot/rule/scene/form/selectors/PropertySelector.vue @@ -262,7 +262,6 @@ const handleChange = (value: string) => { } } -// TODO @puhui999:这里没用到哈; /** * 获取物模型TSL数据 */ @@ -297,62 +296,62 @@ const parseThingModelData = () => { const tsl = thingModelTSL.value const properties: PropertySelectorItem[] = [] - // TODO @puhui999:if return,减少下括号层级; - if (tsl) { - // 解析属性 - if (tsl.properties && Array.isArray(tsl.properties)) { - tsl.properties.forEach((prop) => { - properties.push({ - identifier: prop.identifier, - name: prop.name, - description: prop.description, - dataType: prop.dataType, - type: IoTThingModelTypeEnum.PROPERTY, - accessMode: prop.accessMode, - required: prop.required, - unit: getPropertyUnit(prop), - range: getPropertyRange(prop), - property: prop - }) + if (!tsl) { + propertyList.value = properties + return + } + // 解析属性 + if (tsl.properties && Array.isArray(tsl.properties)) { + tsl.properties.forEach((prop) => { + properties.push({ + identifier: prop.identifier, + name: prop.name, + description: prop.description, + dataType: prop.dataType, + type: IoTThingModelTypeEnum.PROPERTY, + accessMode: prop.accessMode, + required: prop.required, + unit: getPropertyUnit(prop), + range: getPropertyRange(prop), + property: prop }) - } - - // 解析事件 - if (tsl.events && Array.isArray(tsl.events)) { - tsl.events.forEach((event) => { - properties.push({ - identifier: event.identifier, - name: event.name, - description: event.description, - dataType: 'struct', - type: IoTThingModelTypeEnum.EVENT, - eventType: event.type, - required: event.required, - outputParams: event.outputParams, - event: event - }) - }) - } - - // 解析服务 - if (tsl.services && Array.isArray(tsl.services)) { - tsl.services.forEach((service) => { - properties.push({ - identifier: service.identifier, - name: service.name, - description: service.description, - dataType: 'struct', - type: IoTThingModelTypeEnum.SERVICE, - callType: service.callType, - required: service.required, - inputParams: service.inputParams, - outputParams: service.outputParams, - service: service - }) - }) - } + }) } + // 解析事件 + if (tsl.events && Array.isArray(tsl.events)) { + tsl.events.forEach((event) => { + properties.push({ + identifier: event.identifier, + name: event.name, + description: event.description, + dataType: 'struct', + type: IoTThingModelTypeEnum.EVENT, + eventType: event.type, + required: event.required, + outputParams: event.outputParams, + event: event + }) + }) + } + + // 解析服务 + if (tsl.services && Array.isArray(tsl.services)) { + tsl.services.forEach((service) => { + properties.push({ + identifier: service.identifier, + name: service.name, + description: service.description, + dataType: 'struct', + type: IoTThingModelTypeEnum.SERVICE, + callType: service.callType, + required: service.required, + inputParams: service.inputParams, + outputParams: service.outputParams, + service: service + }) + }) + } propertyList.value = properties } @@ -396,7 +395,7 @@ const getPropertyRange = (property: any) => { return undefined } -/** 监听产品变化 *、 +/** 监听产品变化 */ watch( () => props.productId, () => { @@ -410,7 +409,6 @@ watch( () => props.triggerType, () => { localValue.value = '' - // el-popover 会自动关闭,无需手动处理 } )