From 86e0e21b585705e78392698cea8b8cea5d31b381 Mon Sep 17 00:00:00 2001 From: dmy Date: Tue, 6 Jan 2026 11:25:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B9=E6=A1=88=E5=AF=B9=E6=AF=94?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E8=A1=A8=E6=A0=BC=E6=96=B0=E5=A2=9E=E6=80=BB?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在方案对比结果中新增'总长度(m)'列 - 自动计算每个方案的海缆总长度 - 支持按总长度排序,方便方案比选 --- gui.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) 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(