修正客户端费用换算信息空态

This commit is contained in:
2026-08-29 11:45:57 +08:00
parent bf20224a48
commit 545a0f23ed
5 changed files with 31 additions and 12 deletions
@@ -19,7 +19,7 @@ test('shows the confirmed merchant inbound and fee fields without write actions'
assert.match(source, new RegExp(label)) assert.match(source, new RegExp(label))
} }
assert.match(source, /formatInboundMoney\(props\.data\.latestFee\.totalAmount/) assert.match(source, /formatInboundMoney\(props\.data\.latestFee\.totalAmount/)
assert.match(source, /getRoundingModeLabel\(props\.data\.latestFee\.roundingMode\)/) assert.match(source, /formatConversionPrecision\(/)
assert.doesNotMatch(source, /确认费用|调整费用|发送费用|下载照片/) assert.doesNotMatch(source, /确认费用|调整费用|发送费用|下载照片/)
assert.doesNotMatch(source, /internalNotes|statusHistory|files/) assert.doesNotMatch(source, /internalNotes|statusHistory|files/)
assert.match(source, /latestFee\.ruleCode/) assert.match(source, /latestFee\.ruleCode/)
@@ -2,12 +2,12 @@
import { Clock3, PackageCheck, RefreshCw, TriangleAlert } from '@lucide/vue' import { Clock3, PackageCheck, RefreshCw, TriangleAlert } from '@lucide/vue'
import type { MerchantInboundBilling } from '@/modules/first-leg/types/inboundBilling' import type { MerchantInboundBilling } from '@/modules/first-leg/types/inboundBilling'
import { import {
formatConversionPrecision,
formatInboundDateTime, formatInboundDateTime,
formatInboundMeasure, formatInboundMeasure,
formatInboundMoney, formatInboundMoney,
formatInboundNumber, formatInboundNumber,
getChargeModeLabel, getChargeModeLabel,
getRoundingModeLabel,
getTaxModeLabel, getTaxModeLabel,
} from '@/modules/first-leg/utils/inboundBilling' } from '@/modules/first-leg/utils/inboundBilling'
@@ -109,10 +109,11 @@ defineEmits<{
<div><dt>计费方式</dt><dd>{{ getChargeModeLabel(props.data.latestFee.chargeMode) }} · {{ getTaxModeLabel(props.data.latestFee.taxMode) }}</dd></div> <div><dt>计费方式</dt><dd>{{ getChargeModeLabel(props.data.latestFee.chargeMode) }} · {{ getTaxModeLabel(props.data.latestFee.taxMode) }}</dd></div>
<div> <div>
<dt>换算与精度</dt> <dt>换算与精度</dt>
<dd> <dd>{{ formatConversionPrecision(
系数 {{ formatInboundNumber(props.data.latestFee.conversionFactor) }} · props.data.latestFee.conversionFactor,
保留 {{ props.data.latestFee.roundingScale }} 位 {{ getRoundingModeLabel(props.data.latestFee.roundingMode) }} props.data.latestFee.roundingScale,
</dd> props.data.latestFee.roundingMode,
) }}</dd>
</div> </div>
<div><dt>实际重量</dt><dd>{{ formatInboundMeasure(props.data.latestFee.actualWeightKg, 'kg') }}</dd></div> <div><dt>实际重量</dt><dd>{{ formatInboundMeasure(props.data.latestFee.actualWeightKg, 'kg') }}</dd></div>
<div><dt>实际体积</dt><dd>{{ formatInboundMeasure(props.data.latestFee.actualVolumeCbm, 'm³') }}</dd></div> <div><dt>实际体积</dt><dd>{{ formatInboundMeasure(props.data.latestFee.actualVolumeCbm, 'm³') }}</dd></div>
@@ -79,9 +79,9 @@ export interface MerchantInboundFeeSnapshot {
destinationCode: string destinationCode: string
taxMode: string taxMode: string
chargeMode: 'KG' | 'CBM' chargeMode: 'KG' | 'CBM'
conversionFactor: number conversionFactor: number | null
roundingScale: number roundingScale: number | null
roundingMode: string roundingMode: string | null
actualWeightKg: number actualWeightKg: number
actualVolumeCbm: number actualVolumeCbm: number
convertedQuantity: number convertedQuantity: number
@@ -16,5 +16,12 @@ test('translates backend rounding modes into customer-facing calculation labels'
assert.match(source, /export function getRoundingModeLabel/) assert.match(source, /export function getRoundingModeLabel/)
assert.match(source, /CEILING: '向上取整'/) assert.match(source, /CEILING: '向上取整'/)
assert.match(source, /HALF_UP: '四舍五入'/) assert.match(source, /HALF_UP: '四舍五入'/)
assert.match(source, /return labels\[value\] \|\| value \|\| '-'/) assert.match(source, /return value \? labels\[value\] \|\| value : '-'/)
})
test('renders conversion metadata as one complete label or a single empty marker', () => {
assert.match(source, /export function formatConversionPrecision/)
assert.match(source, /roundingScale === null \|\| roundingScale === undefined/)
assert.match(source, /\|\| !roundingMode\) return '-'/)
assert.match(source, /`系数 \$\{formatInboundNumber\(conversionFactor\)\} · 保留 \$\{roundingScale\} 位 \$\{getRoundingModeLabel\(roundingMode\)\}`/)
}) })
+13 -2
View File
@@ -46,7 +46,7 @@ export function getTaxModeLabel(value: string) {
return value || '-' return value || '-'
} }
export function getRoundingModeLabel(value: string) { export function getRoundingModeLabel(value: string | null | undefined) {
const labels: Record<string, string> = { const labels: Record<string, string> = {
UP: '向上舍入', UP: '向上舍入',
DOWN: '向下舍入', DOWN: '向下舍入',
@@ -56,5 +56,16 @@ export function getRoundingModeLabel(value: string) {
HALF_DOWN: '五舍六入', HALF_DOWN: '五舍六入',
HALF_EVEN: '银行家舍入', HALF_EVEN: '银行家舍入',
} }
return labels[value] || value || '-' return value ? labels[value] || value : '-'
}
export function formatConversionPrecision(
conversionFactor: number | null | undefined,
roundingScale: number | null | undefined,
roundingMode: string | null | undefined,
) {
if (conversionFactor === null || conversionFactor === undefined
|| roundingScale === null || roundingScale === undefined
|| !roundingMode) return '-'
return `系数 ${formatInboundNumber(conversionFactor)} · 保留 ${roundingScale} 位 ${getRoundingModeLabel(roundingMode)}`
} }