- 登录响应支持 mustChangePassword 并强制跳转改密页 - 新增改密页面与全局路由守卫 - 完善 AUTH_002/SYS_429/VALID_00x 等错误提示
121 行
3.2 KiB
TypeScript
121 行
3.2 KiB
TypeScript
export function mapApiErrorMessage(
|
|
code: string,
|
|
details?: Record<string, unknown>,
|
|
fallbackMessage?: string,
|
|
) {
|
|
if (code === "AUTH_001") {
|
|
return "账号或密码错误,请检查后重试。";
|
|
}
|
|
|
|
if (code === "AUTH_002") {
|
|
const lockedUntil = typeof details?.lockedUntil === "string" ? details.lockedUntil : null;
|
|
if (lockedUntil) {
|
|
const until = new Date(lockedUntil);
|
|
if (!Number.isNaN(until.getTime())) {
|
|
return `账号已锁定至 ${until.toLocaleString()},请稍后重试。`;
|
|
}
|
|
}
|
|
return "账号已锁定,请稍后重试。";
|
|
}
|
|
|
|
if (code === "AUTH_003") {
|
|
return "账号已离职/禁用,请联系管理员。";
|
|
}
|
|
|
|
if (code === "AUTH_004") {
|
|
return "登录状态失效,请重新登录。";
|
|
}
|
|
|
|
if (code === "AUTH_005") {
|
|
return "登录状态已失效,请重新登录。";
|
|
}
|
|
|
|
if (code === "PERM_001") {
|
|
return "当前账号无权限执行该操作。";
|
|
}
|
|
|
|
if (code === "PERM_002") {
|
|
return "你不是当前任务处理人,无法执行该操作。";
|
|
}
|
|
|
|
if (code === "SYS_404") {
|
|
return "目标数据不存在或已被删除。";
|
|
}
|
|
|
|
if (code === "SYS_001") {
|
|
return "服务暂不可用,请稍后重试或联系管理员。";
|
|
}
|
|
|
|
if (code === "SYS_429") {
|
|
return "请求过于频繁,请稍后重试。";
|
|
}
|
|
|
|
if (code === "VALID_002") {
|
|
return "输入内容长度不足,请补充后再提交。";
|
|
}
|
|
|
|
if (code === "VALID_003") {
|
|
return "票据疑似重复,请核对后再上传或联系财务处理。";
|
|
}
|
|
|
|
if (code === "VALID_004") {
|
|
return "原始单据已审批通过/付款,当前操作不允许。";
|
|
}
|
|
|
|
if (code === "VALID_005") {
|
|
return "票据已绑定报销单,无需重复绑定。";
|
|
}
|
|
|
|
if (code === "VALID_006") {
|
|
return "OCR 重试次数已达上限,请稍后人工处理。";
|
|
}
|
|
|
|
if (code === "VALID_007") {
|
|
return "OCR 重试过于频繁,请稍后再试。";
|
|
}
|
|
|
|
if (code === "VALID_001") {
|
|
if (details?.payment === "already_paid_conflict") {
|
|
return "该报销单已支付且付款信息冲突,请刷新后确认。";
|
|
}
|
|
|
|
if (details?.status === "invalid_pay_status") {
|
|
return "当前状态不允许执行付款。";
|
|
}
|
|
|
|
if (details?.transfer === "chain_limit_exceeded") {
|
|
return "当前任务转审次数已达上限。";
|
|
}
|
|
|
|
if (details?.transfer === "same_assignee_not_allowed") {
|
|
return "不能将任务转审给自己。";
|
|
}
|
|
|
|
if (details?.toApproverId === "target_not_approver") {
|
|
return "目标人员不具备审批权限。";
|
|
}
|
|
|
|
if (details?.toApproverId === "invalid_target") {
|
|
return "目标审批人不存在或已停用。";
|
|
}
|
|
|
|
if (details?.task === "already_processed") {
|
|
return "该任务已被处理,请刷新列表。";
|
|
}
|
|
|
|
if (details?.invoice === "not_bound") {
|
|
return "该票据未绑定报销单,无法解绑。";
|
|
}
|
|
|
|
if (details?.reimbursement === "invalid_status_for_unbind") {
|
|
return "仅草稿/驳回状态的报销单允许解绑票据。";
|
|
}
|
|
|
|
if (details?.ocr === "disabled") {
|
|
return "当前环境未开启 OCR,请联系管理员或切换到 mock/tencent。";
|
|
}
|
|
}
|
|
|
|
return fallbackMessage || "请求失败,请稍后重试。";
|
|
}
|