Files
zkxw/web-admin/src/utils/production-labels.ts
T
2026-05-26 21:27:48 +08:00

50 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { TagType } from '@/utils/status-tag-registry'
/** 生产结论 cg=成功 sb=失败 */
export function productionConclusionLabel(code?: string | null): string {
const c = (code || '').trim()
if (c === 'cg') return '成功'
if (c === 'sb') return '失败'
return c || '—'
}
export function productionConclusionTagType(code?: string | null): TagType | undefined {
const c = (code || '').trim()
if (c === 'cg') return 'success'
if (c === 'sb') return 'danger'
return undefined
}
/** 生产任务来源:inbound / temporary / outbound */
export function productionOrderSourceTag(orderSource?: string | null): {
label: string
type: TagType
} {
const s = (orderSource || '').trim() || 'inbound'
if (s === 'temporary') return { label: '临时', type: 'warning' }
if (s === 'outbound') return { label: '出库', type: 'primary' }
return { label: '入库', type: 'success' }
}
/** 生产任务类型(临时单看 orderSource,入库/出库看 taskType) */
export function productionTaskTypeTag(
taskType?: string | null,
orderSource?: string | null
): { label: string; type: TagType } {
if ((orderSource || '').trim() === 'temporary') {
return { label: '临时生产单', type: 'warning' }
}
const t = (taskType || '').trim() || 'cell_storage'
const map: Record<string, { label: string; type: TagType }> = {
cell_storage: { label: '入库生产单', type: 'primary' },
outbound: { label: '出库生产单', type: 'warning' }
}
return map[t] || { label: t, type: 'info' }
}
/** 按工单类型派生创建任务时的 task_type */
export function productionTaskTypeForWorkOrder(workOrderType?: string | null): string {
if (workOrderType === 'outbound') return 'outbound'
return 'cell_storage'
}