diff --git a/src/modules/order-management/api/inboundPlans.ts b/src/modules/order-management/api/inboundPlans.ts index d49d921..8512ef2 100644 --- a/src/modules/order-management/api/inboundPlans.ts +++ b/src/modules/order-management/api/inboundPlans.ts @@ -17,8 +17,8 @@ export interface InboundPlanSummary { planNo: string inboundCode: string orderType: string | null - overseasWarehouseCode: string | null - overseasWarehouseName: string | null + overseasWarehouseCode?: string | null + overseasWarehouseName?: string | null fbaWarehouseCode: string | null packageCount: number pickedPackageCount: number @@ -52,8 +52,8 @@ export interface InboundPlanPallet { export interface InboundPlanDetail { planNo: string containerNo: string | null - overseasWarehouseCode: string | null - overseasWarehouseName: string | null + overseasWarehouseCode?: string | null + overseasWarehouseName?: string | null status: string lineCount: number palletCount: number diff --git a/src/modules/order-management/inboundOrders.test.mjs b/src/modules/order-management/inboundOrders.test.mjs index d4ed904..9bba715 100644 --- a/src/modules/order-management/inboundOrders.test.mjs +++ b/src/modules/order-management/inboundOrders.test.mjs @@ -1,6 +1,7 @@ import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import test from 'node:test' +import { overseasWarehouseLabel } from './inboundPlanDisplay.ts' const api = readFileSync(new URL('./api/inboundPlans.ts', import.meta.url), 'utf8') const routes = readFileSync(new URL('./routes.ts', import.meta.url), 'utf8') @@ -12,6 +13,7 @@ test('activates the customer-scoped overseas inbound list and detail', () => { assert.match(api, /\/merchant\/v1\/last-leg\/inbound-plans/) assert.match(api, /encodeURIComponent\(planNo\)/) assert.doesNotMatch(api, /\/platform\/|\/internal\/|customerId|tenantId/) + assert.doesNotMatch(view, /customerId|tenantId/) }) test('keeps actions first and exposes filters loading errors empty state pagination and business identifiers', () => { @@ -26,16 +28,24 @@ test('keeps actions first and exposes filters loading errors empty state paginat }) test('shows only the server-provided overseas receiving warehouse code and name', () => { - assert.match(api, /overseasWarehouseCode: string \| null/) - assert.match(api, /overseasWarehouseName: string \| null/) + assert.equal((api.match(/overseasWarehouseCode\?: string \| null/g) || []).length, 2) + assert.equal((api.match(/overseasWarehouseName\?: string \| null/g) || []).length, 2) assert.doesNotMatch(api, /overseasWarehouseId/) assert.match(view, /label="海外接柜仓"/) assert.match(view, /overseasWarehouseLabel\(scope\.row\.overseasWarehouseCode, scope\.row\.overseasWarehouseName\)/) assert.match(view, /overseasWarehouseLabel\(detail\.overseasWarehouseCode, detail\.overseasWarehouseName\)/) - assert.match(view, /if \(typeof code !== 'string' \|\| !code\.trim\(\) \|\| typeof name !== 'string' \|\| !name\.trim\(\)\) return '—'/) assert.doesNotMatch(view, /warehouseName \|\| warehouseCode|destinationWarehouse(?:Id|Code|Name).*overseasWarehouse/i) }) +test('renders a dash when either formal receiving warehouse field is absent', () => { + assert.equal(overseasWarehouseLabel('US-LAX-01', '洛杉矶仓'), 'US-LAX-01 · 洛杉矶仓') + assert.equal(overseasWarehouseLabel(' US-LAX-01 ', ' 洛杉矶仓 '), 'US-LAX-01 · 洛杉矶仓') + for (const pair of [ + [undefined, undefined], [null, null], ['', '洛杉矶仓'], ['US-LAX-01', ''], + [undefined, '洛杉矶仓'], ['US-LAX-01', undefined], [' ', '洛杉矶仓'], ['US-LAX-01', ' '], + ]) assert.equal(overseasWarehouseLabel(pair[0], pair[1]), '—') +}) + test('preserves overseas API diagnostic metadata without rendering it as a business identifier', () => { assert.match(overseasHttp, /response\.data\.traceId/) assert.match(overseasHttp, /response\.data\.requestId/) diff --git a/src/modules/order-management/inboundPlanDisplay.ts b/src/modules/order-management/inboundPlanDisplay.ts new file mode 100644 index 0000000..30e94ca --- /dev/null +++ b/src/modules/order-management/inboundPlanDisplay.ts @@ -0,0 +1,4 @@ +export function overseasWarehouseLabel(code: unknown, name: unknown) { + if (typeof code !== 'string' || !code.trim() || typeof name !== 'string' || !name.trim()) return '—' + return `${code.trim()} · ${name.trim()}` +} diff --git a/src/modules/order-management/views/InboundOrdersView.vue b/src/modules/order-management/views/InboundOrdersView.vue index 2bfbed7..7627e05 100644 --- a/src/modules/order-management/views/InboundOrdersView.vue +++ b/src/modules/order-management/views/InboundOrdersView.vue @@ -2,6 +2,7 @@ import { onMounted, reactive, ref } from 'vue' import { ElMessage } from 'element-plus' import { getInboundPlan, listInboundPlans, type InboundPlanDetail, type InboundPlanSummary } from '../api/inboundPlans' +import { overseasWarehouseLabel } from '../inboundPlanDisplay' const loading = ref(false) const error = ref('') @@ -23,10 +24,6 @@ const query = reactive({ }) function text(value: unknown) { return value === null || value === undefined || value === '' ? '—' : String(value) } -function overseasWarehouseLabel(code: unknown, name: unknown) { - if (typeof code !== 'string' || !code.trim() || typeof name !== 'string' || !name.trim()) return '—' - return `${code.trim()} · ${name.trim()}` -} function destinationWarehouseLabel(...values: unknown[]) { const parts = values .filter((value): value is string => typeof value === 'string' && Boolean(value.trim()))