61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
export function formatStatusWithRaw(status: string, labelMap: Record<string, string> = {}) {
|
|
const normalized = String(status || '').trim()
|
|
|
|
if (!normalized) {
|
|
return '-'
|
|
}
|
|
|
|
const key = normalized.toLowerCase()
|
|
const label = labelMap[key]
|
|
|
|
if (!label || label === normalized) {
|
|
return normalized
|
|
}
|
|
|
|
return `${label} (${normalized})`
|
|
}
|
|
|
|
export function formatAuditAction(action: string) {
|
|
const labelMap: Record<string, string> = {
|
|
admin_user_created: '创建后台用户',
|
|
admin_user_role_updated: '修改用户角色',
|
|
admin_user_status_updated: '修改用户状态',
|
|
admin_user_password_reset: '重置用户密码',
|
|
task_release_inventory: '释放任务库存',
|
|
task_release_inventory_binding: '释放任务库存绑定',
|
|
task_regenerate_claim_link: '重发领取链接',
|
|
task_closed: '关闭任务',
|
|
task_mark_manual_review: '转人工处理',
|
|
task_complete_manual_dispatch: '完成人工履约',
|
|
inventory_item_released: '释放库存项',
|
|
inventory_item_invalidated: '作废库存项',
|
|
webhook_replayed: '重放 Webhook',
|
|
platform_shop_config_updated: '更新店铺配置',
|
|
platform_fulfillment_config_updated: '更新履约配置',
|
|
}
|
|
|
|
return formatStatusWithRaw(action, labelMap)
|
|
}
|
|
|
|
export function formatAuditTargetType(targetType: string) {
|
|
const labelMap: Record<string, string> = {
|
|
admin_user: '后台用户',
|
|
task: '交付任务',
|
|
task_inventory_binding: '任务库存绑定',
|
|
inventory_item: '库存项',
|
|
webhook_event: 'Webhook 事件',
|
|
platform_config: '平台配置',
|
|
}
|
|
|
|
return formatStatusWithRaw(targetType, labelMap)
|
|
}
|
|
|
|
export function formatTaskEventType(eventType: string) {
|
|
const labelMap: Record<string, string> = {
|
|
manual_dispatch_completed: '人工履约已回写',
|
|
inventory_binding_released: '库存绑定已释放',
|
|
}
|
|
|
|
return formatStatusWithRaw(eventType, labelMap)
|
|
}
|