From 4382351569bbd3ea69fe8ad4e4f8361c89cb1541 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Thu, 10 Sep 2026 16:03:01 +0800 Subject: [PATCH] fix: show pallets across warehouses by default --- .../pages/PalletsView.test.ts | 18 ++++++++++++++++-- .../overseas-warehouse/pages/PalletsView.vue | 14 +++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/modules/overseas-warehouse/pages/PalletsView.test.ts b/src/modules/overseas-warehouse/pages/PalletsView.test.ts index 146ba769..403ba86b 100644 --- a/src/modules/overseas-warehouse/pages/PalletsView.test.ts +++ b/src/modules/overseas-warehouse/pages/PalletsView.test.ts @@ -31,19 +31,33 @@ describe('PalletsView', () => { vi.mocked(updatePallet).mockReset().mockResolvedValue(null) }) - it('loads the all-warehouse pallet summary when the page opens', async () => { + it('loads the all-warehouse pallet list and summary when the page opens', async () => { vi.mocked(getPalletSummary).mockResolvedValueOnce({ totalCount: 250, idleCount: 100, occupiedCount: 98, scrappedCount: 52 }) const wrapper = mount(PalletsView, { attachTo: document.body, global: { plugins: [ElementPlus] } }) await flushPromises() - expect(getPalletSummary).toHaveBeenCalledWith('', {}) + expect(listPallets).toHaveBeenCalledWith('', { page: 1, size: 10, keyword: undefined, palletType: undefined, status: undefined }) + expect(getPalletSummary).toHaveBeenCalledWith('', { page: 1, size: 10, keyword: undefined, palletType: undefined, status: undefined }) + expect(wrapper.get('[aria-label="托盘管理列表"]').text()).toContain('PLT-1') + expect(wrapper.get('[aria-label="托盘管理列表"]').text()).not.toContain('请先选择仓库后查询') expect(wrapper.get('[aria-label="海外托盘数量概览"]').text()).toContain('托盘总数250') expect(wrapper.get('[aria-label="海外托盘数量概览"]').text()).toContain('闲置托盘100') expect(wrapper.get('[aria-label="海外托盘数量概览"]').text()).toContain('占用托盘98') expect(wrapper.get('[aria-label="海外托盘数量概览"]').text()).toContain('已报废52') }) + it('reloads all warehouses when the filters are reset', async () => { + const wrapper = mount(PalletsView, { attachTo: document.body, global: { plugins: [ElementPlus] } }) + await flushPromises() + vi.mocked(listPallets).mockClear() + + wrapper.findComponent(QueryToolbar).vm.$emit('reset', { warehouseId: '', code: '', type: '', status: '' }) + await flushPromises() + + expect(listPallets).toHaveBeenCalledWith('', { page: 1, size: 10, keyword: undefined, palletType: undefined, status: undefined }) + }) + it('loads the current detail version and keeps the edit open on a conflict', async () => { vi.mocked(updatePallet).mockRejectedValueOnce(Object.assign(new Error('version conflict'), { code: 'A0409' })) const wrapper = mount(PalletsView, { attachTo: document.body, global: { plugins: [ElementPlus] } }) diff --git a/src/modules/overseas-warehouse/pages/PalletsView.vue b/src/modules/overseas-warehouse/pages/PalletsView.vue index 9120d74c..1a51ba69 100644 --- a/src/modules/overseas-warehouse/pages/PalletsView.vue +++ b/src/modules/overseas-warehouse/pages/PalletsView.vue @@ -35,7 +35,7 @@ const total = ref(0) const summary = ref({ totalCount: 0, idleCount: 0, occupiedCount: 0, scrappedCount: 0 }) const filters = ref({ warehouseId: '', code: '', type: '', status: '' }) const fields = computed(() => [ - { key: 'warehouseId', type: 'select', label: '仓库', width: 240, placeholder: contextLoading.value ? '仓库加载中' : '请选择仓库', options: warehouses.value.map((item) => ({ label: `${item.warehouseName}(${item.warehouseCode})`, value: String(item.id) })), props: { filterable: true, clearable: true, disabled: contextLoading.value } }, + { key: 'warehouseId', type: 'select', label: '仓库', width: 240, placeholder: contextLoading.value ? '仓库加载中' : '全部仓库', options: warehouses.value.map((item) => ({ label: `${item.warehouseName}(${item.warehouseCode})`, value: String(item.id) })), props: { filterable: true, clearable: true, disabled: contextLoading.value } }, { key: 'code', type: 'input', label: '托盘编码', placeholder: '请输入托盘编码', width: 180 }, { key: 'type', type: 'select', label: '托盘类型', placeholder: '全部类型', width: 160, options: ['WOOD', 'PLASTIC', 'METAL', 'PAPER', 'FUMIGATION_FREE'].map((value) => ({ label: palletTypeLabel(value), value })) }, { key: 'status', type: 'select', label: '状态', placeholder: '全部状态', width: 140, options: [{ label: '闲置', value: 'IDLE' }, { label: '占用', value: 'OCCUPIED' }, { label: '已报废', value: 'SCRAPPED' }] }, @@ -63,14 +63,12 @@ async function loadWarehouses() { warehouses.value = []; filters.value.warehouseId = ''; rows.value = []; total.value = 0 contextLoading.value = true; loadError.value = null; loadErrorKind.value = 'context' try { - const [warehousePage, platformFbaWarehouses, overallSummary] = await Promise.all([ + const [warehousePage, platformFbaWarehouses] = await Promise.all([ listReceivingOverseasWarehouses(), listAllPlatformWarehouses({ warehouseType: 'FBA', status: 'ACTIVE' }), - getPalletSummary('', {}), ]) warehouses.value = warehousePage.records fbaWarehouses.value = platformFbaWarehouses - summary.value = overallSummary } catch (error) { loadError.value = getApiErrorDetails(error, '海外仓列表加载失败,请重试') } finally { contextLoading.value = false } @@ -121,17 +119,19 @@ async function save() { } function search(model: QueryModel) { page.value = 1; void load(model) } +function resetSearch(model: QueryModel) { page.value = 1; void load(model) } function openDetail(source: object) { const row = source as PalletListItem; void router.push({ name: 'overseas-pallet-detail', params: { palletId: row.id }, query: { warehouseId: row.warehouseId } }) } -onMounted(loadWarehouses) +async function initialize() { await loadWarehouses(); if (!loadError.value) await load() } +onMounted(initialize)