diff --git a/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts b/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts index 3ca1f28f..e8230cab 100644 --- a/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts +++ b/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts @@ -245,6 +245,31 @@ describe('GlobalSmartLoadingView', () => { expect(listSmartLoadingCandidates).toHaveBeenLastCalledWith(dongguanContainer.id, dongguanContainer.warehouseId) }) + it('keeps the selected channel when the warehouse changes even if that warehouse has no matching container', async () => { + const dongguanOvertimeContainer = { + ...container, + id: '9007199254740998', + planId: '9007199254740999', + cabinetNo: 'CB-DG-MAX', + containerNo: 'MSCU-DG-MAX', + warehouseId: '18', + warehouseName: '东莞仓', + channelCode: 'MATSON_MAX_TRUCK', + channelName: '美森加班海卡', + } + vi.mocked(listContainers).mockResolvedValue({ records: [container, dongguanOvertimeContainer], page: 1, size: 100, total: 2, pages: 1 }) + const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } }) + await flushPromises() + + await (wrapper.vm as unknown as { selectWarehouse: (code: string) => Promise }).selectWarehouse('DONGGUAN') + await flushPromises() + + expect(wrapper.get('.channel-tabs [role="tab"][aria-selected="true"]').text()).toBe('美森正班') + expect(wrapper.findAll('.container-option')).toHaveLength(0) + expect(wrapper.text()).not.toContain('MSCU-DG-MAX') + expect(listSmartLoadingCandidates).toHaveBeenCalledTimes(1) + }) + it('filters candidates by an active name-only customer selector and accountId', () => { const source = readFileSync(resolve(process.cwd(), 'src/modules/container-loading/pages/GlobalSmartLoadingView.vue'), 'utf8') expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })") diff --git a/src/modules/container-loading/pages/GlobalSmartLoadingView.vue b/src/modules/container-loading/pages/GlobalSmartLoadingView.vue index 9a268b42..79c1e372 100644 --- a/src/modules/container-loading/pages/GlobalSmartLoadingView.vue +++ b/src/modules/container-loading/pages/GlobalSmartLoadingView.vue @@ -399,7 +399,6 @@ async function selectContainer(containerId: string) { async function selectWarehouse(warehouseCode: string) { if (activeWarehouseCode.value === warehouseCode) return activeWarehouseCode.value = warehouseCode - activeChannelCode.value = preferredChannelCode(warehouseCode) selectedContainerId.value = preferredContainerId() await loadSelectedData() }