From c605c4ac8245c975d679678eaa1958f11aab5b6b Mon Sep 17 00:00:00 2001 From: hwj Date: Thu, 15 Jan 2026 11:50:31 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E6=95=B0=E6=8D=AE=E9=87=87?= =?UTF-8?q?=E9=9B=86-=E9=87=87=E9=9B=86=E8=AE=BE=E5=A4=87=E7=82=B9?= =?UTF-8?q?=E4=BD=8D-=E6=96=B0=E5=A2=9E/=E7=BC=96=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=BD=93=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E4=B8=BA=E6=95=B0?= =?UTF-8?q?=E5=80=BC=E6=89=8D=E8=83=BD=E5=A1=AB=E5=80=8D=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/components/DeviceAttributeForm.vue | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/views/iot/device/components/DeviceAttributeForm.vue b/src/views/iot/device/components/DeviceAttributeForm.vue index 3d72a2da..e1fe54fc 100644 --- a/src/views/iot/device/components/DeviceAttributeForm.vue +++ b/src/views/iot/device/components/DeviceAttributeForm.vue @@ -44,7 +44,7 @@ - + @@ -104,6 +104,33 @@ const formData = ref({ deviceId: undefined as number | undefined }) +const ratioEnabledTypes = new Set([ + 'uint8', + 'uint16', + 'uint32', + 'uint64', + 'int8', + 'int16', + 'int32', + 'float32', + 'float64' +]) + +const ratioEnabled = computed(() => { + const v = formData.value.dataType + if (!v) return false + return ratioEnabledTypes.has(v) +}) + +watch( + () => formData.value.dataType, + () => { + if (!ratioEnabled.value) { + formData.value.ratio = undefined + } + } +) + const handleAttributeCodeInput = (val: string) => { formData.value.attributeCode = val?.replace(/[\u4e00-\u9fa5]/g, '') } @@ -190,7 +217,7 @@ const buildSubmitData = () => { dataType, address, dataUnit, - ratio, + ratio: ratioEnabled.value ? ratio : undefined, sort: parsedSort, remark, deviceId