fix(dashboard): 修复剩余刑期天数计算逻辑不一致问题

- 前端直接使用后端返回的remainingDays,不再重新计算
- 添加TypeScript接口missing的remainingDays字段定义
- 修复前后端数据不一致问题(差异可达25天)

分析发现:前端用"总刑期-已服刑"计算,后端用"当前日期到释放日期"计算
This commit is contained in:
tangweijie 2026-01-27 11:55:56 +08:00
parent 4e65bb4300
commit ae0493428e
2 changed files with 2 additions and 7 deletions

View File

@ -217,6 +217,7 @@ export interface PrisonerDashboardStatsRespVO {
imprisonmentDate: string // 入狱时间 imprisonmentDate: string // 入狱时间
releaseDate: string // 出狱时间 releaseDate: string // 出狱时间
servedDays: number // 已服刑天数 servedDays: number // 已服刑天数
remainingDays: number // 剩余刑期天数
age: number // 年龄 age: number // 年龄
nativePlace: string // 籍贯 nativePlace: string // 籍贯
education: string // 文化程度 education: string // 文化程度

View File

@ -285,13 +285,7 @@ const loadData = async (prisonerId: number) => {
// //
const servedDaysValue = res.servedDays || 0; const servedDaysValue = res.servedDays || 0;
servedDays.value = servedDaysValue servedDays.value = servedDaysValue
remainingDays.value = 0; remainingDays.value = res.remainingDays || 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);
}
// - // -
let totalPenaltyCount = 0; let totalPenaltyCount = 0;