修复bug
This commit is contained in:
+3
-2
@@ -1,12 +1,13 @@
|
|||||||
import { apiRequest } from '@/api/http'
|
import { apiRequest } from '@/api/http'
|
||||||
|
|
||||||
export type MerchantPartnerType = 'CUSTOMER' | 'SUPPLIER' | 'BOTH'
|
export type MerchantPartnerType = 'CUSTOMER' | 'SUPPLIER' | 'CARRIER' | 'CUSTOMS_BROKER' | 'SHIPPER' | 'CONSIGNEE'
|
||||||
|
|
||||||
export interface MerchantPartner {
|
export interface MerchantPartner {
|
||||||
id: number | string
|
id: number | string
|
||||||
partnerCode: string
|
partnerCode: string
|
||||||
partnerName: string
|
partnerName: string
|
||||||
partnerType: MerchantPartnerType | string
|
partnerType: MerchantPartnerType | 'BOTH' | string
|
||||||
|
types?: MerchantPartnerType[]
|
||||||
contactName: string | null
|
contactName: string | null
|
||||||
contactPhone: string | null
|
contactPhone: string | null
|
||||||
contactEmail: string | null
|
contactEmail: string | null
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ test('keeps counterparty availability behind a replaceable read-only source', ()
|
|||||||
assert.match(source, /async load\(\)/)
|
assert.match(source, /async load\(\)/)
|
||||||
assert.match(source, /party\.status === 'ACTIVE' && party\.roles\.includes\(role\)/)
|
assert.match(source, /party\.status === 'ACTIVE' && party\.roles\.includes\(role\)/)
|
||||||
assert.match(source, /getMerchantPartnerCandidates/)
|
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.match(source, /await getMerchantPartnerCandidates\(\)/)
|
||||||
assert.doesNotMatch(source, /getMerchantPartnerCandidates\('SENDER'\)|getMerchantPartnerCandidates\('RECEIVER'\)/)
|
assert.doesNotMatch(source, /getMerchantPartnerCandidates\('SENDER'\)|getMerchantPartnerCandidates\('RECEIVER'\)/)
|
||||||
assert.match(viewSource, /firstLegPartySource\.listAvailable\('SHIPPER'\)/)
|
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.match(viewSource, /firstLegPartySource\.load\(\)/)
|
||||||
assert.doesNotMatch(viewSource, /DEMO_FIRST_LEG_PARTIES/)
|
assert.doesNotMatch(viewSource, /DEMO_FIRST_LEG_PARTIES/)
|
||||||
assert.match(apiSource, /url: '\/merchant\/v1\/partners\/candidates'/)
|
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\}`/)
|
assert.match(apiSource, /url: `\/merchant\/v1\/partners\/\$\{id\}`/)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,13 +14,15 @@ function isAvailableForRole(party: FirstLegParty, role: FirstLegPartyRole) {
|
|||||||
const parties: FirstLegParty[] = []
|
const parties: FirstLegParty[] = []
|
||||||
|
|
||||||
function mapPartner(partner: MerchantPartner): 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 {
|
return {
|
||||||
id: String(partner.id),
|
id: String(partner.id),
|
||||||
code: partner.partnerCode,
|
code: partner.partnerCode,
|
||||||
name: partner.partnerName,
|
name: partner.partnerName,
|
||||||
// 后端往来单位类型为 CUSTOMER / SUPPLIER / BOTH,不表达订单中的发货/收货角色;
|
// 新契约按稳定类型限制订单角色;旧响应无 types 时保持原有兼容行为。
|
||||||
// 两类订单角色均可选择启用主数据,提交时分别保存独立快照。
|
roles,
|
||||||
roles: ['SHIPPER', 'CONSIGNEE'],
|
|
||||||
contactName: partner.contactName ?? '',
|
contactName: partner.contactName ?? '',
|
||||||
phone: partner.contactPhone ?? '',
|
phone: partner.contactPhone ?? '',
|
||||||
email: partner.contactEmail ?? '',
|
email: partner.contactEmail ?? '',
|
||||||
|
|||||||
Reference in New Issue
Block a user