LP6 完善请假采购体验与审批说明
这个提交包含在:
@@ -0,0 +1,172 @@
|
||||
import { isUuidLike } from "./reimbursementDisplay";
|
||||
|
||||
export type ApprovalHistoryDisplayItem = {
|
||||
id: string;
|
||||
action: string;
|
||||
comment: string | null;
|
||||
actorName: string | null;
|
||||
actorEmployeeNo?: string | null;
|
||||
createdAt: string | null;
|
||||
};
|
||||
|
||||
type PendingWorkflowLike = {
|
||||
currentStatus?: string | null;
|
||||
task?: {
|
||||
stepName?: string | null;
|
||||
assigneeRole?: string | null;
|
||||
} | null;
|
||||
} | null;
|
||||
|
||||
type LeaveStatusLike = {
|
||||
status: string;
|
||||
pendingWorkflow?: PendingWorkflowLike;
|
||||
approvalHistory?: ApprovalHistoryDisplayItem[];
|
||||
};
|
||||
|
||||
type PurchaseStatusLike = {
|
||||
status: string;
|
||||
requestNo?: string | null;
|
||||
title?: string | null;
|
||||
createdAt?: string | null;
|
||||
updatedAt?: string | null;
|
||||
budgetPool?: { name?: string | null } | null;
|
||||
pendingWorkflow?: PendingWorkflowLike;
|
||||
approvalHistory?: ApprovalHistoryDisplayItem[];
|
||||
};
|
||||
|
||||
export function workflowActionLabel(action: string | null | undefined) {
|
||||
const labels: Record<string, string> = {
|
||||
start: "提交",
|
||||
submit: "提交",
|
||||
approve: "通过",
|
||||
reject: "驳回",
|
||||
return: "退回",
|
||||
transfer: "转审",
|
||||
withdraw: "撤回",
|
||||
remind: "催办",
|
||||
overdue_remind: "超时提醒",
|
||||
skip: "跳过",
|
||||
cancel: "取消",
|
||||
};
|
||||
|
||||
return action ? labels[action] ?? action : "-";
|
||||
}
|
||||
|
||||
export function formatApprovalHistoryTime(value: string | null | undefined) {
|
||||
return value ? value.slice(0, 19).replace("T", " ") : "-";
|
||||
}
|
||||
|
||||
export function latestDecisionHistory(items: ApprovalHistoryDisplayItem[] | null | undefined) {
|
||||
return (items ?? []).find((item) => ["return", "reject", "withdraw", "approve"].includes(item.action)) ?? null;
|
||||
}
|
||||
|
||||
function commentSuffix(item: ApprovalHistoryDisplayItem | null) {
|
||||
if (!item?.comment?.trim()) {
|
||||
return "";
|
||||
}
|
||||
return `:${item.comment.trim()}`;
|
||||
}
|
||||
|
||||
export function resolveLeaveStatusHint(item: LeaveStatusLike) {
|
||||
const latest = latestDecisionHistory(item.approvalHistory);
|
||||
|
||||
if (item.status === "draft") {
|
||||
if (latest?.action === "return") {
|
||||
return `审批已退回${commentSuffix(latest)}。修改后可重新提交。`;
|
||||
}
|
||||
if (latest?.action === "withdraw") {
|
||||
return "已撤回为草稿,可修改后重新提交。";
|
||||
}
|
||||
return "草稿可继续编辑,确认后提交审批。";
|
||||
}
|
||||
|
||||
if (item.status === "reviewing") {
|
||||
const stepName = item.pendingWorkflow?.task?.stepName;
|
||||
return stepName ? `当前节点:${stepName},等待审批人处理。` : "已提交,等待审批人处理。";
|
||||
}
|
||||
|
||||
if (item.status === "approved") {
|
||||
return "已通过,系统会按请假结果更新额度和团队状态。";
|
||||
}
|
||||
|
||||
if (item.status === "rejected") {
|
||||
return latest?.action === "reject"
|
||||
? `审批已驳回${commentSuffix(latest)}。可修改后重新提交。`
|
||||
: "审批已驳回,可修改后重新提交。";
|
||||
}
|
||||
|
||||
if (item.status === "cancelled") {
|
||||
return "已取消,不再进入审批。";
|
||||
}
|
||||
|
||||
return "请查看审批记录确认下一步。";
|
||||
}
|
||||
|
||||
export function resolvePurchaseDisplayCode(item: PurchaseStatusLike) {
|
||||
const requestNo = item.requestNo?.trim();
|
||||
if (requestNo && !isUuidLike(requestNo)) {
|
||||
return requestNo;
|
||||
}
|
||||
|
||||
const title = item.title?.trim();
|
||||
if (title) {
|
||||
return title;
|
||||
}
|
||||
|
||||
const date = item.updatedAt?.slice(0, 10) ?? item.createdAt?.slice(0, 10) ?? "";
|
||||
if (item.status === "draft" || item.status === "rejected") {
|
||||
return date ? `采购草稿 · ${date}` : "采购草稿";
|
||||
}
|
||||
|
||||
return date ? `未编号采购 · ${date}` : "未编号采购";
|
||||
}
|
||||
|
||||
export function resolvePurchaseBudgetHint(item: PurchaseStatusLike) {
|
||||
if (item.budgetPool?.name) {
|
||||
return `已匹配预算池:${item.budgetPool.name}`;
|
||||
}
|
||||
|
||||
return "未匹配预算池;当前试运行按预警继续提交审批,如需强预算校验请由管理员补充预算配置。";
|
||||
}
|
||||
|
||||
export function resolvePurchaseSubmitWarning(warnings: string[]) {
|
||||
if (warnings.includes("missing_budget_pool")) {
|
||||
return "采购申请已提交;未匹配预算池,已按当前试运行规则继续进入审批。";
|
||||
}
|
||||
return "采购申请已提交";
|
||||
}
|
||||
|
||||
export function resolvePurchaseStatusHint(item: PurchaseStatusLike) {
|
||||
const latest = latestDecisionHistory(item.approvalHistory);
|
||||
|
||||
if (item.status === "draft") {
|
||||
if (latest?.action === "return") {
|
||||
return `审批已退回${commentSuffix(latest)}。修改后可重新提交。`;
|
||||
}
|
||||
if (latest?.action === "withdraw") {
|
||||
return "已撤回为草稿,可修改后重新提交。";
|
||||
}
|
||||
return "草稿可继续编辑,补齐明细和附件后提交审批。";
|
||||
}
|
||||
|
||||
if (item.status === "reviewing") {
|
||||
const stepName = item.pendingWorkflow?.task?.stepName;
|
||||
return stepName ? `当前节点:${stepName},等待审批人处理。` : "已提交,等待审批人处理。";
|
||||
}
|
||||
|
||||
if (item.status === "approved") {
|
||||
return "已通过,可由有权限人员完成 PO/合同归档或后续处理。";
|
||||
}
|
||||
|
||||
if (item.status === "rejected") {
|
||||
return latest?.action === "reject"
|
||||
? `审批已驳回${commentSuffix(latest)}。可修改后重新提交。`
|
||||
: "审批已驳回,可修改后重新提交。";
|
||||
}
|
||||
|
||||
if (item.status === "cancelled") {
|
||||
return "已取消,不再进入审批。";
|
||||
}
|
||||
|
||||
return "请查看审批记录确认下一步。";
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户