feat(pda): support five loading photos per category and reconcile saves

This commit is contained in:
2026-10-26 17:12:38 +08:00
parent c2261bc655
commit 7749b33700
4 changed files with 120 additions and 31 deletions
+7 -3
View File
@@ -1,6 +1,9 @@
import { overseasRequest, overseasUpload, overseasDownload } from './overseas.js'
export const loadingPhotoSlots = ['LOADING_SCENE', 'LOADING_LIST', 'PRE_DEPARTURE_CHECK', 'DRIVER_LICENSE', 'RECEIPT']
// 保留既有五框标识以维持文件归属,界面按当前装车资料分类展示。
export const loadingPhotoLabels = { LOADING_SCENE: '司机驾驶证', LOADING_LIST: '车牌照片', PRE_DEPARTURE_CHECK: '装车完成', DRIVER_LICENSE: '封车照片', RECEIPT: 'BOL司机签字' }
export const loadingPhotoLimit = 5
const path = no => {
if (!no || typeof no !== 'string') throw new Error('请先打开排车任务')
return `/pda/v1/last-leg/dispatches/${encodeURIComponent(no)}/loading-documents`
@@ -12,10 +15,11 @@ function slotPath(no, slot) {
export function normalizeLoadingDocuments(value, no) {
if (value?.dispatchNo !== no || !/^\d+$/.test(String(value.recordVersion ?? '')) || !Array.isArray(value.photos)
|| !['LOADING', 'AFTER_LOADING', 'DELIVERING', 'DELIVERED'].includes(value.stage)) throw new Error('装车资料与当前排车事实不一致')
const slots = new Set()
const files = new Set(), counts = {}
for (const photo of value.photos) {
if (!loadingPhotoSlots.includes(photo.slot) || !photo.fileId || slots.has(photo.slot)) throw new Error('装车照片引用不完整或重复')
slots.add(photo.slot)
if (!loadingPhotoSlots.includes(photo.slot) || !photo.fileId || files.has(String(photo.fileId))) throw new Error('装车照片引用不完整或重复')
files.add(String(photo.fileId)); counts[photo.slot] = (counts[photo.slot] || 0) + 1
if (counts[photo.slot] > loadingPhotoLimit) throw new Error('每类装车照片最多5张')
}
return { ...value, editable: value.editable === true, complete: value.complete === true }
}