46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
export const ORDER_STATUS_LABELS: Record<string, string> = {
|
|
PENDING_PAY: '待付款',
|
|
PENDING_SHIP: '待发货',
|
|
OUT_WAREHOUSE: '已出库',
|
|
SHIPPING: '配送中',
|
|
PENDING_RECEIVE: '待收货',
|
|
COMPLETED: '已完成',
|
|
CANCELLED: '已取消',
|
|
REFUNDING: '退款中',
|
|
REFUNDED: '已退款',
|
|
};
|
|
|
|
export const STORE_STATUS_LABELS: Record<string, string> = {
|
|
OPEN: '营业中',
|
|
PAUSED: '暂停',
|
|
CLOSED: '已关闭',
|
|
};
|
|
|
|
export const CITY_STATUS_LABELS: Record<string, string> = {
|
|
PENDING: '待开城',
|
|
ACTIVE: '已开城',
|
|
PAUSED: '已暂停',
|
|
};
|
|
|
|
export const PRODUCT_STATUS_LABELS: Record<string, string> = {
|
|
DRAFT: '草稿',
|
|
ON_SALE: '在售',
|
|
OFF_SALE: '下架',
|
|
};
|
|
|
|
export function badgeClass(status: string): string {
|
|
if (['OPEN', 'ACTIVE', 'ON_SALE', 'COMPLETED', 'PAID', 'CONFIRMED'].includes(status)) return 'hq-badge--ok';
|
|
if (['PENDING', 'PENDING_PAY', 'PENDING_SHIP', 'DRAFT', 'PENDING_RECEIVE'].includes(status)) return 'hq-badge--warn';
|
|
if (['CLOSED', 'CANCELLED', 'REFUNDED', 'OFF_SALE', 'VOID'].includes(status)) return 'hq-badge--danger';
|
|
return 'hq-badge--info';
|
|
}
|
|
|
|
export function fmtTime(v?: string | null): string {
|
|
return v ? new Date(v).toLocaleString('zh-CN') : '—';
|
|
}
|
|
|
|
export function fmtMoney(v?: number | string | null): string {
|
|
const n = Number(v ?? 0);
|
|
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
}
|