提交
This commit is contained in:
1 parent
7e9155fef1
commit
2fd826dbe1
80 files changed
+32546
-36145
No files matched your search
@@ -1,13 +1,7 @@
|
||||
import { fetchAttachmentDownloadUrl } from '@/api/business'
|
||||
import { attachmentFullUrl } from '@/composables/useAttachmentActions'
|
||||
|
||||
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
|
||||
export function attachmentFullUrl(url: string) {
|
||||
const u = String(url || '').trim()
|
||||
if (!u) return ''
|
||||
if (/^https?:\/\//i.test(u)) return u
|
||||
return minioBaseUrl ? `${minioBaseUrl}/${u.replace(/^\//, '')}` : u
|
||||
}
|
||||
export { attachmentFullUrl }
|
||||
|
||||
export function sanitizeZipPathSegment(value: string, fallback = '未命名') {
|
||||
const cleaned = String(value || '')
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { mapWorkOrderTasksToSetItems } from './production-task-set'
|
||||
import {
|
||||
mapWorkOrderTasksToSetItems,
|
||||
revertTaskNamePlaceholders,
|
||||
resolveWorkOrderLabStorageCode,
|
||||
LAB_STORAGE_CODE_PLACEHOLDER
|
||||
} from './production-task-set'
|
||||
|
||||
describe('mapWorkOrderTasksToSetItems', () => {
|
||||
it('skips empty names and keeps route/description/remark', () => {
|
||||
@@ -28,3 +33,36 @@ describe('mapWorkOrderTasksToSetItems', () => {
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('revertTaskNamePlaceholders', () => {
|
||||
it('replaces lab storage code with placeholder', () => {
|
||||
assert.equal(
|
||||
revertTaskNamePlaceholders('LS001样本处理', 'LS001'),
|
||||
`${LAB_STORAGE_CODE_PLACEHOLDER}样本处理`
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps name when code empty', () => {
|
||||
assert.equal(revertTaskNamePlaceholders('LS001样本处理', ''), 'LS001样本处理')
|
||||
})
|
||||
})
|
||||
|
||||
describe('mapWorkOrderTasksToSetItems with labStorageCode', () => {
|
||||
it('reverts names when mapping', () => {
|
||||
const { items } = mapWorkOrderTasksToSetItems(
|
||||
[{ taskName: 'LS001分离', routeId: 'r1', routeName: 'A' }],
|
||||
{ labStorageCode: 'LS001' }
|
||||
)
|
||||
assert.equal(items[0].taskName, `${LAB_STORAGE_CODE_PLACEHOLDER}分离`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('resolveWorkOrderLabStorageCode', () => {
|
||||
it('prefers row field then reception', () => {
|
||||
assert.equal(resolveWorkOrderLabStorageCode({ labStorageCode: 'A' }), 'A')
|
||||
assert.equal(
|
||||
resolveWorkOrderLabStorageCode({ reception: { labStorageCode: 'B' } }),
|
||||
'B'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,3 +1,5 @@
|
||||
export const LAB_STORAGE_CODE_PLACEHOLDER = '{lab_storage_code}'
|
||||
|
||||
export type ProductionTaskSetItemPreview = {
|
||||
taskName: string
|
||||
routeId: string
|
||||
@@ -6,10 +8,24 @@ export type ProductionTaskSetItemPreview = {
|
||||
remark: string
|
||||
}
|
||||
|
||||
export function mapWorkOrderTasksToSetItems(tasks: Record<string, any>[] | undefined): {
|
||||
export function revertTaskNamePlaceholders(
|
||||
taskName: string,
|
||||
labStorageCode?: string | null
|
||||
): string {
|
||||
const text = String(taskName || '')
|
||||
const code = String(labStorageCode || '').trim()
|
||||
if (!code) return text
|
||||
return text.split(code).join(LAB_STORAGE_CODE_PLACEHOLDER)
|
||||
}
|
||||
|
||||
export function mapWorkOrderTasksToSetItems(
|
||||
tasks: Record<string, any>[] | undefined,
|
||||
options?: { labStorageCode?: string | null }
|
||||
): {
|
||||
items: ProductionTaskSetItemPreview[]
|
||||
skippedEmptyNameCount: number
|
||||
} {
|
||||
const labStorageCode = options?.labStorageCode
|
||||
const items: ProductionTaskSetItemPreview[] = []
|
||||
let skippedEmptyNameCount = 0
|
||||
for (const row of tasks || []) {
|
||||
@@ -19,7 +35,7 @@ export function mapWorkOrderTasksToSetItems(tasks: Record<string, any>[] | undef
|
||||
continue
|
||||
}
|
||||
items.push({
|
||||
taskName,
|
||||
taskName: revertTaskNamePlaceholders(taskName, labStorageCode),
|
||||
routeId: String(row.routeId || '').trim(),
|
||||
routeName: String(row.routeName || '').trim(),
|
||||
description: String(row.description || '').trim(),
|
||||
@@ -28,3 +44,14 @@ export function mapWorkOrderTasksToSetItems(tasks: Record<string, any>[] | undef
|
||||
}
|
||||
return { items, skippedEmptyNameCount }
|
||||
}
|
||||
|
||||
export function resolveWorkOrderLabStorageCode(
|
||||
row: Record<string, any> | null | undefined
|
||||
): string {
|
||||
if (!row) return ''
|
||||
const fromRow = String(row.labStorageCode || '').trim()
|
||||
if (fromRow) return fromRow
|
||||
return String(
|
||||
(row.reception as Record<string, any> | undefined)?.labStorageCode || ''
|
||||
).trim()
|
||||
}
|
||||
Reference in new issue
Block a user