fix(dispatch): synchronize loading evidence and review round validation
This commit is contained in:
@@ -13,7 +13,7 @@ function slotPath(no, slot) {
|
||||
return `${path(no)}/${slot}`
|
||||
}
|
||||
export function normalizeLoadingDocuments(value, no) {
|
||||
if (value?.dispatchNo !== no || !/^\d+$/.test(String(value.recordVersion ?? '')) || !Array.isArray(value.photos)
|
||||
if (value?.dispatchNo !== no || !/^\d+$/.test(String(value.recordVersion ?? '')) || !/^[1-9]\d*$/.test(String(value.reviewRound ?? '')) || !Array.isArray(value.photos)
|
||||
|| !['LOADING', 'AFTER_LOADING', 'DELIVERING', 'DELIVERED'].includes(value.stage)) throw new Error('装车资料与当前排车事实不一致')
|
||||
const files = new Set(), counts = {}
|
||||
for (const photo of value.photos) {
|
||||
@@ -24,6 +24,10 @@ export function normalizeLoadingDocuments(value, no) {
|
||||
return { ...value, editable: value.editable === true, complete: value.complete === true }
|
||||
}
|
||||
export async function getLoadingDocuments(no) { return normalizeLoadingDocuments(await overseasRequest('GET', path(no)), no) }
|
||||
export function uploadLoadingPhoto(no, slot, filePath, key) { return overseasUpload(`${slotPath(no, slot)}/uploads?idempotencyKey=${encodeURIComponent(key)}`, filePath) }
|
||||
export function uploadLoadingPhoto(no, slot, filePath, key, reviewRound) { return overseasUpload(`${slotPath(no, slot)}/uploads?idempotencyKey=${encodeURIComponent(key)}&reviewRound=${encodeURIComponent(reviewRound)}`, filePath) }
|
||||
export async function bindLoadingPhoto(no, slot, body) { return normalizeLoadingDocuments(await overseasRequest('PUT', slotPath(no, slot), body), no) }
|
||||
export function readLoadingPhoto(no, photo) { return overseasDownload(`${slotPath(no, photo.slot)}/files/${encodeURIComponent(photo.fileId)}/content`, { expectedContentTypePrefix: 'image/' }) }
|
||||
export function readLoadingPhoto(no, photo) {
|
||||
const pdf = photo.slot === 'LOADING_SCENE' && photo.contentType === 'application/pdf'
|
||||
if (!pdf && !['image/jpeg', 'image/png'].includes(photo.contentType)) throw new Error('装车资料格式无效')
|
||||
return overseasDownload(`${slotPath(no, photo.slot)}/files/${encodeURIComponent(photo.fileId)}/content`, { expectedContentTypePrefix: pdf ? 'application/pdf' : photo.contentType })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user