/** * 客户状态管理工具函数 */ // 客户状态类型定义 export type CustomerStatus = 'all' | 'pending' | 'signed' | 'cancelled'; // 客户状态配置 export const CUSTOMER_STATUS_CONFIG = { all: { label: '全部', color: '#666666', tagType: 'default' as const }, pending: { label: '跟进中', color: '#ff8800', tagType: 'warning' as const }, signed: { label: '已签约', color: '#52c41a', tagType: 'success' as const }, cancelled: { label: '已取消', color: '#ff4d4f', tagType: 'danger' as const } }; /** * 获取状态文本 */ export const getStatusText = (status: CustomerStatus): string => { return CUSTOMER_STATUS_CONFIG[status]?.label || ''; }; /** * 获取状态标签类型 */ export const getStatusTagType = (status: CustomerStatus) => { return CUSTOMER_STATUS_CONFIG[status]?.tagType || 'default'; }; /** * 获取状态颜色 */ export const getStatusColor = (status: CustomerStatus): string => { return CUSTOMER_STATUS_CONFIG[status]?.color || '#666666'; }; /** * 获取所有状态选项 */ export const getStatusOptions = () => { return Object.entries(CUSTOMER_STATUS_CONFIG).map(([value, config]) => ({ value: value as CustomerStatus, label: config.label })); }; /** * 临时函数:生成随机状态(实际项目中应该删除,从数据库获取真实状态) */ export const getRandomStatus = (): CustomerStatus => { const statuses: CustomerStatus[] = ['pending', 'signed', 'cancelled']; return statuses[Math.floor(Math.random() * statuses.length)]; };