diff --git a/gui.py b/gui.py index aa7726c..b7e61d5 100644 --- a/gui.py +++ b/gui.py @@ -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"], } @@ -944,19 +948,24 @@ def index(): "field": "cost_wan", "sortable": True, }, - { - "name": "loss_kw", - "label": "线损 (kW)", - "field": "loss_kw", - "sortable": True, - }, - { - "name": "note", - "label": "备注", - "field": "note", - "align": "left", - }, - ] + { + "name": "loss_kw", + "label": "线损 (kW)", + "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(