import { OrganizationalLevel, PersonnelLevel, PersonnelStatus, ApprovalStatus, ApprovalRequestType } from '@/types'

export function getOrganizationalLevelName(level: OrganizationalLevel): string {
  switch (level) {
    case OrganizationalLevel.Division: return '师团'
    case OrganizationalLevel.Regiment: return '团'
    case OrganizationalLevel.Battalion: return '营'
    case OrganizationalLevel.Company: return '连'
    default: return ''
  }
}

export function getPersonnelLevelName(level: PersonnelLevel): string {
  switch (level) {
    case PersonnelLevel.Division: return '师级人才'
    case PersonnelLevel.Regiment: return '团级人才'
    case PersonnelLevel.Battalion: return '营级人才'
    case PersonnelLevel.Company: return '连级人才'
    default: return ''
  }
}

export function getPersonnelStatusName(status: PersonnelStatus): string {
  switch (status) {
    case PersonnelStatus.Pending: return '待审批'
    case PersonnelStatus.Approved: return '已批准'
    case PersonnelStatus.Rejected: return '已拒绝'
    default: return ''
  }
}

export function getApprovalStatusName(status: ApprovalStatus): string {
  switch (status) {
    case ApprovalStatus.Pending: return '待审批'
    case ApprovalStatus.Approved: return '已批准'
    case ApprovalStatus.Rejected: return '已拒绝'
    default: return ''
  }
}

export function getApprovalTypeName(type: ApprovalRequestType): string {
  switch (type) {
    case ApprovalRequestType.AllocationModification: return '配额修改'
    case ApprovalRequestType.ReportModification: return '上报修改'
    case ApprovalRequestType.PersonnelModification: return '人员修改'
    default: return ''
  }
}

export function formatDate(dateStr: string): string {
  return new Date(dateStr).toLocaleString('zh-CN')
}

export function formatNumber(num: number, decimals: number = 2): string {
  return num.toFixed(decimals)
}

export function formatPercentage(rate: number): string {
  return `${(rate * 100).toFixed(1)}%`
}
