文件
hyb-oa/client/src/lib/actionConfirm.ts
T

143 行
5.1 KiB
TypeScript
原始文件 Blame 文件历史

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
import type { ReactNode } from "react";
export type ActionConfirmKind =
| "submit"
| "precheck"
| "delete"
| "archive"
| "withdraw"
| "enable"
| "disable"
| "batchApprove"
| "batchReject"
| "financeReview"
| "financePayment"
| "duplicateOverride"
| "sensitiveExport"
| "retry"
| "unbind"
| "cancel";
export type ActionConfirmCopy = {
title: string;
description: ReactNode;
confirmLabel: string;
variant: "default" | "destructive";
};
export type ActionConfirmContext = {
targetName?: string;
count?: number;
detail?: ReactNode;
};
function withTarget(base: string, targetName?: string) {
return targetName ? `${base}:${targetName}` : base;
}
export function getActionConfirmCopy(kind: ActionConfirmKind, context: ActionConfirmContext = {}): ActionConfirmCopy {
const { targetName, count, detail } = context;
const countText = typeof count === "number" && count > 0 ? `${count} 项` : "所选项目";
const copies: Record<ActionConfirmKind, ActionConfirmCopy> = {
submit: {
title: withTarget("确认提交审批", targetName),
description: detail ?? "提交后将进入审批流程,系统会生成待办、通知审批人并写入提交历史。",
confirmLabel: "确认提交",
variant: "default",
},
precheck: {
title: withTarget("确认继续提交", targetName),
description: detail ?? "当前提交存在提示项。确认后将继续提交审批,并按系统规则留痕。",
confirmLabel: "继续提交",
variant: "default",
},
delete: {
title: withTarget("确认删除", targetName),
description: detail ?? "删除后将无法在当前列表继续使用,相关业务记录可能无法恢复。",
confirmLabel: "确认删除",
variant: "destructive",
},
archive: {
title: withTarget("确认归档", targetName),
description: detail ?? "归档后将不再用于新的业务流转,历史记录仍保留。",
confirmLabel: "确认归档",
variant: "destructive",
},
withdraw: {
title: withTarget("确认撤回", targetName),
description: detail ?? "撤回后当前审批流程会终止或回到可编辑状态,并写入撤回历史。",
confirmLabel: "确认撤回",
variant: "destructive",
},
enable: {
title: withTarget("确认启用", targetName),
description: detail ?? "启用后该配置会重新参与后续业务判断,只影响新发生的业务。",
confirmLabel: "确认启用",
variant: "default",
},
disable: {
title: withTarget("确认停用", targetName),
description: detail ?? "停用后该配置不再参与后续业务判断,历史记录不回写。",
confirmLabel: "确认停用",
variant: "destructive",
},
batchApprove: {
title: `确认批量通过${count ? ` ${countText}` : ""}`,
description: detail ?? "系统会逐条处理所选待办;每条结果都会写入审批历史。",
confirmLabel: "确认批量通过",
variant: "default",
},
batchReject: {
title: `确认批量驳回${count ? ` ${countText}` : ""}`,
description: detail ?? "系统会逐条驳回所选待办;驳回意见会写入审批历史。",
confirmLabel: "确认批量驳回",
variant: "destructive",
},
financeReview: {
title: withTarget("确认财务复核", targetName),
description: detail ?? "确认后将更新财务复核结果,并写入财务处理记录。",
confirmLabel: "确认复核",
variant: "default",
},
financePayment: {
title: withTarget("确认财务付款动作", targetName),
description: detail ?? "确认后将影响付款批次或付款状态,并写入财务审计记录。",
confirmLabel: "确认执行",
variant: "destructive",
},
duplicateOverride: {
title: withTarget("确认判重例外", targetName),
description: detail ?? "确认后将写入审计记录,并影响该票据后续判重口径。",
confirmLabel: "确认例外",
variant: "destructive",
},
sensitiveExport: {
title: withTarget("确认导出敏感数据", targetName),
description: detail ?? "导出文件可能包含业务或个人信息,请确认当前账号和用途合规。",
confirmLabel: "确认导出",
variant: "default",
},
retry: {
title: withTarget("确认重试", targetName),
description: detail ?? "确认后系统会重新发起该动作,并追加新的处理记录。",
confirmLabel: "确认重试",
variant: "default",
},
unbind: {
title: withTarget("确认解绑", targetName),
description: detail ?? "解绑后当前对象关系会被移除,后续需重新绑定才能继续使用。",
confirmLabel: "确认解绑",
variant: "destructive",
},
cancel: {
title: withTarget("确认取消", targetName),
description: detail ?? "取消后该业务动作将停止,系统会保留操作历史。",
confirmLabel: "确认取消",
variant: "destructive",
},
};
return copies[kind];
}