偷袭
This commit is contained in:
Vendored
-2
@@ -46,8 +46,6 @@ declare module 'vue' {
|
|||||||
ElTabPane: typeof import('element-plus/es')['ElTabPane']
|
ElTabPane: typeof import('element-plus/es')['ElTabPane']
|
||||||
ElTabs: typeof import('element-plus/es')['ElTabs']
|
ElTabs: typeof import('element-plus/es')['ElTabs']
|
||||||
ElTag: typeof import('element-plus/es')['ElTag']
|
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']
|
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||||
ElUpload: typeof import('element-plus/es')['ElUpload']
|
ElUpload: typeof import('element-plus/es')['ElUpload']
|
||||||
LoadErrorState: typeof import('./components/common/LoadErrorState.vue')['default']
|
LoadErrorState: typeof import('./components/common/LoadErrorState.vue')['default']
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { apiRequest } from '@/api/http'
|
import { apiRequest } from '@/api/http'
|
||||||
|
|
||||||
export type MerchantPartnerType = 'CUSTOMER' | 'SUPPLIER' | 'CARRIER' | 'CUSTOMS_BROKER' | 'SHIPPER' | 'CONSIGNEE'
|
export type MerchantPartnerType = 'SHIPPER' | 'CONSIGNEE'
|
||||||
|
|
||||||
export interface MerchantPartner {
|
export interface MerchantPartner {
|
||||||
id: number | string
|
id: number | string
|
||||||
|
|||||||
@@ -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 viewSource = readFileSync(new URL('../views/FirstLegOrdersView.vue', import.meta.url), 'utf8')
|
||||||
const apiSource = readFileSync(new URL('../api/partners.ts', 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, /export interface FirstLegPartySource/)
|
||||||
assert.match(source, /listAvailable\(role/)
|
assert.match(source, /listAvailable\(role/)
|
||||||
assert.match(source, /findAvailable\(id, role/)
|
assert.match(source, /findAvailable\(id, role/)
|
||||||
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, /partner\.types\?\.length/)
|
assert.match(source, /ORDER_PARTNER_ROLES: readonly FirstLegPartyRole\[\] = \['SHIPPER', 'CONSIGNEE'\]/)
|
||||||
assert.match(source, /partner\.types\?\.includes\(role\)/)
|
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.match(source, /await getMerchantPartnerCandidates\(\)/)
|
||||||
assert.doesNotMatch(source, /getMerchantPartnerCandidates\('SENDER'\)|getMerchantPartnerCandidates\('RECEIVER'\)/)
|
assert.doesNotMatch(source, /getMerchantPartnerCandidates\('SENDER'\)|getMerchantPartnerCandidates\('RECEIVER'\)/)
|
||||||
assert.doesNotMatch(viewSource, /firstLegPartySource/)
|
assert.doesNotMatch(viewSource, /firstLegPartySource/)
|
||||||
assert.doesNotMatch(viewSource, /发货单位|收货单位/)
|
assert.doesNotMatch(viewSource, /发货单位|收货单位/)
|
||||||
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, /'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, /types\?: MerchantPartnerType\[\]/)
|
||||||
assert.match(apiSource, /url: `\/merchant\/v1\/partners\/\$\{id\}`/)
|
assert.match(apiSource, /url: `\/merchant\/v1\/partners\/\$\{id\}`/)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -12,16 +12,14 @@ function isAvailableForRole(party: FirstLegParty, role: FirstLegPartyRole) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parties: FirstLegParty[] = []
|
const parties: FirstLegParty[] = []
|
||||||
|
const ORDER_PARTNER_ROLES: readonly FirstLegPartyRole[] = ['SHIPPER', 'CONSIGNEE']
|
||||||
|
|
||||||
function mapPartner(partner: MerchantPartner): FirstLegParty {
|
function mapPartner(partner: MerchantPartner): FirstLegParty {
|
||||||
const roles: FirstLegPartyRole[] = partner.types?.length
|
const roles = ORDER_PARTNER_ROLES.filter((role) => partner.types?.includes(role))
|
||||||
? (['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,
|
||||||
// 新契约按稳定类型限制订单角色;旧响应无 types 时保持原有兼容行为。
|
|
||||||
roles,
|
roles,
|
||||||
contactName: partner.contactName ?? '',
|
contactName: partner.contactName ?? '',
|
||||||
phone: partner.contactPhone ?? '',
|
phone: partner.contactPhone ?? '',
|
||||||
@@ -44,6 +42,10 @@ export const firstLegPartySource: FirstLegPartySource = {
|
|||||||
},
|
},
|
||||||
async load() {
|
async load() {
|
||||||
parties.splice(0, parties.length)
|
parties.splice(0, parties.length)
|
||||||
parties.push(...(await getMerchantPartnerCandidates()).map(mapPartner))
|
parties.push(
|
||||||
|
...(await getMerchantPartnerCandidates())
|
||||||
|
.map(mapPartner)
|
||||||
|
.filter((party) => party.roles.length > 0),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user