From 1edf29abebaae26be78ffd4114681f7b55d3d4b7 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 24 May 2026 21:36:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(iot):=20=E4=BF=AE=E5=A4=8D=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=A8=A1=E6=8B=9F=E5=99=A8=E5=B1=9E=E6=80=A7=E5=80=BC?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 按物模型 dataSpecsList 还原 enum/bool 属性原始值类型 - 保持设备消息筛选和卡片分页与 vue3 + ep 源项目一致 - 更新 IoT bug 状态,归档 B144 并清空剩余 todo --- .../device/detail/modules/simulator.vue | 26 +++++++++++++++++++ .../device/detail/modules/simulator.vue | 26 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/apps/web-antd/src/views/iot/device/device/detail/modules/simulator.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/simulator.vue index eefd303f8..ebfa9087c 100644 --- a/apps/web-antd/src/views/iot/device/device/detail/modules/simulator.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/simulator.vue @@ -235,14 +235,40 @@ function getPropertyOptions(row: ThingModelApi.ThingModel) { return []; } +/** 获取物模型选项原始值 */ +function getMatchedPropertyOption(row: ThingModelApi.ThingModel, value: any) { + return row.property?.dataSpecsList?.find( + (item: any) => String(item.value) === String(value), + ); +} + /** 按物模型数据类型转换属性值 */ function normalizePropertyValue(row: ThingModelApi.ThingModel, value: any) { if (value === undefined || value === null || value === '') { return undefined; } + const dataType = getPropertyDataType(row); if (isNumberProperty(row)) { return Number(value); } + if ( + [IoTDataSpecsDataTypeEnum.BOOL, IoTDataSpecsDataTypeEnum.ENUM].includes( + dataType as any, + ) + ) { + const option = getMatchedPropertyOption(row, value); + if (option) { + return option.value; + } + } + if (dataType === IoTDataSpecsDataTypeEnum.BOOL) { + if (String(value) === 'true') { + return true; + } + if (String(value) === 'false') { + return false; + } + } return value; } diff --git a/apps/web-ele/src/views/iot/device/device/detail/modules/simulator.vue b/apps/web-ele/src/views/iot/device/device/detail/modules/simulator.vue index efb06af9a..b94f4d545 100644 --- a/apps/web-ele/src/views/iot/device/device/detail/modules/simulator.vue +++ b/apps/web-ele/src/views/iot/device/device/detail/modules/simulator.vue @@ -128,14 +128,40 @@ function getPropertyOptions(row: ThingModelApi.ThingModel) { return []; } +/** 获取物模型选项原始值 */ +function getMatchedPropertyOption(row: ThingModelApi.ThingModel, value: any) { + return row.property?.dataSpecsList?.find( + (item: any) => String(item.value) === String(value), + ); +} + /** 按物模型数据类型转换属性值 */ function normalizePropertyValue(row: ThingModelApi.ThingModel, value: any) { if (value === undefined || value === null || value === '') { return undefined; } + const dataType = getPropertyDataType(row); if (isNumberProperty(row)) { return Number(value); } + if ( + [IoTDataSpecsDataTypeEnum.BOOL, IoTDataSpecsDataTypeEnum.ENUM].includes( + dataType as any, + ) + ) { + const option = getMatchedPropertyOption(row, value); + if (option) { + return option.value; + } + } + if (dataType === IoTDataSpecsDataTypeEnum.BOOL) { + if (String(value) === 'true') { + return true; + } + if (String(value) === 'false') { + return false; + } + } return value; }