/** * 用户角色配置 */ import { UserRole } from '@/types/api' // 用户角色选项 export const USER_ROLE_OPTIONS = [ { label: '超级管理员', value: UserRole.SUPER_ADMIN, color: '#F56C6C' }, { label: '管理员', value: UserRole.ADMIN, color: '#E6A23C' }, { label: '代理商', value: UserRole.AGENT, color: '#409EFF' }, { label: '企业客户', value: UserRole.ENTERPRISE, color: '#67C23A' } ] // 用户角色映射 export const USER_ROLE_MAP = USER_ROLE_OPTIONS.reduce( (map, item) => { map[item.value] = item return map }, {} as Record ) // 获取用户角色标签 export function getUserRoleLabel(role: UserRole): string { return USER_ROLE_MAP[role]?.label || role } // 获取用户角色颜色 export function getUserRoleColor(role: UserRole): string { return USER_ROLE_MAP[role]?.color || '#909399' } // 账号状态选项 export const ACCOUNT_STATUS_OPTIONS = [ { label: '启用', value: 1, type: 'success' as const }, { label: '禁用', value: 0, type: 'danger' as const }, { label: '锁定', value: 2, type: 'warning' as const } ] // 获取账号状态标签 export function getAccountStatusLabel(status: number): string { const option = ACCOUNT_STATUS_OPTIONS.find((item) => item.value === status) return option?.label || '未知' } // 获取账号状态类型 export function getAccountStatusType(status: number) { const option = ACCOUNT_STATUS_OPTIONS.find((item) => item.value === status) return option?.type || 'info' }