diff --git a/backend/airlabs.db b/backend/airlabs.db index 6ff9f2e..733e4f4 100644 Binary files a/backend/airlabs.db and b/backend/airlabs.db differ diff --git a/backend/routers/dashboard.py b/backend/routers/dashboard.py index 69d4590..39424f3 100644 --- a/backend/routers/dashboard.py +++ b/backend/routers/dashboard.py @@ -93,8 +93,12 @@ def get_dashboard( # 损耗排行 waste_ranking = [] + total_waste_seconds_all = 0.0 + total_target_seconds_all = 0.0 for p in active + completed: w = calc_waste_for_project(p.id, db) + total_waste_seconds_all += w.get("total_waste_seconds", 0) + total_target_seconds_all += p.target_total_seconds or 0 if w.get("total_waste_seconds", 0) > 0: waste_ranking.append({ "project_id": p.id, @@ -103,6 +107,7 @@ def get_dashboard( "waste_rate": w["waste_rate"], }) waste_ranking.sort(key=lambda x: x["waste_rate"], reverse=True) + total_waste_rate = round(total_waste_seconds_all / total_target_seconds_all * 100, 1) if total_target_seconds_all > 0 else 0 # 已结算项目 settled = [] @@ -206,6 +211,8 @@ def get_dashboard( "monthly_total_seconds": round(monthly_secs, 1), "avg_daily_seconds_per_person": avg_daily, "projects": project_summaries, + "total_waste_seconds": round(total_waste_seconds_all, 0), + "total_waste_rate": total_waste_rate, "waste_ranking": waste_ranking, "settled_projects": settled, "profitability": profitability, diff --git a/frontend/src/views/Dashboard.vue b/frontend/src/views/Dashboard.vue index ada6c3b..ecc0193 100644 --- a/frontend/src/views/Dashboard.vue +++ b/frontend/src/views/Dashboard.vue @@ -1,7 +1,7 @@