优化
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user