提交
This commit is contained in:
1 parent
038a60b09e
commit
3740a7dd80
45 files changed
+10945
-6192
No files matched your search
@@ -41,7 +41,17 @@ export type AttachmentZipExportResult = {
|
||||
const PREPARING_MAX = 5
|
||||
const DOWNLOADING_MAX = 85
|
||||
|
||||
function isInboundQcWorkOrder(row: QcWorkOrder) {
|
||||
return (row.workOrderType || 'inbound') === 'inbound'
|
||||
}
|
||||
|
||||
function workOrderFolderName(row: QcWorkOrder, used: Set<string>) {
|
||||
if (isInboundQcWorkOrder(row)) {
|
||||
const labCode = sanitizeZipPathSegment(row.labStorageCode || '', '未命名')
|
||||
const workOrderNo = sanitizeZipPathSegment(row.workOrderNo || row.id, '工单')
|
||||
const base = `入库${labCode}_${workOrderNo}`
|
||||
return ensureUniqueZipEntryName(base, used)
|
||||
}
|
||||
const parts = [sanitizeZipPathSegment(row.workOrderNo || row.id, '工单')]
|
||||
if (row.sampleCode) {
|
||||
parts.push(`样本${sanitizeZipPathSegment(row.sampleCode)}`)
|
||||
@@ -49,15 +59,34 @@ function workOrderFolderName(row: QcWorkOrder, used: Set<string>) {
|
||||
return ensureUniqueZipEntryName(parts.join('_'), used)
|
||||
}
|
||||
|
||||
function batchFolderName(batch: QcInspectionBatch, used: Set<string>) {
|
||||
const no = sanitizeZipPathSegment(batch.batchNo || '', '')
|
||||
function applyInboundLabStorageCodePrefix(code: string, workOrder: QcWorkOrder) {
|
||||
if (!isInboundQcWorkOrder(workOrder)) return code
|
||||
const raw = String(code || '').trim()
|
||||
const workOrderNo = String(workOrder.workOrderNo || '').trim()
|
||||
if (!raw || !workOrderNo || !raw.startsWith(workOrderNo)) return raw
|
||||
const labCode = sanitizeZipPathSegment(workOrder.labStorageCode || '', '未命名')
|
||||
return sanitizeZipPathSegment(`${labCode}${raw.slice(workOrderNo.length)}`, '')
|
||||
}
|
||||
|
||||
function batchFolderName(batch: QcInspectionBatch, workOrder: QcWorkOrder, used: Set<string>) {
|
||||
const no = sanitizeZipPathSegment(
|
||||
applyInboundLabStorageCodePrefix(batch.batchNo || '', workOrder),
|
||||
''
|
||||
)
|
||||
const name = sanitizeZipPathSegment(batch.batchName || '未命名批次')
|
||||
const base = no ? `${no}_${name}` : name || `批次${batch.orderNum ?? 1}`
|
||||
return ensureUniqueZipEntryName(base, used)
|
||||
}
|
||||
|
||||
function taskFolderName(task: { taskNo?: string; itemName?: string }, used: Set<string>) {
|
||||
const no = sanitizeZipPathSegment(task.taskNo || '', '')
|
||||
function taskFolderName(
|
||||
task: { taskNo?: string; itemName?: string },
|
||||
workOrder: QcWorkOrder,
|
||||
used: Set<string>
|
||||
) {
|
||||
const no = sanitizeZipPathSegment(
|
||||
applyInboundLabStorageCodePrefix(task.taskNo || '', workOrder),
|
||||
''
|
||||
)
|
||||
const name = sanitizeZipPathSegment(task.itemName || '未命名任务')
|
||||
const base = no ? `${no}_${name}` : name
|
||||
return ensureUniqueZipEntryName(base, used)
|
||||
@@ -76,7 +105,7 @@ export function buildQcWorkOrderZipEntries(
|
||||
const usedBatchFolders = new Set<string>()
|
||||
|
||||
for (const batch of batches) {
|
||||
const batchFolder = batchFolderName(batch, usedBatchFolders)
|
||||
const batchFolder = batchFolderName(batch, wo, usedBatchFolders)
|
||||
const tasks = batch.tasks || []
|
||||
const usedTaskFolders = new Set<string>()
|
||||
|
||||
@@ -84,7 +113,7 @@ export function buildQcWorkOrderZipEntries(
|
||||
const files = task.attachmentFiles?.filter((f) => String(f.fileUrl || '').trim()) || []
|
||||
if (!files.length) continue
|
||||
|
||||
const taskFolder = taskFolderName(task, usedTaskFolders)
|
||||
const taskFolder = taskFolderName(task, wo, usedTaskFolders)
|
||||
const usedFileNames = new Set<string>()
|
||||
const contextHint = [wo.workOrderNo, batch.batchName, task.itemName]
|
||||
.filter(Boolean)
|
||||
|
||||
Reference in new issue
Block a user