From 5e02fb66c3a5c1b046ccf2abc382553d5318e5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E4=B8=87=E4=BF=8A?= Date: Thu, 25 Dec 2025 18:08:37 +0800 Subject: [PATCH] =?UTF-8?q?feat/=20=E6=B8=A9=E6=B9=BF=E5=BA=A6=E4=BC=A0?= =?UTF-8?q?=E6=84=9F=E5=99=A8=E9=98=88=E5=80=BC=E9=85=8D=E7=BD=AE=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/equipment/environmentMonitoring.vue | 54 ++++- src/views/linkConfig/sensorConfig.vue | 200 +++++++++++++----- 2 files changed, 194 insertions(+), 60 deletions(-) diff --git a/src/views/equipment/environmentMonitoring.vue b/src/views/equipment/environmentMonitoring.vue index 91ef5fb..e9bca4d 100644 --- a/src/views/equipment/environmentMonitoring.vue +++ b/src/views/equipment/environmentMonitoring.vue @@ -148,8 +148,31 @@ export default { // activeTab == 86 的情况 if (tabTypeId == 86 || tabTypeId == 84 || tabTypeId == 81) { - const numValue = Number(value) - return numValue === 0 ? 0 : numValue.toFixed(1) + // 如果 value 是字符串,需要先提取数值部分(可能包含单位) + let numValue + if (typeof value === 'string') { + // 使用正则表达式提取数值部分(包括小数点和负号) + const numMatch = value.match(/^-?[\d.]+/) + if (numMatch) { + numValue = Number(numMatch[0]) + } else { + // 如果无法提取数值,返回原值 + return value + } + } else { + numValue = Number(value) + } + + // 检查是否为有效数字 + if (isNaN(numValue)) { + return value + } + + // 提取单位部分(如果有) + const unit = typeof value === 'string' ? value.replace(/^-?[\d.]+/, '') : '' + + const formattedValue = numValue === 0 ? 0 : numValue.toFixed(1) + return unit ? `${formattedValue}${unit}` : formattedValue } // activeTab == 71 的情况(水库液位) @@ -162,7 +185,16 @@ export default { // 解析每一行:提取 point_name 和 status const colonIndex = line.indexOf(':') if (colonIndex === -1) { - // 如果没有冒号,可能是单个数值 + // 如果没有冒号,可能是单个数值(可能带单位) + // 提取数值部分 + const numMatch = line.match(/^([\d.]+)/) + if (numMatch) { + const numValue = numMatch[1] + const calculatedValue = calculateWaterLevel(numValue) + // 保留单位(如果有) + const unit = line.replace(/^[\d.]+/, '') + return unit ? `${calculatedValue}${unit}` : calculatedValue + } return calculateWaterLevel(line) } const pointName = line.substring(0, colonIndex) @@ -180,7 +212,19 @@ export default { }) return formattedLines.join('\n') } else { - // 单行数据:直接计算 + // 单行数据:可能带单位,需要先提取数值部分 + if (typeof value === 'string') { + // 提取数值部分 + const numMatch = value.match(/^([\d.]+)/) + if (numMatch) { + const numValue = numMatch[1] + const calculatedValue = calculateWaterLevel(numValue) + // 保留单位(如果有) + const unit = value.replace(/^[\d.]+/, '') + return unit ? `${calculatedValue}${unit}` : calculatedValue + } + } + // 如果不是字符串或无法提取数值,直接计算 return calculateWaterLevel(value) } } @@ -439,8 +483,6 @@ export default { tableData: typeGroup.devices })) - console.log(tabs.value, "===> tabs.value"); - // 只在首次加载时设置默认激活的选项卡,轮询时保持当前选项卡状态 if (isFirstLoad && tabs.value.length > 0) { diff --git a/src/views/linkConfig/sensorConfig.vue b/src/views/linkConfig/sensorConfig.vue index b20dacd..f05f77f 100644 --- a/src/views/linkConfig/sensorConfig.vue +++ b/src/views/linkConfig/sensorConfig.vue @@ -3,7 +3,7 @@ @@ -22,60 +22,151 @@ :model="sensor" :rules="thresholdRules" ref="formRefs" - label-width="80px" + :label-width="sensor.model_id == 86 ? '120px' : '80px'" class="threshold-form" > - - - - - - - - - - - - - - - - - + + { // 验证阈值逻辑 // if (sensor.upper_threshold <= sensor.lower_threshold) { - // ElMessage.error("上限阈值必须大于下限阈值"); + // ElMessage.error("阈值必须大于阈值"); // return; // } saving.value = true; @@ -325,4 +416,5 @@ onMounted(() => { ::v-deep .sp-label .el-form-item__label { width: 120px !important; } +