This commit is contained in:
wujinliang
2026-09-21 19:36:37 +08:00
parent 8fbefcf657
commit b4403ab188
9 changed files with 62 additions and 9 deletions
+16 -5
View File
@@ -359,7 +359,7 @@ function mapFirstLegOrderRow(row: MerchantFirstLegOrderRow): FirstLegOrder {
const uniqueSkuNos = [...new Set(resolvedSkuNos)]
return {
id: String(row.orderId), orderNo: row.orderNo, referenceNo: row.referenceId ?? '', transportMode: null,
businessType: 'EXPORT', origin: '', destination: row.destinationWarehouseName ?? '', receivingWarehouseId: '',
businessType: 'EXPORT', fulfillmentType: row.fulfillmentType ?? 'STANDARD', lxCode: row.lxCode ?? '', origin: '', destination: row.destinationWarehouseName ?? '', receivingWarehouseId: '',
receivingWarehouseName: '', receivingWarehouseSnapshot: null, expectedDepartureDate: '', etd: '', eta: '',
shipperPartyId: '', shipperPartySnapshot: null, shipper: '', consigneePartyId: '', consigneePartySnapshot: null,
consignee: row.receivingCompanyName ?? '', expressCompanyName: row.expressCompany ?? '', trackingNumber: row.trackingNo ?? '',
@@ -542,9 +542,19 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
return mapped
}
async function loadLegacyDetail(id: string) {
async function loadLegacyDetail(id: string, listOrder?: FirstLegOrder) {
const detail = await getMerchantFirstLegOrder(id)
return upsertOrder(mapOrder(detail.order, warehouses.value, detail))
const mapped = mapOrder(detail.order, warehouses.value, detail)
// Older detail responses may omit newly added dropship fields. Keep the
// values already returned by the list row so editing a draft does not
// clear the persisted LX code in the form.
if (detail.order.fulfillmentType == null && listOrder?.fulfillmentType) {
mapped.fulfillmentType = listOrder.fulfillmentType
}
if (detail.order.lxCode == null && listOrder?.lxCode) {
mapped.lxCode = listOrder.lxCode
}
return upsertOrder(mapped)
}
async function loadUnifiedDetail(id: string) {
@@ -558,7 +568,8 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
}
async function loadDetail(id: string) {
return getById(id)?.status === 'DRAFT' ? loadLegacyDetail(id) : loadUnifiedDetail(id)
const listOrder = getById(id)
return listOrder?.status === 'DRAFT' ? loadLegacyDetail(id, listOrder) : loadUnifiedDetail(id)
}
async function loadWarehouseDetail(id: string) {
@@ -616,7 +627,7 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
}
async function loadDraftDetail(id: string) {
return loadLegacyDetail(id)
return loadLegacyDetail(id, getById(id))
}
return { orders, warehouses, loading, loadedFromApi, loadError, warehouseLoadError, draftLoadError, activeCount, pendingCount, getById, load, loadDetail, loadDraftDetail, loadWarehouseDetail, loadWarehouseType, saveDraft, saveDraftBatch, submitSaved, submit }