workOrderDict.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // ========== 工单业务公共字典 ==========
  2. // 数据源:/api/work-order/* (BusinessWorkOrderController)
  3. // 工单类型:1-故障维修 2-日常巡检 3-设备保养
  4. export const ORDER_TYPE_MAP = {
  5. 1: { text: '故障维修', type: 'danger' },
  6. 2: { text: '日常巡检', type: 'primary' },
  7. 3: { text: '设备保养', type: 'warning' }
  8. }
  9. // 工单优先级:1-紧急 2-一般 3-低
  10. export const ORDER_LEVEL_MAP = {
  11. 1: { text: '紧急', type: 'danger' },
  12. 2: { text: '一般', type: 'warning' },
  13. 3: { text: '低', type: 'info' }
  14. }
  15. // 工单状态:1-待派单 2-待接单 3-已接单 4-处理中 5-待验收 6-已结案 7-已驳回 8-延期审核 9-已延期
  16. export const ORDER_STATUS_MAP = {
  17. 1: { text: '待派单', type: 'danger' },
  18. 2: { text: '待接单', type: 'warning' },
  19. 3: { text: '已接单', type: 'primary' },
  20. 4: { text: '处理中', type: 'warning' },
  21. 5: { text: '待验收', type: 'primary' },
  22. 6: { text: '已结案', type: 'success' },
  23. 7: { text: '已驳回', type: 'info' },
  24. 8: { text: '延期审核', type: 'warning' },
  25. 9: { text: '已延期', type: 'warning' }
  26. }
  27. // 业务简化为三态分组(统计卡用)
  28. export const ORDER_STATUS_GROUP = {
  29. pending: [1, 2, 3], // 待处理:待派单/待接单/已接单
  30. processing: [4, 8, 9], // 处理中:处理中/延期审核/已延期
  31. completed: [5, 6], // 已完成:待验收/已结案
  32. rejected: [7] // 已驳回
  33. }
  34. // 工单操作日志类型(后端 WorkOrderLog.operType 数字枚举)
  35. export const ORDER_LOG_TYPE_MAP = {
  36. 1: { text: '创建工单', type: 'primary' },
  37. 2: { text: '派单', type: 'warning' },
  38. 3: { text: '接单', type: 'success' },
  39. 4: { text: '开始维修', type: 'warning' },
  40. 5: { text: '提交验收', type: 'primary' },
  41. 6: { text: '验收通过', type: 'success' },
  42. 7: { text: '驳回工单', type: 'info' },
  43. 8: { text: '申请延期', type: 'warning' },
  44. 9: { text: '延期通过', type: 'warning' }
  45. }
  46. // ========== 辅助函数 ==========
  47. /** 工单状态文本 */
  48. export function orderStatusText(status) {
  49. return ORDER_STATUS_MAP[status]?.text || '未知'
  50. }
  51. /** 工单状态 Tag type */
  52. export function orderStatusType(status) {
  53. return ORDER_STATUS_MAP[status]?.type || 'info'
  54. }
  55. /** 工单类型文本 */
  56. export function orderTypeText(type) {
  57. return ORDER_TYPE_MAP[type]?.text || '未知'
  58. }
  59. /** 工单类型 Tag type */
  60. export function orderTypeTagType(type) {
  61. return ORDER_TYPE_MAP[type]?.type || 'info'
  62. }
  63. /** 优先级文本 */
  64. export function orderLevelText(level) {
  65. return ORDER_LEVEL_MAP[level]?.text || '-'
  66. }
  67. /** 优先级 Tag type */
  68. export function orderLevelType(level) {
  69. return ORDER_LEVEL_MAP[level]?.type || 'info'
  70. }
  71. /** 是否属于某状态分组 */
  72. export function inStatusGroup(order, groupName) {
  73. const list = ORDER_STATUS_GROUP[groupName] || []
  74. return list.includes(Number(order?.orderStatus))
  75. }
  76. /** 是否允许该操作(状态机与后端 BusinessWorkOrderServiceImpl 对齐)
  77. * 流程:1待派单 →2待接单 →3已接单 →4处理中 →5待验收 →6已结案
  78. * 动作:派单(1) → 核查(2/3) → 处理(3/4) → 提交验收(4) → 验收通过(5);任意非终态可取消(→7)
  79. */
  80. export const canOperate = {
  81. /** 待派单可派单 */
  82. dispatch: (o) => Number(o?.orderStatus) === 1,
  83. /** 待接单/已接单可核查 */
  84. verify: (o) => [2, 3].includes(Number(o?.orderStatus)),
  85. /** 已接单/处理中可处理 */
  86. process: (o) => [3, 4].includes(Number(o?.orderStatus)),
  87. /** 处理中可提交验收 */
  88. complete: (o) => Number(o?.orderStatus) === 4,
  89. /** 待验收可验收通过/结案 */
  90. close: (o) => Number(o?.orderStatus) === 5,
  91. /** 可取消:未结案/未驳回 */
  92. cancel: (o) => ![6, 7].includes(Number(o?.orderStatus))
  93. }
  94. /** 工单操作日志文本 */
  95. export function orderLogText(type) {
  96. return ORDER_LOG_TYPE_MAP[type]?.text || type || '操作'
  97. }
  98. /** 工单操作日志 Tag type */
  99. export function orderLogType(type) {
  100. return ORDER_LOG_TYPE_MAP[type]?.type || 'info'
  101. }
  102. /** 时间兜底显示 */
  103. export function timeText(t) {
  104. return t || '-'
  105. }