From b0196ba1774e2862594d2e54ef93a8d4c22fbf67 Mon Sep 17 00:00:00 2001 From: hmo Date: Tue, 28 Apr 2026 16:49:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20click=20'x=E4=B8=AA=E6=96=B9=E6=A1=88'?= =?UTF-8?q?=20to=20open=20latest=20plan=20detail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models.py | 5 +++++ app/templates/index.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 8695ae7..968347f 100644 --- a/app/models.py +++ b/app/models.py @@ -139,6 +139,10 @@ class Student(db.Model): goal_count = len(self.goal_records) if self.goal_records else 0 completed_goal_count = sum(1 for g in self.goal_records if g.achievement_date) if self.goal_records else 0 + # 获取最新方案ID + latest_plan = self.plans.order_by(db.desc("created_at")).first() + latest_plan_id = latest_plan.id if latest_plan else None + return { "id": self.id, "name": self.name, @@ -154,6 +158,7 @@ class Student(db.Model): "problem_count": self.problems.count(), "problem_names": problem_names, # 问题名称列表(按严重程度排序) "plan_count": self.plans.count(), + "latest_plan_id": latest_plan_id, "goal_count": goal_count, "completed_goal_count": completed_goal_count, } diff --git a/app/templates/index.html b/app/templates/index.html index cf286c2..ae1257d 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -614,7 +614,7 @@ function renderStudentList(students) {

${s.wechat_nickname || ''} ${s.phone ? '| ' + s.phone : ''}

${s.practice_time} ${problemText} - ${planBadgeText} + ${s.plan_count > 0 ? `${s.plan_count} 个方案` : '暂无方案'} ${s.goal_count > 0 ? `${s.goal_count}个目标(${s.completed_goal_count}已达成)` : ''}