From cc778f3701bef01a5a392855319d3c6864e0c053 Mon Sep 17 00:00:00 2001 From: kkfluous Date: Wed, 3 Jun 2026 14:54:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(mileage):=20=E5=AF=BC=E5=87=BA=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E9=87=8C=E7=A8=8B=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/mileage/xlsx-export.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/mileage/xlsx-export.ts b/src/modules/mileage/xlsx-export.ts index dd413f2..18ee534 100644 --- a/src/modules/mileage/xlsx-export.ts +++ b/src/modules/mileage/xlsx-export.ts @@ -20,9 +20,9 @@ function mileageCell(v: MonitoringVehicle, kind: 'today' | 'total'): string | nu if (kind === 'today') { // 当日未对接但有历史累计,视作今日 0;只有完全无数据才标「未对接」 if (!v.isDataSynced && v.totalKm == null) return '未对接'; - return Math.max(0, Math.round(v.dailyKm || 0)); + return Math.max(0, v.dailyKm || 0); } - return v.totalKm != null ? Math.round(v.totalKm) : '未对接'; + return v.totalKm != null ? v.totalKm : '未对接'; } export function exportMileageXlsx(vehicles: MonitoringVehicle[], ctx: ExportContext): void { @@ -57,6 +57,13 @@ export function exportMileageXlsx(vehicles: MonitoringVehicle[], ctx: ExportCont ws['!freeze'] = { xSplit: 0, ySplit: 1 } as never; + for (let r = 1; r < data.length; r++) { + for (const c of [7, 8]) { + const ref = XLSX.utils.encode_cell({ r, c }); + if (ws[ref]?.t === 'n') ws[ref].z = '0.##########'; + } + } + // 表头样式(在客户端 SheetJS 社区版仅基本样式生效) for (let c = 0; c < HEADERS.length; c++) { const ref = XLSX.utils.encode_cell({ r: 0, c });