优化
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
# 海外合作仓类型契约缺口
|
||||
|
||||
四期原型把海外合作仓作为现有仓库主数据中的一种仓库类型,而不是独立库存领域。
|
||||
|
||||
- 建议类型码:`OVERSEAS_PARTNER`。
|
||||
- 当前状态:仅为前端与后端对齐用的建议值,尚未生效。
|
||||
- 当前 Warehouse Service 的 DTO、校验与 OpenAPI 只接受 `DOMESTIC`、`FBA`、`OVERSEAS`。
|
||||
- 在服务端正式接受并返回合作仓类型前,Admin 不得把合作仓按 `OVERSEAS` 创建或更新,也不新增一套重复的合作仓列表。
|
||||
- 合作仓列表和详情继续复用 `platform:warehouse:list`;未来创建、编辑、启停分别复用现有 `platform:warehouse:create`、`platform:warehouse:edit`、`platform:warehouse:status`。
|
||||
- 服务端契约补齐时需同步核对仓库 DTO、Controller、OpenAPI、初始化 SQL、导入模板及全部消费者。
|
||||
|
||||
@@ -110,6 +110,34 @@ describe('platform warehouse API', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('passes the confirmed overseas partner warehouse type through list and save contracts', async () => {
|
||||
vi.mocked(http.get).mockResolvedValue({
|
||||
code: '200',
|
||||
data: { records: [], page: 1, size: 20, total: 0, pages: 0 },
|
||||
})
|
||||
vi.mocked(http.post).mockResolvedValue({ code: '200', data: '19020' })
|
||||
const partnerPayload: SavePlatformWarehouseRequest = {
|
||||
...payload,
|
||||
warehouseCode: 'PARTNER-US-01',
|
||||
warehouseName: '洛杉矶合作仓',
|
||||
warehouseType: 'OVERSEAS_PARTNER',
|
||||
countryCode: 'US',
|
||||
timezone: 'UTC-8',
|
||||
address: { ...payload.address, countryCode: 'US', stateProvince: 'CA', city: 'Los Angeles' },
|
||||
}
|
||||
|
||||
await listPlatformWarehouses({ page: 1, size: 20, warehouseType: 'OVERSEAS_PARTNER' })
|
||||
await expect(createPlatformWarehouse(partnerPayload)).resolves.toBe('19020')
|
||||
|
||||
expect(http.get).toHaveBeenCalledWith('/platform/v1/warehouse-admin', {
|
||||
params: { page: 1, size: 20, warehouseType: 'OVERSEAS_PARTNER' },
|
||||
})
|
||||
expect(http.post).toHaveBeenCalledWith('/platform/v1/warehouse-admin', {
|
||||
...partnerPayload,
|
||||
tenantId: 0,
|
||||
})
|
||||
})
|
||||
|
||||
it('loads every warehouse page for complete resource selectors', async () => {
|
||||
const firstRecord = { id: '1', warehouseCode: 'ABE2', warehouseType: 'FBA' }
|
||||
const domesticRecord = { id: '201', warehouseCode: 'CN-YIWU-01', warehouseType: 'DOMESTIC' }
|
||||
|
||||
@@ -2,7 +2,7 @@ import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
|
||||
export type PlatformWarehouseStatus = 'ACTIVE' | 'INACTIVE'
|
||||
|
||||
export type WarehouseType = 'DOMESTIC' | 'FBA' | 'OVERSEAS'
|
||||
export type WarehouseType = 'DOMESTIC' | 'FBA' | 'OVERSEAS' | 'OVERSEAS_PARTNER'
|
||||
|
||||
export interface PlatformWarehouseResource {
|
||||
id: number | string
|
||||
|
||||
@@ -126,6 +126,20 @@ const fbaDetail: PlatformWarehouseDetailResource = {
|
||||
capabilities: [],
|
||||
}
|
||||
|
||||
const partnerWarehouse: PlatformWarehouseSummaryResource = {
|
||||
...fbaWarehouse,
|
||||
id: '19021',
|
||||
warehouseCode: 'PARTNER-US-01',
|
||||
warehouseName: '洛杉矶合作仓',
|
||||
warehouseType: 'OVERSEAS_PARTNER',
|
||||
}
|
||||
|
||||
const partnerDetail: PlatformWarehouseDetailResource = {
|
||||
warehouse: partnerWarehouse,
|
||||
addresses: [{ ...fbaAddress, id: '19022', warehouseId: '19021', stateProvince: 'CA', city: 'Los Angeles' }],
|
||||
capabilities: [],
|
||||
}
|
||||
|
||||
const detail: PlatformWarehouseDetailResource = {
|
||||
warehouse: domesticWarehouse,
|
||||
addresses: [domesticAddress],
|
||||
@@ -413,6 +427,69 @@ describe('WarehousesView', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('creates and filters the confirmed overseas partner warehouse type through the existing warehouse page', async () => {
|
||||
const wrapper = await mountView()
|
||||
|
||||
wrapper.findComponent(QueryToolbar).vm.$emit('search', {
|
||||
keyword: '',
|
||||
warehouseType: 'OVERSEAS_PARTNER',
|
||||
status: 'ACTIVE',
|
||||
})
|
||||
await flushPromises()
|
||||
expect(listPlatformWarehouses).toHaveBeenLastCalledWith({
|
||||
page: 1,
|
||||
size: 20,
|
||||
keyword: undefined,
|
||||
warehouseType: 'OVERSEAS_PARTNER',
|
||||
status: 'ACTIVE',
|
||||
})
|
||||
|
||||
wrapper.findComponent({ name: 'ElDropdown' }).vm.$emit('command', 'OVERSEAS_PARTNER')
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.warehouse-editor-dialog')?.textContent).toContain('新增海外仓合作仓')
|
||||
|
||||
const stateSelect = wrapper.findAllComponents({ name: 'ElSelect' })
|
||||
.find((select) => select.props('placeholder') === '请选择州')
|
||||
setField('input[placeholder="请输入仓库名称"]', '洛杉矶合作仓')
|
||||
stateSelect!.vm.$emit('update:modelValue', 'CA')
|
||||
stateSelect!.vm.$emit('change', 'CA')
|
||||
setField('input[placeholder="例如 Long Beach"]', 'Los Angeles')
|
||||
setField('textarea[placeholder="请输入街道、园区、楼栋及门牌信息"]', '100 Partner Ave')
|
||||
|
||||
const saveButton = [...document.querySelectorAll('button')].find((button) => button.textContent?.trim() === '确认新增')
|
||||
saveButton!.dispatchEvent(new MouseEvent('click', { bubbles: true }))
|
||||
await flushPromises()
|
||||
|
||||
expect(createPlatformWarehouse).toHaveBeenCalledWith(expect.objectContaining({
|
||||
warehouseCode: expect.stringMatching(/^PARTNER-WH-/),
|
||||
warehouseName: '洛杉矶合作仓',
|
||||
warehouseType: 'OVERSEAS_PARTNER',
|
||||
countryCode: 'US',
|
||||
timezone: 'UTC-8',
|
||||
address: expect.objectContaining({ stateProvince: 'CA', city: 'Los Angeles' }),
|
||||
}))
|
||||
})
|
||||
|
||||
it('edits an existing overseas partner warehouse without converting it to an ordinary overseas warehouse', async () => {
|
||||
vi.mocked(listPlatformWarehouses).mockResolvedValueOnce({ records: [partnerWarehouse], page: 1, size: 20, total: 1, pages: 1 })
|
||||
vi.mocked(getPlatformWarehouse).mockResolvedValueOnce(partnerDetail)
|
||||
const wrapper = await mountView()
|
||||
|
||||
await wrapper.find('.el-table__body-wrapper .table-actions button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.warehouse-editor-dialog')?.textContent).toContain('编辑海外仓合作仓')
|
||||
|
||||
const saveButton = [...document.querySelectorAll('button')].find((button) => button.textContent?.trim() === '保存修改')
|
||||
saveButton!.dispatchEvent(new MouseEvent('click', { bubbles: true }))
|
||||
await flushPromises()
|
||||
|
||||
expect(updatePlatformWarehouse).toHaveBeenCalledWith('19021', expect.objectContaining({
|
||||
warehouseCode: 'PARTNER-US-01',
|
||||
warehouseName: '洛杉矶合作仓',
|
||||
warehouseType: 'OVERSEAS_PARTNER',
|
||||
}))
|
||||
})
|
||||
|
||||
it('edits FBA warehouses with selectors for country, timezone and state', async () => {
|
||||
vi.mocked(listPlatformWarehouses).mockResolvedValueOnce({ records: [fbaWarehouse, domesticWarehouse], page: 1, size: 20, total: 2, pages: 1 })
|
||||
vi.mocked(getPlatformWarehouse).mockResolvedValueOnce(fbaDetail)
|
||||
|
||||
@@ -34,6 +34,7 @@ const warehouseTypeLabels: Record<WarehouseType, string> = {
|
||||
DOMESTIC: '国内收货仓',
|
||||
FBA: 'FBA 地址',
|
||||
OVERSEAS: '海外仓',
|
||||
OVERSEAS_PARTNER: '海外仓合作仓',
|
||||
}
|
||||
const timezoneOptions = [
|
||||
'UTC-12', 'UTC-11', 'UTC-10', 'UTC-9', 'UTC-8', 'UTC-7', 'UTC-6', 'UTC-5', 'UTC-4', 'UTC-3',
|
||||
@@ -145,6 +146,7 @@ const queryFields: QueryField[] = [
|
||||
{ label: warehouseTypeLabels.DOMESTIC, value: 'DOMESTIC' },
|
||||
{ label: warehouseTypeLabels.FBA, value: 'FBA' },
|
||||
{ label: warehouseTypeLabels.OVERSEAS, value: 'OVERSEAS' },
|
||||
{ label: warehouseTypeLabels.OVERSEAS_PARTNER, value: 'OVERSEAS_PARTNER' },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -188,7 +190,7 @@ type WarehouseForm = Omit<Warehouse, 'updatedAt'> & {
|
||||
}
|
||||
|
||||
function generatedCode(type: WarehouseType) {
|
||||
const prefix = type === 'DOMESTIC' ? 'CN' : type === 'FBA' ? 'FBA' : 'US'
|
||||
const prefix = type === 'DOMESTIC' ? 'CN' : type === 'FBA' ? 'FBA' : type === 'OVERSEAS_PARTNER' ? 'PARTNER' : 'US'
|
||||
return `${prefix}-WH-${Date.now().toString(36).slice(-7).toUpperCase()}`
|
||||
}
|
||||
|
||||
@@ -708,7 +710,7 @@ onMounted(() => void loadWarehouses())
|
||||
<el-button :disabled="!warehouseReady" @click="openImport"><FileUp :size="16" />导入仓库</el-button>
|
||||
<el-dropdown trigger="click" :disabled="!warehouseReady" @command="openCreate($event as WarehouseType)">
|
||||
<el-button type="primary" :disabled="!warehouseReady"><Plus :size="16" />新增仓库<ChevronDown :size="15" /></el-button>
|
||||
<template #dropdown><el-dropdown-menu><el-dropdown-item command="FBA"><FileSpreadsheet :size="15" />新增 FBA 地址</el-dropdown-item><el-dropdown-item command="DOMESTIC"><WarehouseIcon :size="15" />新增国内仓</el-dropdown-item><el-dropdown-item command="OVERSEAS"><MapPin :size="15" />新增海外仓</el-dropdown-item></el-dropdown-menu></template>
|
||||
<template #dropdown><el-dropdown-menu><el-dropdown-item command="FBA"><FileSpreadsheet :size="15" />新增 FBA 地址</el-dropdown-item><el-dropdown-item command="DOMESTIC"><WarehouseIcon :size="15" />新增国内仓</el-dropdown-item><el-dropdown-item command="OVERSEAS"><MapPin :size="15" />新增海外仓</el-dropdown-item><el-dropdown-item command="OVERSEAS_PARTNER"><MapPin :size="15" />新增海外仓合作仓</el-dropdown-item></el-dropdown-menu></template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user