This commit is contained in:
2026-09-07 15:07:54 +08:00
parent 65962eb940
commit ee99854a39
9 changed files with 94 additions and 24 deletions
+2 -2
View File
@@ -1,11 +1,11 @@
import { overseasDownload, overseasRequest, overseasUpload } from '@/api/overseas.js'
import { normalizeReceivingCandidate, normalizeReceivingSession } from '@/api/receiving-adapter.js'
import { normalizeReceivingCandidate, normalizeReceivingSession, normalizeReceivingWarehouseProfile } from '@/api/receiving-adapter.js'
const RECEIVING_BASE = '/pda/v1/last-leg/receiving-containers'
const current = (suffix = '') => `${RECEIVING_BASE}/current${suffix}`
export const listReceivingCandidates = async () => (await overseasRequest('GET', `${RECEIVING_BASE}/candidates`)).map(normalizeReceivingCandidate)
export const getCurrentWarehouseProfile = () => overseasRequest('GET', `${RECEIVING_BASE}/warehouse-profile`)
export const getCurrentWarehouseProfile = async () => normalizeReceivingWarehouseProfile(await overseasRequest('GET', `${RECEIVING_BASE}/warehouse-profile`))
export const getReceivingContainer = async (containerNo) => normalizeReceivingSession(await overseasRequest('GET', `${RECEIVING_BASE}/${encodeURIComponent(containerNo)}`))
export const prepareReceivingContainer = async (containerNo, request) => normalizeReceivingSession(await overseasRequest('POST', `${RECEIVING_BASE}/${encodeURIComponent(containerNo)}/prepare`, request))
export const uploadCurrentUnloadPhoto = (filePath) => overseasUpload(current('/unload-photos/files'), filePath)
+38
View File
@@ -1,6 +1,40 @@
export const RECEIVING_PHOTO_ROLES = ['LICENSE_PLATE', 'CONTAINER_SEAL', 'DOOR_OPEN']
const number = (value) => Math.max(0, Number(value || 0))
const text = (value) => typeof value === 'string' ? value.trim() : ''
function warehouseContractError(message) {
return Object.assign(new Error(message), { code: 'RECEIVING_WAREHOUSE_CONTRACT_INVALID' })
}
export function normalizeReceivingWarehouseProfile(value = {}) {
const profile = {
warehouseId: value.warehouseId === null || value.warehouseId === undefined ? '' : String(value.warehouseId),
warehouseCode: text(value.warehouseCode),
warehouseName: text(value.warehouseName)
}
if (!profile.warehouseId || !profile.warehouseCode || !profile.warehouseName) {
throw warehouseContractError('当前 PDA 绑定仓信息不完整,请联系管理员检查账号绑定')
}
return profile
}
export function assertReceivingWarehouse(value, profile, label = '当前柜') {
const expectedCode = text(profile?.warehouseCode)
const expectedName = text(profile?.warehouseName)
const actualCode = text(value?.overseasWarehouseCode)
const actualName = text(value?.overseasWarehouseName)
if (!expectedCode || !expectedName) {
throw warehouseContractError('当前 PDA 绑定仓信息不完整,暂停接柜作业')
}
if (!actualCode || !actualName) {
throw warehouseContractError(`${label}缺少已分配海外接柜仓信息,暂停操作并请联系管理员`)
}
if (actualCode !== expectedCode) {
throw Object.assign(new Error(`${label}已分配至其他海外接柜仓,当前仓不可操作`), { code: 'RECEIVING_WAREHOUSE_MISMATCH' })
}
return value
}
export function normalizeReceivingInbound(value = {}) {
return {
@@ -17,6 +51,8 @@ export function normalizeReceivingCandidate(value = {}) {
...value,
sourceContainerBookingId: typeof value.sourceContainerBookingId === 'string' ? value.sourceContainerBookingId.trim() : '',
containerNo: String(value.containerNo || '').trim(),
overseasWarehouseCode: text(value.overseasWarehouseCode),
overseasWarehouseName: text(value.overseasWarehouseName),
plannedArrivalAt: typeof value.plannedArrivalAt === 'string' && value.plannedArrivalAt.trim() ? value.plannedArrivalAt.trim() : null,
totalOrderCount: number(value.totalOrderCount),
planCount: number(value.planCount),
@@ -42,6 +78,8 @@ export function normalizeReceivingSession(value) {
: []
return {
...value,
overseasWarehouseCode: text(value.overseasWarehouseCode),
overseasWarehouseName: text(value.overseasWarehouseName),
photos: RECEIVING_PHOTO_ROLES.map((role) => photos.find((photo) => photo?.role === role && photo?.fileId)).filter(Boolean),
totalPackages: number(value.totalPackages),
receivedPackages: number(value.receivedPackages),