production-labels.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import type { TagType } from '@/utils/status-tag-registry'
  2. /** 生产结论 cg=成功 sb=失败 */
  3. export function productionConclusionLabel(code?: string | null): string {
  4. const c = (code || '').trim()
  5. if (c === 'cg') return '成功'
  6. if (c === 'sb') return '失败'
  7. return c || '—'
  8. }
  9. export function productionConclusionTagType(code?: string | null): TagType | undefined {
  10. const c = (code || '').trim()
  11. if (c === 'cg') return 'success'
  12. if (c === 'sb') return 'danger'
  13. return undefined
  14. }
  15. /** 生产任务来源:inbound / temporary / outbound */
  16. export function productionOrderSourceTag(orderSource?: string | null): {
  17. label: string
  18. type: TagType
  19. } {
  20. const s = (orderSource || '').trim() || 'inbound'
  21. if (s === 'temporary') return { label: '临时', type: 'warning' }
  22. if (s === 'outbound') return { label: '出库', type: 'primary' }
  23. return { label: '入库', type: 'success' }
  24. }
  25. /** 生产任务类型(临时单看 orderSource,入库/出库看 taskType) */
  26. export function productionTaskTypeTag(
  27. taskType?: string | null,
  28. orderSource?: string | null
  29. ): { label: string; type: TagType } {
  30. if ((orderSource || '').trim() === 'temporary') {
  31. return { label: '临时生产单', type: 'warning' }
  32. }
  33. const t = (taskType || '').trim() || 'cell_storage'
  34. const map: Record<string, { label: string; type: TagType }> = {
  35. cell_storage: { label: '入库生产单', type: 'primary' },
  36. outbound: { label: '出库生产单', type: 'warning' }
  37. }
  38. return map[t] || { label: t, type: 'info' }
  39. }
  40. /** 按工单类型派生创建任务时的 task_type */
  41. export function productionTaskTypeForWorkOrder(workOrderType?: string | null): string {
  42. if (workOrderType === 'outbound') return 'outbound'
  43. return 'cell_storage'
  44. }