Files
hzdyjs/web/src/constants/workflow.ts
T
2025-11-14 00:49:57 +08:00

56 lines
1.9 KiB
TypeScript

/**
* 工作流状态常量定义
* 用于统一管理工作流状态的映射关系
*/
// 工作流状态枚举
export const WORKFLOW_STATUS = {
CANCEL: 'cancel', // 已撤销
DRAFT: 'draft', // 草稿
WAITING: 'waiting', // 待审核
FINISH: 'finish', // 已完成
INVALID: 'invalid', // 已作废
BACK: 'back', // 已退回
TERMINATION: 'termination' // 已终止
} as const;
// 工作流状态文本映射
export const WORKFLOW_STATUS_TEXT = {
[WORKFLOW_STATUS.CANCEL]: '已撤销',
[WORKFLOW_STATUS.DRAFT]: '草稿',
[WORKFLOW_STATUS.WAITING]: '待审核',
[WORKFLOW_STATUS.FINISH]: '已完成',
[WORKFLOW_STATUS.INVALID]: '已作废',
[WORKFLOW_STATUS.BACK]: '已退回',
[WORKFLOW_STATUS.TERMINATION]: '已终止'
} as const;
// 工作流状态标签类型映射
export const WORKFLOW_STATUS_TAG_TYPE = {
[WORKFLOW_STATUS.CANCEL]: 'info', // 已撤销 - 灰色
[WORKFLOW_STATUS.DRAFT]: 'info', // 草稿 - 灰色
[WORKFLOW_STATUS.WAITING]: 'warning', // 待审核 - 橙色
[WORKFLOW_STATUS.FINISH]: 'success', // 已完成 - 绿色
[WORKFLOW_STATUS.INVALID]: 'danger', // 已作废 - 红色
[WORKFLOW_STATUS.BACK]: 'danger', // 已退回 - 红色
[WORKFLOW_STATUS.TERMINATION]: 'primary' // 已终止 - 蓝色
} as const;
/**
* 获取工作流状态标签类型
* @param status 工作流状态
* @returns 标签类型
*/
export const getWorkflowStatusTagType = (status: string): 'success' | 'warning' | 'danger' | 'info' | 'primary' => {
return WORKFLOW_STATUS_TAG_TYPE[status as keyof typeof WORKFLOW_STATUS_TAG_TYPE] || 'info';
};
/**
* 获取工作流状态文本
* @param status 工作流状态
* @returns 状态文本
*/
export const getWorkflowStatusText = (status: string): string => {
return WORKFLOW_STATUS_TEXT[status as keyof typeof WORKFLOW_STATUS_TEXT] || status;
};