From 16a271f7e05e0c11b708ff55d0df88f2e794af4e Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sat, 15 Aug 2026 11:19:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=81=B7=E8=A2=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components.d.ts | 2 -- src/modules/first-leg/api/partners.ts | 2 +- .../first-leg/data/firstLegPartySource.test.mjs | 10 ++++++---- src/modules/first-leg/data/firstLegPartySource.ts | 12 +++++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components.d.ts b/src/components.d.ts index 996b13b..90a9533 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -46,8 +46,6 @@ declare module 'vue' { ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabs: typeof import('element-plus/es')['ElTabs'] ElTag: typeof import('element-plus/es')['ElTag'] - ElTimeline: typeof import('element-plus/es')['ElTimeline'] - ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElUpload: typeof import('element-plus/es')['ElUpload'] LoadErrorState: typeof import('./components/common/LoadErrorState.vue')['default'] diff --git a/src/modules/first-leg/api/partners.ts b/src/modules/first-leg/api/partners.ts index 1e36fa3..ab6df49 100644 --- a/src/modules/first-leg/api/partners.ts +++ b/src/modules/first-leg/api/partners.ts @@ -1,6 +1,6 @@ import { apiRequest } from '@/api/http' -export type MerchantPartnerType = 'CUSTOMER' | 'SUPPLIER' | 'CARRIER' | 'CUSTOMS_BROKER' | 'SHIPPER' | 'CONSIGNEE' +export type MerchantPartnerType = 'SHIPPER' | 'CONSIGNEE' export interface MerchantPartner { id: number | string diff --git a/src/modules/first-leg/data/firstLegPartySource.test.mjs b/src/modules/first-leg/data/firstLegPartySource.test.mjs index 50cf89c..c505bf0 100644 --- a/src/modules/first-leg/data/firstLegPartySource.test.mjs +++ b/src/modules/first-leg/data/firstLegPartySource.test.mjs @@ -6,23 +6,25 @@ const source = readFileSync(new URL('./firstLegPartySource.ts', import.meta.url) const viewSource = readFileSync(new URL('../views/FirstLegOrdersView.vue', import.meta.url), 'utf8') const apiSource = readFileSync(new URL('../api/partners.ts', import.meta.url), 'utf8') -test('keeps the legacy counterparty source available without coupling it to first-leg ordering', () => { +test('only exposes shipper and consignee partners as first-leg order candidates', () => { assert.match(source, /export interface FirstLegPartySource/) assert.match(source, /listAvailable\(role/) assert.match(source, /findAvailable\(id, role/) assert.match(source, /async load\(\)/) assert.match(source, /party\.status === 'ACTIVE' && party\.roles\.includes\(role\)/) assert.match(source, /getMerchantPartnerCandidates/) - assert.match(source, /partner\.types\?\.length/) + assert.match(source, /ORDER_PARTNER_ROLES: readonly FirstLegPartyRole\[\] = \['SHIPPER', 'CONSIGNEE'\]/) assert.match(source, /partner\.types\?\.includes\(role\)/) - assert.match(source, /: \['SHIPPER', 'CONSIGNEE'\]/) + assert.match(source, /\.filter\(\(party\) => party\.roles\.length > 0\)/) + assert.doesNotMatch(source, /: \['SHIPPER', 'CONSIGNEE'\]/) assert.match(source, /await getMerchantPartnerCandidates\(\)/) assert.doesNotMatch(source, /getMerchantPartnerCandidates\('SENDER'\)|getMerchantPartnerCandidates\('RECEIVER'\)/) assert.doesNotMatch(viewSource, /firstLegPartySource/) assert.doesNotMatch(viewSource, /发货单位|收货单位/) assert.doesNotMatch(viewSource, /DEMO_FIRST_LEG_PARTIES/) assert.match(apiSource, /url: '\/merchant\/v1\/partners\/candidates'/) - assert.match(apiSource, /'CARRIER' \| 'CUSTOMS_BROKER' \| 'SHIPPER' \| 'CONSIGNEE'/) + assert.match(apiSource, /export type MerchantPartnerType = 'SHIPPER' \| 'CONSIGNEE'/) + assert.doesNotMatch(apiSource, /'CUSTOMER'|'SUPPLIER'|'CARRIER'|'CUSTOMS_BROKER'/) assert.match(apiSource, /types\?: MerchantPartnerType\[\]/) assert.match(apiSource, /url: `\/merchant\/v1\/partners\/\$\{id\}`/) }) diff --git a/src/modules/first-leg/data/firstLegPartySource.ts b/src/modules/first-leg/data/firstLegPartySource.ts index 9674503..0f343a7 100644 --- a/src/modules/first-leg/data/firstLegPartySource.ts +++ b/src/modules/first-leg/data/firstLegPartySource.ts @@ -12,16 +12,14 @@ function isAvailableForRole(party: FirstLegParty, role: FirstLegPartyRole) { } const parties: FirstLegParty[] = [] +const ORDER_PARTNER_ROLES: readonly FirstLegPartyRole[] = ['SHIPPER', 'CONSIGNEE'] function mapPartner(partner: MerchantPartner): FirstLegParty { - const roles: FirstLegPartyRole[] = partner.types?.length - ? (['SHIPPER', 'CONSIGNEE'] as FirstLegPartyRole[]).filter((role) => partner.types?.includes(role)) - : ['SHIPPER', 'CONSIGNEE'] + const roles = ORDER_PARTNER_ROLES.filter((role) => partner.types?.includes(role)) return { id: String(partner.id), code: partner.partnerCode, name: partner.partnerName, - // 新契约按稳定类型限制订单角色;旧响应无 types 时保持原有兼容行为。 roles, contactName: partner.contactName ?? '', phone: partner.contactPhone ?? '', @@ -44,6 +42,10 @@ export const firstLegPartySource: FirstLegPartySource = { }, async load() { parties.splice(0, parties.length) - parties.push(...(await getMerchantPartnerCandidates()).map(mapPartner)) + parties.push( + ...(await getMerchantPartnerCandidates()) + .map(mapPartner) + .filter((party) => party.roles.length > 0), + ) }, }