This commit is contained in:
2026-08-20 09:10:36 +08:00
parent 033b5df6b6
commit 508f76924e
58 changed files with 1790 additions and 628 deletions
@@ -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>