This commit is contained in:
zlwu committed 2026-06-13 19:47:22 +08:00
1 parent e1d6de45a3
commit 5ad07c8cac
616 files changed
+181132 -35125

No files matched your search

+39 -4
View File
@@ -40,7 +40,7 @@ function createTagTypeGetter(registry: StatusRegistry) {
export const protocolStatus: StatusRegistry = {
dsx: { label: '待生效', tagType: 'info' },
sxz: { label: '生效中', tagType: 'success' },
sxz: { label: '生效中', tagType: 'primary' },
ygq: { label: '已过期', tagType: 'warning' },
yzf: { label: '已作废', tagType: 'danger' },
zky: { label: '转科研', tagType: 'primary' }
@@ -50,7 +50,7 @@ export const protocolStatusTagType = createTagTypeGetter(protocolStatus)
export const donationStatus: StatusRegistry = {
dsx: { label: '待生效', tagType: 'info' },
sxz: { label: '生效中', tagType: 'success' },
sxz: { label: '生效中', tagType: 'primary' },
ygq: { label: '已过期', tagType: 'warning' },
yzf: { label: '已作废', tagType: 'danger' },
zckc: { label: '转细胞存储', tagType: 'primary' }
@@ -213,7 +213,7 @@ export const agreementTypeTagType = createTagTypeGetter(agreementType)
export const agreementStatus: StatusRegistry = {
dsx: { label: '待生效', tagType: 'info' },
sxz: { label: '生效中', tagType: 'success' },
sxz: { label: '生效中', tagType: 'primary' },
yzf: { label: '已作废', tagType: 'danger' }
}
export const agreementStatusLabel = createLabelGetter(agreementStatus)
@@ -331,6 +331,25 @@ export const packType: StatusRegistry = {
export const packTypeLabel = createLabelGetter(packType)
export const packTypeTagType = createTagTypeGetter(packType)
/** 生产物料类型 */
export const productionMaterialType: StatusRegistry = {
reagent: { label: '试剂', tagType: 'primary' },
consumable: { label: '耗材', tagType: 'success' },
configured_reagent: { label: '配置试剂', tagType: 'warning' }
}
export const productionMaterialTypeLabel = createLabelGetter(productionMaterialType)
export const productionMaterialTypeTagType = createTagTypeGetter(productionMaterialType)
export const productionMaterialUsageSourceType: StatusRegistry = {
manual_in: { label: '手动入库', tagType: 'success' },
manual_out: { label: '手动出库', tagType: 'warning' },
manual_discard: { label: '手动废弃', tagType: 'danger' },
step_save: { label: '生产扣减', tagType: 'primary' },
prep_consume: { label: '配制消耗', tagType: 'info' },
prep_in: { label: '配制入库', tagType: 'success' }
}
export const productionMaterialUsageSourceTypeLabel = createLabelGetter(productionMaterialUsageSourceType)
export const productionMaterialUsageSourceTypeTagType = createTagTypeGetter(productionMaterialUsageSourceType)
// ══════════════════════════════════════════════════════════════════════════════
// 入库放行审核域
// ══════════════════════════════════════════════════════════════════════════════
@@ -366,7 +385,7 @@ export const channelServiceOrderStatus: StatusRegistry = {
dsx: { label: '待生效', tagType: 'info' },
dqr: { label: '待确认', tagType: 'warning' },
yqr: { label: '已确认', tagType: 'success' },
sxz: { label: '生效中', tagType: 'success' },
sxz: { label: '生效中', tagType: 'primary' },
tfqrz: { label: '退款确认中', tagType: 'danger' },
ytf: { label: '已退款', tagType: 'info' },
yzf: { label: '已作废', tagType: 'info' }
@@ -581,6 +600,22 @@ export function productStatusTagType(status: string): string {
return map[status] || 'info'
}
// ========== 设备管理 - 设备状态 ==========
export const equipmentStatus: StatusRegistry = {
'1': { label: '正常', tagType: 'success' },
'0': { label: '异常', tagType: 'danger' }
}
export const equipmentStatusLabel = createLabelGetter(equipmentStatus)
export const equipmentStatusTagType = createTagTypeGetter(equipmentStatus)
// ========== 洁净服管理 - 洁净服状态 ==========
export const garmentStatus: StatusRegistry = {
zc: { label: '正常', tagType: 'success' },
yfq: { label: '已废弃', tagType: 'info' }
}
export const garmentStatusLabel = createLabelGetter(garmentStatus)
export const garmentStatusTagType = createTagTypeGetter(garmentStatus)
// ========== 细胞产品库 - 产品状态 ==========
export function cellProductStatusLabel(status: string): string {
const map: Record<string, string> = {
+102 -11
View File
@@ -5,6 +5,13 @@ import { buildTreePathLabelFromFlat } from '@/utils/tree-path'
export type StorageSlotSelectOption = { id: string; name: string }
export type LoadStorageSlotSelectOptions = {
/** 仅返回空格子(编辑时可配合 includeSlotIds 保留当前格) */
availableOnly?: boolean
/** 额外保留在选项中的格子 ID(如编辑态当前储物格) */
includeSlotIds?: string[]
}
export function getStorageFacilityOrderNum(item: Record<string, unknown>): number {
const raw = item?.orderNum ?? item?.order_num ?? item?.sortOrder ?? item?.sort_order ?? 0
const parsed = Number(raw)
@@ -24,6 +31,42 @@ export function parseStorageSlotCode(code: string): { row: number; col: number }
return { row: parseInt(match[2], 10), col: parseInt(match[3], 10) }
}
/** 从根到节点的 node_code 路径,用 `-` 连接 */
export function buildNodeCodePathFromFlat(
nodeId: string,
flatList: Record<string, unknown>[]
): string {
const byId = new Map<string, Record<string, unknown>>()
for (const item of flatList || []) {
const id = String(item?.id ?? '').trim()
if (id) byId.set(id, item)
}
const parts: string[] = []
let curId = String(nodeId ?? '').trim()
const visited = new Set<string>()
while (curId && curId !== '0' && !visited.has(curId)) {
visited.add(curId)
const node = byId.get(curId)
if (!node) break
const code = String(node.nodeCode ?? node.node_code ?? '').trim()
if (code) parts.unshift(code)
curId = String(node.parentId ?? node.parent_id ?? '').trim()
}
return parts.join('-')
}
/** 完整储物格编号:祖先 node_code + 本地 slot_code */
export function buildFullSlotCodeFromFlat(
facilityNodeId: string,
slotCode: string,
flatList: Record<string, unknown>[]
): string {
const path = buildNodeCodePathFromFlat(facilityNodeId, flatList)
const local = String(slotCode ?? '').trim()
if (path && local) return `${path}-${local}`
return local || path
}
/** 盒内格位:order_num → 行 → 列 → 编码 */
export function compareStorageFacilitySlots(
a: Record<string, unknown>,
@@ -49,6 +92,12 @@ export function sortStorageFacilitySlots<T extends Record<string, unknown>>(slot
return [...slots].sort(compareStorageFacilitySlots)
}
export function isStorageSlotAvailable(slot: Record<string, unknown>): boolean {
const status = String(slot.slotStatus ?? slot.slot_status ?? '')
const occupied = Number(slot.occupiedCount ?? slot.occupied_count ?? 0)
return status === '空' || occupied === 0
}
/**
* 按设施树顺序收集叶子节点(罐 → 层 → 盒…),同级按 order_num、名称排序。
*/
@@ -107,22 +156,38 @@ export function collectLeafFacilityNodesInTreeOrder(
export function mapSlotsToSelectOptions(
facilityNodeId: string,
facilities: Record<string, unknown>[],
slots: Record<string, unknown>[]
slots: Record<string, unknown>[],
opts?: LoadStorageSlotSelectOptions
): StorageSlotSelectOption[] {
const includeSet = new Set((opts?.includeSlotIds || []).map((id) => String(id).trim()).filter(Boolean))
const nodePath = buildTreePathLabelFromFlat(facilityNodeId, facilities, {
nameKey: 'nodeName'
})
return sortStorageFacilitySlots(slots).map((slot) => {
const id = String(slot.id ?? '').trim()
const code = String(slot.slotCode ?? slot.slot_code ?? '')
const name = nodePath && code ? `${nodePath} / ${code}` : code || nodePath
return { id, name }
})
return sortStorageFacilitySlots(slots)
.filter((slot) => {
const id = String(slot.id ?? '').trim()
if (includeSet.has(id)) return true
if (opts?.availableOnly) return isStorageSlotAvailable(slot)
return true
})
.map((slot) => {
const id = String(slot.id ?? '').trim()
const code = String(slot.slotCode ?? slot.slot_code ?? '')
const fullFromApi = String(slot.fullSlotCode ?? slot.full_slot_code ?? '').trim()
const fullCode =
fullFromApi || buildFullSlotCodeFromFlat(facilityNodeId, code, facilities)
const name = fullCode || code || nodePath
return { id, name }
})
}
export async function loadStorageSlotSelectOptions(
facilities: Record<string, unknown>[],
fetchStorageSlotList: (params: { facilityNodeId: string }) => Promise<unknown>
fetchStorageSlotList: (params: {
facilityNodeId: string
availableOnly?: boolean
}) => Promise<unknown>,
opts?: LoadStorageSlotSelectOptions
): Promise<StorageSlotSelectOption[]> {
const leafNodes = collectLeafFacilityNodesInTreeOrder(facilities)
if (!leafNodes.length) return []
@@ -130,15 +195,41 @@ export async function loadStorageSlotSelectOptions(
const results = await Promise.allSettled(
leafNodes.map(async (node) => {
const nodeId = String(node.id ?? '').trim()
const res: any = await fetchStorageSlotList({ facilityNodeId: nodeId })
const res: any = await fetchStorageSlotList({
facilityNodeId: nodeId,
availableOnly: opts?.availableOnly ? true : undefined
})
const slots = (res?.list || res || []) as Record<string, unknown>[]
return mapSlotsToSelectOptions(nodeId, facilities, slots)
return mapSlotsToSelectOptions(nodeId, facilities, slots, opts)
})
)
const options: StorageSlotSelectOption[] = []
const seen = new Set<string>()
results.forEach((r) => {
if (r.status === 'fulfilled') options.push(...r.value)
if (r.status === 'fulfilled') {
r.value.forEach((opt) => {
if (!seen.has(opt.id)) {
seen.add(opt.id)
options.push(opt)
}
})
}
})
return options
}
/** 校验表单内储物格不可重复(一格一物) */
export function validateUniqueStorageSlotIds(
slotIds: Array<string | undefined | null>,
message = '同一表单内不能选择重复的储物格,每份产品须使用不同储物格'
): boolean {
const seen = new Set<string>()
for (const raw of slotIds) {
const id = String(raw ?? '').trim()
if (!id) continue
if (seen.has(id)) return false
seen.add(id)
}
return true
}