This commit is contained in:
2026-08-06 15:32:07 +08:00
parent e33d620d87
commit 9aa79bef6d
8 changed files with 101 additions and 22 deletions
@@ -48,6 +48,11 @@ test('declares the final C02 row and detail contract in the API adapter', () =>
assert.match(unifiedApiSource, /error\.status === 404 \|\| error\.code === 'A0404'/)
})
test('keeps unified order pagination valid when the store omits page and size', () => {
assert.match(unifiedApiSource, /const \{ page, size, \.\.\.filters \} = params/)
assert.match(unifiedApiSource, /params: \{ page: page \?\? 1, size: size \?\? 200, \.\.\.filters \}/)
})
test('keeps drafts on the legacy read path without assigning a unified main status', () => {
assert.match(storeSource, /getMerchantFirstLegOrders\(legacyQuery\(query, 'DRAFT'\)\)/)
assert.match(storeSource, /getById\(id\)\?\.status === 'DRAFT' \? loadLegacyDetail\(id\) : loadUnifiedDetail\(id\)/)
@@ -85,8 +90,7 @@ test('sends backend-required channel, customs, destination and cargo fields', ()
test('separates domestic receiving warehouses from public destinations', () => {
assert.match(apiSource, /warehouseType\?: MerchantWarehouseType/)
assert.match(apiSource, /params: \{ page: 1, size: 200, status: 'ACTIVE', \.\.\.params \}/)
assert.match(storeSource, /getMerchantWarehouses\(\{ warehouseType: warehouseType as MerchantWarehouseType, page, size: 200 \}\)/)
assert.match(storeSource, /while \(page <= pages\)/)
assert.match(storeSource, /loadAllWarehouseRecords\(warehouseType, getMerchantWarehouses\)/)
assert.match(storeSource, /loadWarehouseType\('DOMESTIC', true\)/)
assert.match(storeSource, /warehouse\.warehouseType !== 'DOMESTIC'/)
assert.match(storeSource, /item\.warehouseType === draft\.destinationType/)
+3 -11
View File
@@ -14,7 +14,6 @@ import {
type MerchantFirstLegOrder,
type MerchantFirstLegOrderDetail,
type MerchantWarehouse,
type MerchantWarehouseType,
} from '@/modules/first-leg/api/firstLeg'
import {
getMerchantUnifiedOrder,
@@ -29,6 +28,7 @@ import type { PlatformReceivingWarehouse, PlatformReceivingWarehouseSnapshot } f
import type { FirstLegPartySnapshot } from '@/modules/first-leg/data/firstLegParties'
import type { FirstLegOrder, FirstLegOrderDraft, FirstLegOrderTimelineItem } from '@/modules/first-leg/types/firstLegOrder'
import { canClientEditFirstLegOrder, getFirstLegStatusLabel } from '@/modules/first-leg/utils/firstLegOrder'
import { loadAllWarehouseRecords } from '@/modules/first-leg/utils/warehousePagination'
export type ClientWarehouseType = 'DOMESTIC' | 'FBA' | 'OVERSEAS'
export type ClientWarehouse = PlatformReceivingWarehouse & {
@@ -395,21 +395,13 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
function getById(id: string) { return orders.value.find((item) => item.id === id) }
async function loadWarehouseType(warehouseType: ClientWarehouseType, force = false) {
if (warehouseType === 'DOMESTIC' && force) warehouseLoadError.value = ''
if (!force && loadedWarehouseTypes.value.includes(warehouseType)) return
const pending = warehouseTypeRequests.get(warehouseType)
if (pending) return pending
const request = (async () => {
let page = 1
const records: MerchantWarehouse[] = []
let pages = 1
do {
const response = await getMerchantWarehouses({ warehouseType: warehouseType as MerchantWarehouseType, page, size: 200 })
records.push(...response.records)
pages = Number(response.pages) || page
page += 1
} while (page <= pages)
const records = await loadAllWarehouseRecords(warehouseType, getMerchantWarehouses)
return records
.filter((item) => item.status === 'ACTIVE' && item.warehouseType === warehouseType)
.map(mapWarehouse)