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" },