新增单位水头损失属性;新增样式分级属性

This commit is contained in:
JIANG
2025-12-29 10:52:39 +08:00
parent 39450bc6b1
commit 187e8e93b4
2 changed files with 21 additions and 9 deletions

View File

@@ -413,7 +413,7 @@ const Toolbar: React.FC<ToolbarProps> = ({
{ 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<ToolbarProps> = ({
{ 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<ToolbarProps> = ({
// 追加计算属性
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<ToolbarProps> = ({
type: "节点",
properties: [
{
label: "海拔",
label: "高程",
value: properties.elevation?.toFixed?.(1),
unit: "m",
},
@@ -509,7 +519,7 @@ const Toolbar: React.FC<ToolbarProps> = ({
type: "水池",
properties: [
{
label: "海拔",
label: "高程",
value: properties.elevation?.toFixed?.(1),
unit: "m",
},

View File

@@ -294,6 +294,7 @@ const MapComponent: React.FC<MapComponentProps> = ({ 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<MapComponentProps> = ({ 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" },