From 5ffeddc8ef67f897c2b1d8133ca754c26330ad67 Mon Sep 17 00:00:00 2001 From: hwj Date: Thu, 22 Jan 2026 17:36:07 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E9=87=87=E9=9B=86=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=A8=A1=E5=9E=8B/=E9=87=87=E9=9B=86=E8=AE=BE?= =?UTF-8?q?=E5=A4=87-=E4=BF=AE=E6=94=B9=E7=82=B9=E4=BD=8D=E8=A7=84?= =?UTF-8?q?=E5=88=99-code=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/iot/device/index.vue | 47 +++++++++++++++++++++++------ src/views/iot/devicemodel/index.vue | 38 +++++++++++++++++++---- 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue index b6efdf8b..92f518b5 100644 --- a/src/views/iot/device/index.vue +++ b/src/views/iot/device/index.vue @@ -733,12 +733,32 @@ const openRuleForm = async (row: DevicePointRuleVO & { pointRulesVOList?: any[] if (list.length) { const first = list[0] as any - ruleForm.fieldRule = (first.rule ?? row.fieldRule) as any - ruleForm.ruleAttributeId = first.id as any + const firstRule = first.rule ?? row.fieldRule + const firstAttrId = (() => { + if (first && first.code != null) { + const target = ruleAttributeOptions.value.find( + (item) => item.attributeCode === first.code + ) + return target?.id + } + if (first && first.id != null) return first.id + return undefined + })() + ruleForm.fieldRule = firstRule as any + ruleForm.ruleAttributeId = firstAttrId as any ruleForm.ruleOperator = first.operator as any ruleForm.ruleValue = first.operatorRule as any extraPointRules.value = list.slice(1).map((item: any) => ({ - id: item.id, + id: (() => { + if (item && item.code != null) { + const target = ruleAttributeOptions.value.find( + (opt) => opt.attributeCode === item.code + ) + return target?.id + } + if (item && item.id != null) return item.id + return undefined + })(), rule: item.rule, operator: item.operator, operatorRule: item.operatorRule, @@ -764,18 +784,25 @@ const handleRuleSubmit = async () => { const pointRulesVOList: any[] = [] if (ruleForm.ruleAttributeId && ruleForm.ruleOperator) { - pointRulesVOList.push({ - id: ruleForm.ruleAttributeId, - rule: ruleForm.fieldRule, - operator: ruleForm.ruleOperator, - operatorRule: ruleForm.ruleValue, - }) + const attr = ruleAttributeOptions.value.find( + (item) => item.id === ruleForm.ruleAttributeId + ) + if (attr && attr.attributeCode) { + pointRulesVOList.push({ + code: attr.attributeCode, + rule: ruleForm.fieldRule, + operator: ruleForm.ruleOperator, + operatorRule: ruleForm.ruleValue, + }) + } } extraPointRules.value.forEach((item) => { if (!item.id || !item.operator) return + const attr = ruleAttributeOptions.value.find((opt) => opt.id === item.id) + if (!attr || !attr.attributeCode) return pointRulesVOList.push({ - id: item.id, + code: attr.attributeCode, rule: item.rule ?? ruleForm.fieldRule, operator: item.operator, operatorRule: item.operatorRule, diff --git a/src/views/iot/devicemodel/index.vue b/src/views/iot/devicemodel/index.vue index 68ded9fe..8f9475f2 100644 --- a/src/views/iot/devicemodel/index.vue +++ b/src/views/iot/devicemodel/index.vue @@ -674,12 +674,32 @@ const openRuleForm = async (row: DeviceModelRuleVO & { pointRulesVOList?: any[] if (list.length) { const first = list[0] as any - ruleForm.fieldRule = (first.rule ?? row.fieldRule) as any - ruleForm.ruleAttributeId = first.id as any + const firstRule = first.rule ?? row.fieldRule + const firstAttrId = (() => { + if (first && first.code != null) { + const target = ruleAttributeOptions.value.find( + (item) => item.attributeCode === first.code + ) + return target?.id + } + if (first && first.id != null) return first.id + return undefined + })() + ruleForm.fieldRule = firstRule as any + ruleForm.ruleAttributeId = firstAttrId as any ruleForm.ruleOperator = first.operator as any ruleForm.ruleValue = first.operatorRule as any extraPointRules.value = list.slice(1).map((item: any) => ({ - id: item.id, + id: (() => { + if (item && item.code != null) { + const target = ruleAttributeOptions.value.find( + (opt) => opt.attributeCode === item.code + ) + return target?.id + } + if (item && item.id != null) return item.id + return undefined + })(), rule: item.rule, operator: item.operator, operatorRule: item.operatorRule, @@ -705,18 +725,25 @@ const handleRuleSubmit = async () => { const pointRulesVOList: any[] = [] if (ruleForm.ruleAttributeId && ruleForm.ruleOperator) { + const attr = ruleAttributeOptions.value.find( + (item) => item.id === ruleForm.ruleAttributeId + ) + if (attr && attr.attributeCode) { pointRulesVOList.push({ - id: ruleForm.ruleAttributeId, + code: attr.attributeCode, rule: ruleForm.fieldRule, operator: ruleForm.ruleOperator, operatorRule: ruleForm.ruleValue, }) + } } extraPointRules.value.forEach((item) => { if (!item.id || !item.operator) return + const attr = ruleAttributeOptions.value.find((opt) => opt.id === item.id) + if (!attr || !attr.attributeCode) return pointRulesVOList.push({ - id: item.id, + code: attr.attributeCode, rule: item.rule ?? ruleForm.fieldRule, operator: item.operator, operatorRule: item.operatorRule, @@ -727,7 +754,6 @@ const handleRuleSubmit = async () => { id: ruleForm.id, identifier: ruleForm.identifier, fieldName: ruleForm.fieldName, - fieldRule: ruleForm.fieldRule, defaultValue: ruleForm.defaultValue, modelId: ruleForm.modelId, pointRulesVOList,