Files
web_escort_admin/src/utils/format.ts
T
lik 9f7ab62a06 feat(attendants): 支持陪诊师阶段与等级展示及转正调级
- 列表新增阶段/等级列,实习/正式与青铜~钻石及星级可见

- 新增阶段与等级弹窗,调用 /employee/:id/level 完成转正、调级与设星
2026-11-10 12:02:07 +08:00

134 lines
3.4 KiB
TypeScript

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<string, string> = {
pending: '待确认',
confirmed: '已确认',
in_progress: '服务中',
completed: '已完成',
cancelled: '已取消',
}
export const STATUS_VARIANTS: Record<string, string> = {
pending: 'warning',
confirmed: 'info',
in_progress: 'primary',
completed: 'success',
cancelled: 'secondary',
}
export const CANCEL_LABELS: Record<string, string> = {
none: '未取消',
requested: '取消申请',
cancelled: '已取消',
}
export const CANCEL_VARIANTS: Record<string, string> = {
none: 'secondary',
requested: 'danger',
cancelled: 'dark',
}
export const PAYMENT_LABELS: Record<string, string> = {
unpaid: '未支付',
partial: '部分支付',
paid: '已支付',
refunding: '退款中',
refunded: '已退款',
}
export const PAYMENT_VARIANTS: Record<string, string> = {
unpaid: 'secondary',
partial: 'warning',
paid: 'success',
refunding: 'danger',
refunded: 'info',
}
export const CHANNEL_LABELS: Record<string, string> = {
online_wechat: '线上微信',
offline: '线下支付',
}
export const METHOD_LABELS: Record<string, string> = {
'': '未记录',
online_wechat: '微信支付',
offline_cash: '线下现金',
offline_transfer: '线下转账',
}
export const ROLE_LABELS: Record<string, string> = {
attendant: '陪诊师',
nurse: '护士',
doctor: '医生',
admin: '管理员',
operator: '运营',
other: '其他',
}
export const EMPLOYEE_STATUS_LABELS: Record<string, string> = {
active: '在职',
inactive: '停用',
resigned: '离职',
suspended: '暂停',
}
export const EMPLOYEE_STATUS_VARIANTS: Record<string, string> = {
active: 'success',
inactive: 'secondary',
resigned: 'dark',
suspended: 'warning',
}
/** 陪诊师阶段:实习只看单,转正后才能接单 */
export const ATTENDANT_STAGE_LABELS: Record<string, string> = {
intern: '实习',
certified: '正式',
}
export const ATTENDANT_STAGE_VARIANTS: Record<string, string> = {
intern: 'info',
certified: 'success',
}
export const ATTENDANT_GRADE_LABELS: Record<string, string> = {
bronze: '青铜',
silver: '白银',
gold: '黄金',
diamond: '钻石',
}
export const ACCOUNT_STATUS_LABELS: Record<string, string> = {
normal: '正常',
lock: '已锁定',
}
export const SEX_LABELS: Record<string, string> = {
male: '男',
female: '女',
other: '其他',
'': '-',
}