This commit is contained in:
2026-10-08 20:16:19 +08:00
parent 9c70eab606
commit 115461683b
2 changed files with 27 additions and 5 deletions
@@ -7,9 +7,10 @@ import { UI_PREFERENCE_SCOPE, preferenceStorageKey } from '@/shared/utils/uiLayo
import { getReturnCarton, listReturnCartons, listReturnInventoryMovements, listReturnStock, listReturnPackingSources } from '../api/returnInventory' import { getReturnCarton, listReturnCartons, listReturnInventoryMovements, listReturnStock, listReturnPackingSources } from '../api/returnInventory'
import { listReturnPackingPlans } from '../api/relabelOrders' import { listReturnPackingPlans } from '../api/relabelOrders'
import ReturnInventoryManagementView from './ReturnInventoryManagementView.vue' import ReturnInventoryManagementView from './ReturnInventoryManagementView.vue'
import { listPlatformTenants } from '@/modules/iam'
vi.mock('@/modules/iam', () => ({ vi.mock('@/modules/iam', () => ({
listPlatformTenants: vi.fn().mockResolvedValue({ records: [{ id: 'customer-1', tenantName: '测试客户', status: 'ACTIVE' }] }), listPlatformTenants: vi.fn().mockResolvedValue({ records: [{ id: 'customer-1', tenantName: '测试客户', status: 'ACTIVE' }], page: 1, size: 200, total: 1, pages: 1 }),
listSharedReceivingOverseasWarehouseOptions: vi.fn().mockResolvedValue([{ id: 'warehouse-1', warehouseName: '测试仓库' }]), listSharedReceivingOverseasWarehouseOptions: vi.fn().mockResolvedValue([{ id: 'warehouse-1', warehouseName: '测试仓库' }]),
})) }))
vi.mock('../api/returnInventory', () => ({ vi.mock('../api/returnInventory', () => ({
@@ -52,6 +53,19 @@ afterEach(() => {
}) })
describe('ReturnInventoryManagementView shared list', () => { describe('ReturnInventoryManagementView shared list', () => {
it('includes customers from later server pages in the packing customer selector', async () => {
vi.mocked(listPlatformTenants)
.mockResolvedValueOnce({ records: [{ id: 'customer-1', tenantName: '柏悦物流demo2', status: 'ACTIVE' }], page: 1, size: 200, total: 201, pages: 2 } as Awaited<ReturnType<typeof listPlatformTenants>>)
.mockResolvedValueOnce({ records: [{ id: 'customer-2', tenantName: '柏悦物流', status: 'ACTIVE' }], page: 2, size: 200, total: 201, pages: 2 } as Awaited<ReturnType<typeof listPlatformTenants>>)
const wrapper = await mountView('inventory')
expect(listPlatformTenants).toHaveBeenNthCalledWith(1, { page: 1, size: 200, status: 'ACTIVE' })
expect(listPlatformTenants).toHaveBeenNthCalledWith(2, { page: 2, size: 200, status: 'ACTIVE' })
await wrapper.findAll('button').find(button => button.text().includes('创建合箱计划'))!.trigger('click')
await flushPromises()
const form = wrapper.findAllComponents({ name: 'ElForm' }).find(form => form.classes().includes('packing-form'))!
const options = form.getComponent({ name: 'ElSelect' }).findAllComponents({ name: 'ElOption' })
expect(options.map(option => option.props('label'))).toEqual(['柏悦物流demo2', '柏悦物流'])
})
it('finds boxes by contained SKU while retaining mixed-box contents and selected cartons', async () => { it('finds boxes by contained SKU while retaining mixed-box contents and selected cartons', async () => {
vi.mocked(listReturnPackingSources).mockResolvedValue({records:[ vi.mocked(listReturnPackingSources).mockResolvedValue({records:[
{cartonMark:'BOX-A',sourceUnitType:'BOX',items:[{skuCode:'SKU-APPLE',quantity:2},{skuCode:'SKU-OTHER',quantity:3}]}, {cartonMark:'BOX-A',sourceUnitType:'BOX',items:[{skuCode:'SKU-APPLE',quantity:2},{skuCode:'SKU-OTHER',quantity:3}]},
@@ -206,17 +206,25 @@ function warehouseName(warehouseId?: string) {
function statusLabel(status?: string) { function statusLabel(status?: string) {
return status === "AVAILABLE" ? "可用" : status === "MERGED" ? "已合箱" : "—"; return status === "AVAILABLE" ? "可用" : status === "MERGED" ? "已合箱" : "—";
} }
async function loadCustomerOptions() {
const records: PlatformTenantResource[] = [];
let page = 1;
while (true) {
const result = await listPlatformTenants({ page, size: 200, status: "ACTIVE" });
records.push(...result.records);
if (page >= result.pages || !result.records.length) return records;
page += 1;
}
}
async function loadOptions() { async function loadOptions() {
optionsLoading.value = true; optionsLoading.value = true;
try { try {
const [customerResult, warehouseResult] = await Promise.allSettled([ const [customerResult, warehouseResult] = await Promise.allSettled([
// 客户规模上限约 1,000,退货库存的客户下拉需要一次拿全量, loadCustomerOptions(),
// 否则只取第一页会漏掉较早创建的启用客户。
listPlatformTenants({ page: 1, size: 1000, status: "ACTIVE" }),
listSharedReceivingOverseasWarehouseOptions(), listSharedReceivingOverseasWarehouseOptions(),
]); ]);
if (customerResult.status === "fulfilled") if (customerResult.status === "fulfilled")
customers.value = customerResult.value.records; customers.value = customerResult.value;
else customers.value = []; else customers.value = [];
if (warehouseResult.status === "fulfilled") if (warehouseResult.status === "fulfilled")
warehouses.value = warehouseResult.value; warehouses.value = warehouseResult.value;