export const formatDate = (value?: string | Date | null): string => { if (!value) return '-' const date = value instanceof Date ? value : new Date(value) if (Number.isNaN(date.getTime())) return '-' const year = date.getFullYear() const month = String(date.getMonth() + 1).padStart(2, '0') const day = String(date.getDate()).padStart(2, '0') return `${year}-${month}-${day}` } export const formatDateTime = (value?: string | Date | null): string => { if (!value) return '-' const date = value instanceof Date ? value : new Date(value) if (Number.isNaN(date.getTime())) return '-' const hours = String(date.getHours()).padStart(2, '0') const minutes = String(date.getMinutes()).padStart(2, '0') return `${formatDate(date)} ${hours}:${minutes}` } export const formatMoney = (value?: number | null): string => `¥${(Number(value) || 0).toFixed(2)}` export const shortId = (value?: string | null): string => (value ? value.slice(-6) : '-') export const today = (): string => formatDate(new Date()) export const STATUS_LABELS: Record = { pending: '待确认', confirmed: '已确认', in_progress: '服务中', completed: '已完成', cancelled: '已取消', } export const STATUS_VARIANTS: Record = { pending: 'warning', confirmed: 'info', in_progress: 'primary', completed: 'success', cancelled: 'secondary', } export const CANCEL_LABELS: Record = { none: '未取消', requested: '取消申请', cancelled: '已取消', } export const CANCEL_VARIANTS: Record = { none: 'secondary', requested: 'danger', cancelled: 'dark', } export const PAYMENT_LABELS: Record = { unpaid: '未支付', partial: '部分支付', paid: '已支付', refunding: '退款中', refunded: '已退款', } export const PAYMENT_VARIANTS: Record = { unpaid: 'secondary', partial: 'warning', paid: 'success', refunding: 'danger', refunded: 'info', } export const CHANNEL_LABELS: Record = { online_wechat: '线上微信', offline: '线下支付', } export const METHOD_LABELS: Record = { '': '未记录', online_wechat: '微信支付', offline_cash: '线下现金', offline_transfer: '线下转账', } export const ROLE_LABELS: Record = { attendant: '陪诊师', nurse: '护士', doctor: '医生', admin: '管理员', operator: '运营', other: '其他', } export const EMPLOYEE_STATUS_LABELS: Record = { active: '在职', inactive: '停用', resigned: '离职', suspended: '暂停', } export const EMPLOYEE_STATUS_VARIANTS: Record = { active: 'success', inactive: 'secondary', resigned: 'dark', suspended: 'warning', } /** 陪诊师阶段:实习只看单,转正后才能接单 */ export const ATTENDANT_STAGE_LABELS: Record = { intern: '实习', certified: '正式', } export const ATTENDANT_STAGE_VARIANTS: Record = { intern: 'info', certified: 'success', } export const ATTENDANT_GRADE_LABELS: Record = { bronze: '青铜', silver: '白银', gold: '黄金', diamond: '钻石', } export const ACCOUNT_STATUS_LABELS: Record = { normal: '正常', lock: '已锁定', } export const SEX_LABELS: Record = { male: '男', female: '女', other: '其他', '': '-', }