From ae0493428efbb553fa9573cd632187bf2d013a0b Mon Sep 17 00:00:00 2001 From: tangweijie <877588133@qq.com> Date: Tue, 27 Jan 2026 11:55:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(dashboard):=20=E4=BF=AE=E5=A4=8D=E5=89=A9?= =?UTF-8?q?=E4=BD=99=E5=88=91=E6=9C=9F=E5=A4=A9=E6=95=B0=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 前端直接使用后端返回的remainingDays,不再重新计算 - 添加TypeScript接口missing的remainingDays字段定义 - 修复前后端数据不一致问题(差异可达25天) 分析发现:前端用"总刑期-已服刑"计算,后端用"当前日期到释放日期"计算 --- src/api/prison/dashboard/index.ts | 1 + src/views/Dashboard/Index.vue | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/api/prison/dashboard/index.ts b/src/api/prison/dashboard/index.ts index 1ec6c9bf..08768d15 100644 --- a/src/api/prison/dashboard/index.ts +++ b/src/api/prison/dashboard/index.ts @@ -217,6 +217,7 @@ export interface PrisonerDashboardStatsRespVO { imprisonmentDate: string // 入狱时间 releaseDate: string // 出狱时间 servedDays: number // 已服刑天数 + remainingDays: number // 剩余刑期天数 age: number // 年龄 nativePlace: string // 籍贯 education: string // 文化程度 diff --git a/src/views/Dashboard/Index.vue b/src/views/Dashboard/Index.vue index f9f8eaed..876a759b 100644 --- a/src/views/Dashboard/Index.vue +++ b/src/views/Dashboard/Index.vue @@ -285,13 +285,7 @@ const loadData = async (prisonerId: number) => { // 计算累计服刑天数和剩余刑期天数 const servedDaysValue = res.servedDays || 0; servedDays.value = servedDaysValue - remainingDays.value = 0; - if (res.imprisonmentDate && res.releaseDate) { - const startDate = new Date(res.imprisonmentDate); - const endDate = new Date(res.releaseDate); - const totalDays = Math.floor((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24)); - remainingDays.value = Math.max(0, totalDays - servedDaysValue); - } + remainingDays.value = res.remainingDays || 0; // 获取计分考核数据 - 累计扣分次数和累计加分次数 let totalPenaltyCount = 0;