Files
cn-rdms-web/src/constants/status-tag.ts
dk 9a5845708d feat(我的绩效): 开发我的绩效功能。
fix(加班申请、工作报告): 重构加班申请在审批时的样式,工作报告在新增时的对话框、报告详情页的样式。
2026-06-21 18:22:44 +08:00

125 lines
2.9 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.

/**
* 业务对象状态颜色ElTag type集中配置
*
* 各业务域的 statusCode → ElTag type 在此统一维护,避免散落在各业务模块。
* 未来若后端状态字典返回颜色字段,可在调用方优先取后端值,缺失时回退此映射。
*/
export type StatusTagType = 'primary' | 'success' | 'warning' | 'info' | 'danger';
export type StatusDomain =
| 'projectExecution'
| 'projectTask'
| 'executionAssignee'
| 'taskAssigneeMember'
| 'project'
| 'product'
| 'productRequirement'
| 'projectRequirement'
| 'workOrder'
| 'workReport'
| 'performanceSheet'
| 'personalItem'
| 'overtimeApplication';
const statusTagTypeRegistry: Record<StatusDomain, Record<string, StatusTagType>> = {
// 项目-执行
projectExecution: {
pending: 'info',
active: 'primary',
paused: 'warning',
completed: 'success',
cancelled: 'danger'
},
// 项目-任务
projectTask: {
pending: 'info',
active: 'primary',
paused: 'warning',
completed: 'success',
cancelled: 'danger'
},
// 执行协办人变更事件
executionAssignee: {
join: 'success',
inactive: 'danger',
owner_transfer_in: 'warning',
owner_transfer_out: 'warning'
},
// 任务协办人变更事件
taskAssigneeMember: {
join: 'success',
inactive: 'danger'
},
// 项目(待补全)
project: {},
// 产品(待补全)
product: {},
// 产品需求
productRequirement: {
pending_claim: 'info',
pending_review: 'info',
pending_dispatch: 'primary',
reviewed: 'success',
review_rejected: 'danger',
implementing: 'primary',
accepted: 'success',
closed: 'danger',
rejected: 'danger',
cancelled: 'danger'
},
// 项目需求
projectRequirement: {
pending_claim: 'info',
pending_review: 'info',
reviewed: 'success',
review_rejected: 'danger',
implementing: 'primary',
accepted: 'success',
closed: 'danger',
rejected: 'danger',
cancelled: 'danger'
},
// 工单(待补全)
workOrder: {},
// 工作报告
workReport: {
draft: 'info',
pending_approval: 'warning',
approved: 'success',
rejected: 'danger'
},
// 绩效表
performanceSheet: {
draft: 'info',
sent: 'warning',
confirmed: 'success',
rejected: 'danger'
},
// 个人事项
personalItem: {
pending: 'info',
active: 'primary',
completed: 'success',
cancelled: 'danger'
},
// 加班申请
overtimeApplication: {
pending: 'warning',
approved: 'success',
rejected: 'danger'
}
};
export function getStatusTagType(domain: StatusDomain, statusCode: string | null | undefined): StatusTagType {
if (!statusCode) {
return 'info';
}
return statusTagTypeRegistry[domain]?.[statusCode] || 'info';
}
export function getPersonalItemStatusTagType(statusCode: string | null | undefined) {
return getStatusTagType('personalItem', statusCode);
}