start
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
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 ACCOUNT_STATUS_LABELS: Record<string, string> = {
|
||||
normal: '正常',
|
||||
lock: '已锁定',
|
||||
}
|
||||
|
||||
export const SEX_LABELS: Record<string, string> = {
|
||||
male: '男',
|
||||
female: '女',
|
||||
other: '其他',
|
||||
'': '-',
|
||||
}
|
||||
Reference in New Issue
Block a user