feat: 方案对比结果表格新增总长度列
- 在方案对比结果中新增'总长度(m)'列 - 自动计算每个方案的海缆总长度 - 支持按总长度排序,方便方案比选
This commit is contained in:
35
gui.py
35
gui.py
@@ -798,10 +798,14 @@ def index():
|
|||||||
elif "No Max" in original_name:
|
elif "No Max" in original_name:
|
||||||
note += "不包含可选电缆型号,且可使用的最大截面电缆降一档截面。"
|
note += "不包含可选电缆型号,且可使用的最大截面电缆降一档截面。"
|
||||||
|
|
||||||
|
# 计算总长度
|
||||||
|
total_length = sum(d["length"] for d in res["eval"]["details"])
|
||||||
|
|
||||||
row_dict = {
|
row_dict = {
|
||||||
"name": name_display,
|
"name": name_display,
|
||||||
"cost_wan": f"{res['cost'] / 10000:.2f}",
|
"cost_wan": f"{res['cost'] / 10000:.2f}",
|
||||||
"loss_kw": f"{res['loss']:.2f}",
|
"loss_kw": f"{res['loss']:.2f}",
|
||||||
|
"total_length": f"{total_length:.2f}",
|
||||||
"note": note,
|
"note": note,
|
||||||
"original_name": res["name"],
|
"original_name": res["name"],
|
||||||
}
|
}
|
||||||
@@ -944,19 +948,24 @@ def index():
|
|||||||
"field": "cost_wan",
|
"field": "cost_wan",
|
||||||
"sortable": True,
|
"sortable": True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "loss_kw",
|
"name": "loss_kw",
|
||||||
"label": "线损 (kW)",
|
"label": "线损 (kW)",
|
||||||
"field": "loss_kw",
|
"field": "loss_kw",
|
||||||
"sortable": True,
|
"sortable": True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "note",
|
"name": "total_length",
|
||||||
"label": "备注",
|
"label": "总长度 (m)",
|
||||||
"field": "note",
|
"field": "total_length",
|
||||||
"align": "left",
|
"sortable": True,
|
||||||
},
|
},
|
||||||
]
|
{
|
||||||
|
"name": "note",
|
||||||
|
"label": "备注",
|
||||||
|
"field": "note",
|
||||||
|
"align": "left",
|
||||||
|
}, ]
|
||||||
# 使用内置的 selection='single' 结合行点击事件实现背景高亮
|
# 使用内置的 selection='single' 结合行点击事件实现背景高亮
|
||||||
# 这样可以完全由 Python 事件逻辑控制,不依赖 CSS 伪类
|
# 这样可以完全由 Python 事件逻辑控制,不依赖 CSS 伪类
|
||||||
refs["results_table"] = ui.table(
|
refs["results_table"] = ui.table(
|
||||||
|
|||||||
Reference in New Issue
Block a user