This commit is contained in:
2026-08-11 20:39:34 +08:00
parent 75f9c51bea
commit 23fc845dcf
6 changed files with 82 additions and 14 deletions
@@ -79,4 +79,11 @@ describe('PlatformFirstLegOrdersPanel review queue', () => {
expect(source).toContain('item.reason || historyActionLabel(item.action)')
expect(source).not.toContain('item.reason || item.action')
})
it('formats cargo measurements without exposing floating-point tails', () => {
expect(source).toContain("numeric.toLocaleString('zh-CN', { maximumFractionDigits: 3 })")
expect(source).toContain('formatMeasurement(row.grossWeightKg)')
expect(source).toContain('formatMeasurement(row.volumeCbm)')
expect(source).not.toContain('{{ row.grossWeightKg }} kg / {{ row.volumeCbm }} m³')
})
})
@@ -163,6 +163,13 @@ function formattedDate(value: string | null | undefined) {
return value ? value.replace('T', ' ').slice(0, 16) : '-'
}
function formatMeasurement(value: unknown) {
const numeric = Number(value)
return value === null || value === undefined || value === '' || !Number.isFinite(numeric)
? '—'
: numeric.toLocaleString('zh-CN', { maximumFractionDigits: 3 })
}
function tenantFor(tenantId: number | string) {
return tenants.value.find((tenant) => String(tenant.id) === String(tenantId))
}
@@ -510,7 +517,7 @@ onMounted(() => void loadTenants())
<el-table-column prop="cargoName" label="品名" min-width="150" />
<el-table-column prop="packageType" label="包装" min-width="100" />
<el-table-column prop="packageCount" label="件/箱" width="86" />
<el-table-column label="毛重 / 体积" min-width="150"><template #default="{ row }">{{ row.grossWeightKg }} kg / {{ row.volumeCbm }} m³</template></el-table-column>
<el-table-column label="毛重 / 体积" min-width="150"><template #default="{ row }">{{ formatMeasurement(row.grossWeightKg) }} kg / {{ formatMeasurement(row.volumeCbm) }} m³</template></el-table-column>
</el-table>
</div>
</div>