From 5ab46fbff1b829ef04970b127399069ffabc1606 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Mon, 3 Aug 2026 14:58:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/partners.ts | 5 +++-- src/data/firstLegPartySource.test.mjs | 7 +++++-- src/data/firstLegPartySource.ts | 8 +++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/api/partners.ts b/src/api/partners.ts index ee57c4a..1e36fa3 100644 --- a/src/api/partners.ts +++ b/src/api/partners.ts @@ -1,12 +1,13 @@ import { apiRequest } from '@/api/http' -export type MerchantPartnerType = 'CUSTOMER' | 'SUPPLIER' | 'BOTH' +export type MerchantPartnerType = 'CUSTOMER' | 'SUPPLIER' | 'CARRIER' | 'CUSTOMS_BROKER' | 'SHIPPER' | 'CONSIGNEE' export interface MerchantPartner { id: number | string partnerCode: string partnerName: string - partnerType: MerchantPartnerType | string + partnerType: MerchantPartnerType | 'BOTH' | string + types?: MerchantPartnerType[] contactName: string | null contactPhone: string | null contactEmail: string | null diff --git a/src/data/firstLegPartySource.test.mjs b/src/data/firstLegPartySource.test.mjs index 5152978..b033d9a 100644 --- a/src/data/firstLegPartySource.test.mjs +++ b/src/data/firstLegPartySource.test.mjs @@ -13,7 +13,9 @@ test('keeps counterparty availability behind a replaceable read-only source', () assert.match(source, /async load\(\)/) assert.match(source, /party\.status === 'ACTIVE' && party\.roles\.includes\(role\)/) assert.match(source, /getMerchantPartnerCandidates/) - assert.match(source, /roles: \['SHIPPER', 'CONSIGNEE'\]/) + assert.match(source, /partner\.types\?\.length/) + assert.match(source, /partner\.types\?\.includes\(role\)/) + assert.match(source, /: \['SHIPPER', 'CONSIGNEE'\]/) assert.match(source, /await getMerchantPartnerCandidates\(\)/) assert.doesNotMatch(source, /getMerchantPartnerCandidates\('SENDER'\)|getMerchantPartnerCandidates\('RECEIVER'\)/) assert.match(viewSource, /firstLegPartySource\.listAvailable\('SHIPPER'\)/) @@ -22,6 +24,7 @@ test('keeps counterparty availability behind a replaceable read-only source', () assert.match(viewSource, /firstLegPartySource\.load\(\)/) assert.doesNotMatch(viewSource, /DEMO_FIRST_LEG_PARTIES/) assert.match(apiSource, /url: '\/merchant\/v1\/partners\/candidates'/) - assert.match(apiSource, /'CUSTOMER' \| 'SUPPLIER' \| 'BOTH'/) + assert.match(apiSource, /'CARRIER' \| 'CUSTOMS_BROKER' \| 'SHIPPER' \| 'CONSIGNEE'/) + assert.match(apiSource, /types\?: MerchantPartnerType\[\]/) assert.match(apiSource, /url: `\/merchant\/v1\/partners\/\$\{id\}`/) }) diff --git a/src/data/firstLegPartySource.ts b/src/data/firstLegPartySource.ts index f6d6182..0052739 100644 --- a/src/data/firstLegPartySource.ts +++ b/src/data/firstLegPartySource.ts @@ -14,13 +14,15 @@ function isAvailableForRole(party: FirstLegParty, role: FirstLegPartyRole) { const parties: FirstLegParty[] = [] function mapPartner(partner: MerchantPartner): FirstLegParty { + const roles: FirstLegPartyRole[] = partner.types?.length + ? (['SHIPPER', 'CONSIGNEE'] as FirstLegPartyRole[]).filter((role) => partner.types?.includes(role)) + : ['SHIPPER', 'CONSIGNEE'] return { id: String(partner.id), code: partner.partnerCode, name: partner.partnerName, - // 后端往来单位类型为 CUSTOMER / SUPPLIER / BOTH,不表达订单中的发货/收货角色; - // 两类订单角色均可选择启用主数据,提交时分别保存独立快照。 - roles: ['SHIPPER', 'CONSIGNEE'], + // 新契约按稳定类型限制订单角色;旧响应无 types 时保持原有兼容行为。 + roles, contactName: partner.contactName ?? '', phone: partner.contactPhone ?? '', email: partner.contactEmail ?? '',