AP6 增加审批催办与效率摘要

这个提交包含在:
2026-05-12 10:41:47 +08:00
父节点 f99fbce3d8
当前提交 72e38db4e5
共修改 23 个文件,包含 1362 行新增和 12 行删除
@@ -4,9 +4,14 @@ const workflowRoutes = require("../../../src/routes/workflow");
describe("workflow travel helpers", () => {
const {
buildApprovedCopy,
buildOverdueTaskCopy,
buildPendingTaskCopy,
buildRejectedCopy,
buildRemindedTaskCopy,
buildReturnedCopy,
buildWorkflowTaskSummaryPayload,
calculateWorkflowTaskDueAt,
isWorkflowTaskOverdue,
buildWorkflowEntityMeta,
resolveWorkflowOutcomeNotificationType,
} = workflowRoutes.__testables;
@@ -82,6 +87,14 @@ describe("workflow travel helpers", () => {
title: "【已退回】报销单 BX-20260325-001",
body: "申请人:刘报销\n金额:880.00\n单号:BX-20260325-001\n结果:已退回:请补发票",
});
expect(buildRemindedTaskCopy(reimbursementMeta)).toEqual({
title: "【催办】报销单 BX-20260325-001 待审批",
body: "申请人:刘报销\n金额:880.00\n单号:BX-20260325-001\n动作:申请人已催办,请及时处理审批任务。",
});
expect(buildOverdueTaskCopy(reimbursementMeta)).toEqual({
title: "【超时提醒】报销单 BX-20260325-001 待审批",
body: "申请人:刘报销\n金额:880.00\n单号:BX-20260325-001\n动作:该审批已超时,请尽快处理。",
});
});
it("resolves approved and rejected notification types for travel workflows", () => {
@@ -93,4 +106,47 @@ describe("workflow travel helpers", () => {
);
expect(resolveWorkflowOutcomeNotificationType("travel_request", "returned")).toBeNull();
});
it("builds pending task productivity summary with overdue buckets", () => {
const now = new Date("2026-05-12T08:00:00.000Z");
const tasks = [
{
id: "task-1",
status: "pending",
step_name: "经理审批",
assignee_role: "manager",
created_at: new Date("2026-05-11T07:00:00.000Z"),
due_date: null,
workflow_instance: { entity_type: "reimbursement" },
},
{
id: "task-2",
status: "pending",
step_name: "财务审批",
assignee_role: "finance",
created_at: new Date("2026-05-12T07:00:00.000Z"),
due_date: new Date("2026-05-12T07:30:00.000Z"),
workflow_instance: { entity_type: "purchase_request" },
},
];
expect(calculateWorkflowTaskDueAt(tasks[0], now).toISOString()).toBe("2026-05-12T07:00:00.000Z");
expect(isWorkflowTaskOverdue(tasks[0], now)).toBe(true);
const summary = buildWorkflowTaskSummaryPayload(tasks, "mine", now);
expect(summary).toEqual(
expect.objectContaining({
scope: "mine",
pendingTotal: 2,
overdueTotal: 2,
earliestPendingAt: "2026-05-11T07:00:00.000Z",
}),
);
expect(summary.byEntityType).toEqual(
expect.arrayContaining([
{ key: "reimbursement", pendingTotal: 1, overdueTotal: 1 },
{ key: "purchase_request", pendingTotal: 1, overdueTotal: 1 },
]),
);
});
});