优化
This commit is contained in:
@@ -19,8 +19,8 @@ vi.mock('@/shared/api/http', () => ({
|
||||
const payload: SavePlatformPartnerRequest = {
|
||||
partnerCode: 'CUS-001',
|
||||
partnerName: '测试往来单位',
|
||||
partnerType: 'CUSTOMER',
|
||||
types: ['CUSTOMER', 'SHIPPER'],
|
||||
partnerType: 'SHIPPER',
|
||||
types: ['SHIPPER'],
|
||||
contactName: '测试联系人',
|
||||
contactPhone: '13800000000',
|
||||
contactEmail: null,
|
||||
@@ -40,10 +40,10 @@ describe('platform partner API', () => {
|
||||
it('queries the platform partner page with filters only', async () => {
|
||||
vi.mocked(http.get).mockResolvedValue({ code: '200', message: 'success', data: { records: [], page: '1', size: '20', total: '1', pages: '1' } })
|
||||
|
||||
const result = await listPlatformPartners({ page: 1, size: 20, keyword: '测试', type: 'CUSTOMER', status: 'ACTIVE' })
|
||||
const result = await listPlatformPartners({ page: 1, size: 20, keyword: '测试', type: 'SHIPPER', status: 'ACTIVE' })
|
||||
|
||||
expect(http.get).toHaveBeenCalledWith('/platform/v1/partners', {
|
||||
params: { page: 1, size: 20, keyword: '测试', type: 'CUSTOMER', status: 'ACTIVE' },
|
||||
params: { page: 1, size: 20, keyword: '测试', type: 'SHIPPER', status: 'ACTIVE' },
|
||||
})
|
||||
expect(result).toMatchObject({ page: 1, size: 20, total: 1, pages: 1 })
|
||||
})
|
||||
@@ -66,7 +66,7 @@ describe('platform partner API', () => {
|
||||
vi.mocked(http.get)
|
||||
.mockResolvedValueOnce({ code: '200', message: 'success', data: {
|
||||
id: '19001', tenantId: 0, dataScopeId: 0, partnerCode: 'CUS-001', partnerName: '测试单位',
|
||||
partnerType: 'BOTH', contactName: '张三', contactPhone: '13800000000', contactEmail: null,
|
||||
partnerType: 'CONSIGNEE', contactName: '张三', contactPhone: '13800000000', contactEmail: null,
|
||||
countryCode: 'CN', province: null, city: '深圳市', district: null, addressLine: '测试地址',
|
||||
postalCode: null, status: 'ACTIVE',
|
||||
} })
|
||||
@@ -80,7 +80,7 @@ describe('platform partner API', () => {
|
||||
const file = new File(['xlsx'], 'partners.xlsx')
|
||||
const result = await importPlatformPartners(file)
|
||||
|
||||
expect(detail.types).toEqual(['CUSTOMER', 'SUPPLIER'])
|
||||
expect(detail.types).toEqual(['CONSIGNEE'])
|
||||
expect(detail.dataScopeId).toBe(0)
|
||||
expect(template).toBeInstanceOf(Blob)
|
||||
expect(result.success).toBe(true)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
|
||||
export type PlatformPartnerType = 'CUSTOMER' | 'SUPPLIER' | 'CARRIER' | 'CUSTOMS_BROKER' | 'SHIPPER' | 'CONSIGNEE'
|
||||
export type PlatformPartnerLegacyType = PlatformPartnerType | 'BOTH'
|
||||
export type PlatformPartnerType = 'CARRIER' | 'SHIPPER' | 'CONSIGNEE'
|
||||
export type PlatformPartnerStatus = 'ACTIVE' | 'INACTIVE'
|
||||
|
||||
export interface PlatformPartnerResource {
|
||||
@@ -10,7 +9,7 @@ export interface PlatformPartnerResource {
|
||||
dataScopeId: number | string
|
||||
partnerCode: string
|
||||
partnerName: string
|
||||
partnerType: PlatformPartnerLegacyType
|
||||
partnerType: PlatformPartnerType
|
||||
types: PlatformPartnerType[]
|
||||
contactName: string
|
||||
contactPhone: string
|
||||
@@ -86,13 +85,10 @@ const basePath = '/platform/v1/partners'
|
||||
const platformResourceScope = 0
|
||||
|
||||
function normalizePartner(resource: PlatformPartnerResource): PlatformPartnerResource {
|
||||
const legacyTypes: PlatformPartnerType[] = resource.partnerType === 'BOTH'
|
||||
? ['CUSTOMER', 'SUPPLIER']
|
||||
: [resource.partnerType]
|
||||
return {
|
||||
...resource,
|
||||
dataScopeId: resource.dataScopeId ?? resource.tenantId,
|
||||
types: resource.types?.length ? resource.types : legacyTypes,
|
||||
types: resource.types?.length ? resource.types : [resource.partnerType],
|
||||
remark: resource.remark ?? null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ const partner: PlatformPartnerResource = {
|
||||
id: '19001',
|
||||
tenantId: 0,
|
||||
dataScopeId: 0,
|
||||
partnerCode: 'CUS-001',
|
||||
partnerCode: 'SHP-001',
|
||||
partnerName: '深圳示例贸易有限公司',
|
||||
partnerType: 'CUSTOMER',
|
||||
types: ['CUSTOMER', 'SHIPPER'],
|
||||
partnerType: 'SHIPPER',
|
||||
types: ['SHIPPER'],
|
||||
contactName: '张三',
|
||||
contactPhone: '13800138000',
|
||||
contactEmail: 'contact@example.com',
|
||||
@@ -152,6 +152,11 @@ describe('PartnersView real API integration', () => {
|
||||
|
||||
expect(document.body.textContent).toContain('新增往来单位')
|
||||
expect(document.body.textContent).not.toContain('请先在筛选条件中选择所属企业')
|
||||
expect(document.body.textContent).toContain('船公司')
|
||||
expect(document.body.textContent).toContain('发货单位')
|
||||
expect(document.body.textContent).toContain('收货单位')
|
||||
expect(document.body.textContent).not.toContain('报关行')
|
||||
expect(document.body.textContent).not.toContain('供应商')
|
||||
})
|
||||
|
||||
it('renders a padded detail layout without an empty data-scope cell', async () => {
|
||||
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
updatePlatformPartner,
|
||||
type PlatformPartnerResource,
|
||||
type PlatformPartnerStatus,
|
||||
type PlatformPartnerLegacyType,
|
||||
type PlatformPartnerType,
|
||||
type SavePlatformPartnerRequest,
|
||||
} from '@/modules/master-data/counterparties/api/platformPartners'
|
||||
@@ -68,10 +67,7 @@ const queryFields = computed<QueryField[]>(() => [
|
||||
label: '单位类型',
|
||||
placeholder: '全部类型',
|
||||
options: [
|
||||
{ label: '客户', value: 'CUSTOMER' },
|
||||
{ label: '供应商', value: 'SUPPLIER' },
|
||||
{ label: '承运商', value: 'CARRIER' },
|
||||
{ label: '报关行', value: 'CUSTOMS_BROKER' },
|
||||
{ label: '船公司', value: 'CARRIER' },
|
||||
{ label: '发货单位', value: 'SHIPPER' },
|
||||
{ label: '收货单位', value: 'CONSIGNEE' },
|
||||
],
|
||||
@@ -96,8 +92,8 @@ const emptyForm = (): PartnerForm => ({
|
||||
id: '',
|
||||
partnerCode: '',
|
||||
partnerName: '',
|
||||
partnerType: 'CUSTOMER',
|
||||
types: ['CUSTOMER'],
|
||||
partnerType: 'SHIPPER',
|
||||
types: ['SHIPPER'],
|
||||
contactName: '',
|
||||
contactPhone: '',
|
||||
contactEmail: null,
|
||||
@@ -138,16 +134,13 @@ const rules: FormRules<PartnerForm> = {
|
||||
}
|
||||
|
||||
const typeLabels: Record<PlatformPartnerType, string> = {
|
||||
CUSTOMER: '客户',
|
||||
SUPPLIER: '供应商',
|
||||
CARRIER: '承运商',
|
||||
CUSTOMS_BROKER: '报关行',
|
||||
CARRIER: '船公司',
|
||||
SHIPPER: '发货单位',
|
||||
CONSIGNEE: '收货单位',
|
||||
}
|
||||
const typeOptions = Object.entries(typeLabels).map(([value, label]) => ({ value: value as PlatformPartnerType, label }))
|
||||
function partnerTypeLabel(type: PlatformPartnerLegacyType) {
|
||||
return type === 'BOTH' ? '客户 / 供应商' : typeLabels[type]
|
||||
function partnerTypeLabel(type: PlatformPartnerType) {
|
||||
return typeLabels[type]
|
||||
}
|
||||
const partnerColumns: DataTableColumn[] = [
|
||||
{ key: 'actions', label: '操作', width: 250, fixed: 'left', slotName: 'actions' },
|
||||
|
||||
Reference in New Issue
Block a user