feat: 方案对比结果表格新增总长度列

- 在方案对比结果中新增'总长度(m)'列
- 自动计算每个方案的海缆总长度
- 支持按总长度排序,方便方案比选
This commit is contained in:
dmy
2026-01-06 11:25:43 +08:00
parent 60a9a57cee
commit 86e0e21b58

13
gui.py
View File

@@ -798,10 +798,14 @@ def index():
elif "No Max" in original_name:
note += "不包含可选电缆型号,且可使用的最大截面电缆降一档截面。"
# 计算总长度
total_length = sum(d["length"] for d in res["eval"]["details"])
row_dict = {
"name": name_display,
"cost_wan": f"{res['cost'] / 10000:.2f}",
"loss_kw": f"{res['loss']:.2f}",
"total_length": f"{total_length:.2f}",
"note": note,
"original_name": res["name"],
}
@@ -950,13 +954,18 @@ def index():
"field": "loss_kw",
"sortable": True,
},
{
"name": "total_length",
"label": "总长度 (m)",
"field": "total_length",
"sortable": True,
},
{
"name": "note",
"label": "备注",
"field": "note",
"align": "left",
},
]
}, ]
# 使用内置的 selection='single' 结合行点击事件实现背景高亮
# 这样可以完全由 Python 事件逻辑控制,不依赖 CSS 伪类
refs["results_table"] = ui.table(