| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- // ========== 工单业务公共字典 ==========
- // 数据源:/api/work-order/* (BusinessWorkOrderController)
- // 工单类型:1-故障维修 2-日常巡检 3-设备保养
- export const ORDER_TYPE_MAP = {
- 1: { text: '故障维修', type: 'danger' },
- 2: { text: '日常巡检', type: 'primary' },
- 3: { text: '设备保养', type: 'warning' }
- }
- // 工单优先级:1-紧急 2-一般 3-低
- export const ORDER_LEVEL_MAP = {
- 1: { text: '紧急', type: 'danger' },
- 2: { text: '一般', type: 'warning' },
- 3: { text: '低', type: 'info' }
- }
- // 工单状态:1-待派单 2-待接单 3-已接单 4-处理中 5-待验收 6-已结案 7-已驳回 8-延期审核 9-已延期
- export const ORDER_STATUS_MAP = {
- 1: { text: '待派单', type: 'danger' },
- 2: { text: '待接单', type: 'warning' },
- 3: { text: '已接单', type: 'primary' },
- 4: { text: '处理中', type: 'warning' },
- 5: { text: '待验收', type: 'primary' },
- 6: { text: '已结案', type: 'success' },
- 7: { text: '已驳回', type: 'info' },
- 8: { text: '延期审核', type: 'warning' },
- 9: { text: '已延期', type: 'warning' }
- }
- // 业务简化为三态分组(统计卡用)
- export const ORDER_STATUS_GROUP = {
- pending: [1, 2, 3], // 待处理:待派单/待接单/已接单
- processing: [4, 8, 9], // 处理中:处理中/延期审核/已延期
- completed: [5, 6], // 已完成:待验收/已结案
- rejected: [7] // 已驳回
- }
- // 工单操作日志类型(后端 WorkOrderLog.operType 数字枚举)
- export const ORDER_LOG_TYPE_MAP = {
- 1: { text: '创建工单', type: 'primary' },
- 2: { text: '派单', type: 'warning' },
- 3: { text: '接单', type: 'success' },
- 4: { text: '开始维修', type: 'warning' },
- 5: { text: '提交验收', type: 'primary' },
- 6: { text: '验收通过', type: 'success' },
- 7: { text: '驳回工单', type: 'info' },
- 8: { text: '申请延期', type: 'warning' },
- 9: { text: '延期通过', type: 'warning' }
- }
- // ========== 辅助函数 ==========
- /** 工单状态文本 */
- export function orderStatusText(status) {
- return ORDER_STATUS_MAP[status]?.text || '未知'
- }
- /** 工单状态 Tag type */
- export function orderStatusType(status) {
- return ORDER_STATUS_MAP[status]?.type || 'info'
- }
- /** 工单类型文本 */
- export function orderTypeText(type) {
- return ORDER_TYPE_MAP[type]?.text || '未知'
- }
- /** 工单类型 Tag type */
- export function orderTypeTagType(type) {
- return ORDER_TYPE_MAP[type]?.type || 'info'
- }
- /** 优先级文本 */
- export function orderLevelText(level) {
- return ORDER_LEVEL_MAP[level]?.text || '-'
- }
- /** 优先级 Tag type */
- export function orderLevelType(level) {
- return ORDER_LEVEL_MAP[level]?.type || 'info'
- }
- /** 是否属于某状态分组 */
- export function inStatusGroup(order, groupName) {
- const list = ORDER_STATUS_GROUP[groupName] || []
- return list.includes(Number(order?.orderStatus))
- }
- /** 是否允许该操作(状态机与后端 BusinessWorkOrderServiceImpl 对齐)
- * 流程:1待派单 →2待接单 →3已接单 →4处理中 →5待验收 →6已结案
- * 动作:派单(1) → 核查(2/3) → 处理(3/4) → 提交验收(4) → 验收通过(5);任意非终态可取消(→7)
- */
- export const canOperate = {
- /** 待派单可派单 */
- dispatch: (o) => Number(o?.orderStatus) === 1,
- /** 待接单/已接单可核查 */
- verify: (o) => [2, 3].includes(Number(o?.orderStatus)),
- /** 已接单/处理中可处理 */
- process: (o) => [3, 4].includes(Number(o?.orderStatus)),
- /** 处理中可提交验收 */
- complete: (o) => Number(o?.orderStatus) === 4,
- /** 待验收可验收通过/结案 */
- close: (o) => Number(o?.orderStatus) === 5,
- /** 可取消:未结案/未驳回 */
- cancel: (o) => ![6, 7].includes(Number(o?.orderStatus))
- }
- /** 工单操作日志文本 */
- export function orderLogText(type) {
- return ORDER_LOG_TYPE_MAP[type]?.text || type || '操作'
- }
- /** 工单操作日志 Tag type */
- export function orderLogType(type) {
- return ORDER_LOG_TYPE_MAP[type]?.type || 'info'
- }
- /** 时间兜底显示 */
- export function timeText(t) {
- return t || '-'
- }
|