feat(admin): adapt channel booking and smart loading contracts
This commit is contained in:
@@ -103,7 +103,8 @@ describe('unified order workflow API contract', () => {
|
||||
unitWeightKg: '10.5', unitVolumeCbm: '0.25',
|
||||
}] })
|
||||
const container = await getContainerBooking('2086085512165634050')
|
||||
const candidates = await listSmartLoadingCandidates(container.warehouseId!)
|
||||
const candidates = await listSmartLoadingCandidates(container.id, container.warehouseId!)
|
||||
expect(http.get).toHaveBeenLastCalledWith('/platform/v1/first-leg/smart-loading/candidates', { params: { bookingId: container.id, warehouseId: container.warehouseId } })
|
||||
expect(container).toMatchObject({ id: '2086085512165634050', warehouseId: '2086085512165634051', capacityCbm: 68 })
|
||||
expect(candidates[0]).toMatchObject({
|
||||
accountId: '2086085512165634052', inboundId: '2086085512165634053',
|
||||
|
||||
@@ -339,9 +339,9 @@ export async function getContainerBooking(bookingId: string | number) {
|
||||
return normalizeContainer(unwrapApiResponse(response))
|
||||
}
|
||||
|
||||
export async function listSmartLoadingCandidates(warehouseId: string | number) {
|
||||
export async function listSmartLoadingCandidates(bookingId: string | number, warehouseId: string | number) {
|
||||
const response = await http.get<ApiEnvelope<Record<string, unknown>[]>, ApiEnvelope<Record<string, unknown>[]>>(
|
||||
`${smartLoadingBasePath}/candidates`, { params: { warehouseId: String(warehouseId) } },
|
||||
`${smartLoadingBasePath}/candidates`, { params: { bookingId: String(bookingId), warehouseId: String(warehouseId) } },
|
||||
)
|
||||
return unwrapApiResponse(response).map(normalizeCandidate)
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ async function load() {
|
||||
if (error instanceof ApiResponseError && ['A0404', 'NOT_FOUND'].includes(error.code)) plan.value = null
|
||||
else throw Object.assign(error instanceof Error ? error : new Error(details.message), { details })
|
||||
}
|
||||
candidates.value = nextContainer.warehouseId ? await listSmartLoadingCandidates(nextContainer.warehouseId) : []
|
||||
candidates.value = nextContainer.warehouseId ? await listSmartLoadingCandidates(nextContainer.id, nextContainer.warehouseId) : []
|
||||
} catch (error) {
|
||||
container.value = null
|
||||
plan.value = null
|
||||
@@ -185,7 +185,7 @@ async function runAction(name: string, operation: () => Promise<SmartLoadingPlan
|
||||
plan.value = await operation()
|
||||
ElMessage.success(success)
|
||||
emit('updated')
|
||||
if (container.value?.warehouseId) candidates.value = await listSmartLoadingCandidates(container.value.warehouseId)
|
||||
if (container.value?.warehouseId) candidates.value = await listSmartLoadingCandidates(container.value.id, container.value.warehouseId)
|
||||
return true
|
||||
} catch (error) {
|
||||
actionError.value = getApiErrorDetails(error, `${success}失败,请重试`)
|
||||
|
||||
Reference in New Issue
Block a user