From 1c57eb4a587c411bd7224a429eda2f68cb856c6b Mon Sep 17 00:00:00 2001 From: kkfluous Date: Thu, 7 May 2026 15:20:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(mileage):=20=E7=B4=AF=E8=AE=A1=E9=87=8C?= =?UTF-8?q?=E7=A8=8B=E5=B1=95=E7=A4=BA=E4=B8=8D=E5=86=8D=E8=A2=AB=E3=80=8C?= =?UTF-8?q?=E6=9C=AA=E5=AF=B9=E6=8E=A5=E3=80=8D=E7=8A=B6=E6=80=81=E7=9B=96?= =?UTF-8?q?=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端 cache 已用 fetchLatestPgTotalMileageMap 在当日 source=NONE 时 回填该车 ln_vehicle_day_total_pg 最近一条 total_mileage,但前端 表格 / 卡片 / Excel 都用 isDataSynced && totalKm != null 判定, 未对接车被锁回「未对接」文案。 调整为: - 今日里程仍按 isDataSynced 显示「未对接」(今天确实没增量) - 累计里程只看 totalKm 是否为 null,未对接但有历史值的车现在能显示 实测 粤A03423F:source=NONE / dailyKm=0 / totalKm=9205.6 原来「总: 未对接」→ 现在显示 9205.6 km Co-Authored-By: Claude Opus 4.7 (1M context) --- src/modules/mileage/MonitoringView.tsx | 4 ++-- src/modules/mileage/xlsx-export.ts | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/mileage/MonitoringView.tsx b/src/modules/mileage/MonitoringView.tsx index ce09130..fb517b8 100644 --- a/src/modules/mileage/MonitoringView.tsx +++ b/src/modules/mileage/MonitoringView.tsx @@ -541,7 +541,7 @@ export default function MonitoringView() { - {v.isDataSynced && v.totalKm != null ? <>{v.totalKm.toLocaleString()} km : 未对接} + {v.totalKm != null ? <>{v.totalKm.toLocaleString()} km : 未对接} @@ -937,7 +937,7 @@ export default function MonitoringView() {
- {v.isDataSynced && v.totalKm != null ? `${v.totalKm.toLocaleString()} km` : '未对接'} + {v.totalKm != null ? `${v.totalKm.toLocaleString()} km` : '未对接'}
diff --git a/src/modules/mileage/xlsx-export.ts b/src/modules/mileage/xlsx-export.ts index ba89af7..5b8de8e 100644 --- a/src/modules/mileage/xlsx-export.ts +++ b/src/modules/mileage/xlsx-export.ts @@ -17,8 +17,11 @@ function statusLabel(v: MonitoringVehicle): string { } function mileageCell(v: MonitoringVehicle, kind: 'today' | 'total'): string | number { - if (!v.isDataSynced) return '未对接'; - if (kind === 'today') return Math.max(0, Math.round(v.dailyKm || 0)); + if (kind === 'today') { + if (!v.isDataSynced) return '未对接'; + return Math.max(0, Math.round(v.dailyKm || 0)); + } + // 累计里程:当日未对接也允许使用历史兜底值 return v.totalKm != null ? Math.round(v.totalKm) : '未对接'; }