From 187e8e93b4975e7ae7c9701b32bf6ce2aa4a096b Mon Sep 17 00:00:00 2001 From: JIANG Date: Mon, 29 Dec 2025 10:52:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E4=BD=8D=E6=B0=B4?= =?UTF-8?q?=E5=A4=B4=E6=8D=9F=E5=A4=B1=E5=B1=9E=E6=80=A7=EF=BC=9B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=A0=B7=E5=BC=8F=E5=88=86=E7=BA=A7=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/OlMap/Controls/Toolbar.tsx | 26 ++++++++++++++++++-------- src/app/OlMap/MapComponent.tsx | 4 +++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/app/OlMap/Controls/Toolbar.tsx b/src/app/OlMap/Controls/Toolbar.tsx index 0a16dfb..86b598a 100644 --- a/src/app/OlMap/Controls/Toolbar.tsx +++ b/src/app/OlMap/Controls/Toolbar.tsx @@ -413,7 +413,7 @@ const Toolbar: React.FC = ({ { key: "flow", label: "流量", unit: "m³/h" }, { key: "friction", label: "摩阻", unit: "" }, { key: "headloss", label: "水头损失", unit: "m" }, - { key: "headlossPerKM", label: "单位水头损失", unit: "m/km" }, + { key: "unit_headloss", label: "单位水头损失", unit: "m/km" }, { key: "quality", label: "水质", unit: "mg/L" }, { key: "reaction", label: "反应", unit: "1/d" }, { key: "setting", label: "设置", unit: "" }, @@ -421,8 +421,8 @@ const Toolbar: React.FC = ({ { key: "velocity", label: "流速", unit: "m/s" }, ]; const nodeComputedFields = [ - { key: "actualdemand", label: "实际需水量", unit: "m³/h" }, - { key: "head", label: "水头", unit: "m" }, + { key: "actual_demand", label: "实际需水量", unit: "m³/h" }, + { key: "total_head", label: "水头", unit: "m" }, { key: "pressure", label: "压力", unit: "m" }, { key: "quality", label: "水质", unit: "mg/L" }, ]; @@ -448,11 +448,21 @@ const Toolbar: React.FC = ({ // 追加计算属性 if (computedProperties) { pipeComputedFields.forEach(({ key, label, unit }) => { - if (computedProperties[key] !== undefined) { + let value = computedProperties[key]; + // 如果是单位水头损失且后端未返回,则通过水头损失/长度计算 (单位 m/km) + if ( + key === "unit_headloss" && + value === undefined && + computedProperties.headloss !== undefined && + properties.length + ) { + value = (computedProperties.headloss / properties.length) * 1000; + } + + if (value !== undefined) { result.properties.push({ label, - value: - computedProperties[key].toFixed?.(3) || computedProperties[key], + value: typeof value === "number" ? value.toFixed(3) : value, unit, }); } @@ -466,7 +476,7 @@ const Toolbar: React.FC = ({ type: "节点", properties: [ { - label: "海拔", + label: "高程", value: properties.elevation?.toFixed?.(1), unit: "m", }, @@ -509,7 +519,7 @@ const Toolbar: React.FC = ({ type: "水池", properties: [ { - label: "海拔", + label: "高程", value: properties.elevation?.toFixed?.(1), unit: "m", }, diff --git a/src/app/OlMap/MapComponent.tsx b/src/app/OlMap/MapComponent.tsx index 1720ddb..fdd2fc3 100644 --- a/src/app/OlMap/MapComponent.tsx +++ b/src/app/OlMap/MapComponent.tsx @@ -294,6 +294,7 @@ const MapComponent: React.FC = ({ children }) => { properties: [ // { name: "需求量", value: "demand" }, { name: "高程", value: "elevation" }, + // 计算属性 { name: "实际需求量", value: "actualdemand" }, { name: "水头", value: "head" }, { name: "压力", value: "pressure" }, @@ -315,10 +316,11 @@ const MapComponent: React.FC = ({ children }) => { { name: "管径", value: "diameter" }, // { name: "粗糙度", value: "roughness" }, // { name: "局部损失", value: "minor_loss" }, + // 计算属性 { name: "流量", value: "flow" }, { name: "摩阻系数", value: "friction" }, { name: "水头损失", value: "headloss" }, - { name: "单位水头损失", value: "headlossPerKM" }, + { name: "单位水头损失", value: "unit_headloss" }, { name: "水质", value: "quality" }, { name: "反应速率", value: "reaction" }, { name: "设置值", value: "setting" },