Support paid flow states, freeflow pay actions, and clean pending nodes
This commit is contained in:
1 parent
d5f68ea2f3
commit
6c6b3034a0
3 files changed
+239
-81
No files matched your search
@@ -18,7 +18,9 @@ import {
|
|||||||
getHoseFlow,
|
getHoseFlow,
|
||||||
getHoseOpenFlow,
|
getHoseOpenFlow,
|
||||||
getHoseCloseFlow,
|
getHoseCloseFlow,
|
||||||
alignApprovalRunsWithHoseFlow
|
alignApprovalRunsWithHoseFlow,
|
||||||
|
formatAiDecision,
|
||||||
|
formatHumanOpinionLines
|
||||||
} from "./flow.js";
|
} from "./flow.js";
|
||||||
import {
|
import {
|
||||||
searchCloseBacklogs,
|
searchCloseBacklogs,
|
||||||
@@ -910,6 +912,93 @@ describe("Hose Flow Domain", () => {
|
|||||||
expect(r2.eHumanComment).toBe("上级主管(张舒):当前审核节点");
|
expect(r2.eHumanComment).toBe("上级主管(张舒):当前审核节点");
|
||||||
expect(r2.auditDrift).toBe(false);
|
expect(r2.auditDrift).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("handles completed paid flow: resolves through, deduplicates opinions, omits cc, and clears pending", () => {
|
||||||
|
const runs = [
|
||||||
|
{
|
||||||
|
id: "run-paid",
|
||||||
|
sourceDocumentSN: "B26002324",
|
||||||
|
taskMode: "assisted",
|
||||||
|
createdAt: 10000,
|
||||||
|
status: "completed",
|
||||||
|
manualApprovalStatus: "APPROVED",
|
||||||
|
result: { decision: "EXEMPT_APPROVE" }
|
||||||
|
}
|
||||||
|
] as any[];
|
||||||
|
|
||||||
|
const flow = {
|
||||||
|
state: "已支付",
|
||||||
|
rawState: "paid",
|
||||||
|
history: [
|
||||||
|
{ time: 8000, action: "提交送审", rawAction: "freeflow.submit", operator: { name: "高思琦" } },
|
||||||
|
{ time: 11000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "上级主管", operator: { name: "张舒" } },
|
||||||
|
{ time: 12000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务助理", operator: { name: "熊雪倩" } },
|
||||||
|
{ time: 13000, action: "自动同意", rawAction: "freeflow.autoAgree", nodeName: "部门主管", operator: { name: "张舒" } },
|
||||||
|
{ time: 14000, action: "发表评论", rawAction: "freeflow.comment", comment: "ETA2026年家庭日费用报销", operator: { name: "高思琦" } },
|
||||||
|
{ time: 14500, action: "发表评论", rawAction: "freeflow.comment", comment: "ETA2026年家庭日费用报销", operator: { name: "高思琦" } },
|
||||||
|
{ time: 15000, action: "支付完成", rawAction: "freeflow.pay", operator: { name: "高思琦" } },
|
||||||
|
{ time: 16000, action: "抄送通知", rawAction: "freeflow.carbonCopy", operator: { name: "高思琦" } }
|
||||||
|
],
|
||||||
|
pending: []
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const aligned = alignApprovalRunsWithHoseFlow(runs, flow);
|
||||||
|
const r = aligned.get("run-paid")!;
|
||||||
|
expect(r.aiDecision).toBe("备注通过");
|
||||||
|
expect(r.eHumanAction).toBe("通过");
|
||||||
|
expect(r.auditDrift).toBe(false);
|
||||||
|
|
||||||
|
// Verify opinions:
|
||||||
|
// 1. Agree nodes present
|
||||||
|
expect(r.eHumanComment).toContain("上级主管(张舒): 同意");
|
||||||
|
expect(r.eHumanComment).toContain("财务助理(熊雪倩): 同意");
|
||||||
|
expect(r.eHumanComment).toContain("部门主管(张舒): 自动同意");
|
||||||
|
// 2. Duplicate comment deduplicated (appears only once)
|
||||||
|
const matches = r.eHumanComment.match(/高思琦: ETA2026年家庭日费用报销/g);
|
||||||
|
expect(matches?.length).toBe(1);
|
||||||
|
// 3. freeflow.pay mapped to 支付完成
|
||||||
|
expect(r.eHumanComment).toContain("高思琦: 支付完成");
|
||||||
|
// 4. freeflow.carbonCopy omitted
|
||||||
|
expect(r.eHumanComment).not.toContain("freeflow.carbonCopy");
|
||||||
|
expect(r.eHumanComment).not.toContain("抄送通知");
|
||||||
|
// 5. No pending node appended
|
||||||
|
expect(r.eHumanComment).not.toContain("当前审核节点");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Pending and end-state handling", () => {
|
||||||
|
test("parseHoseOpenPending filters out CANCELED / PROCESSED nodes even with logId -1", () => {
|
||||||
|
const allLogs = [
|
||||||
|
{ id: "1", logId: -1, state: "CANCELED", nodeName: "已取消节点", ownerId: "user-1" },
|
||||||
|
{ id: "2", logId: -1, state: "APPROVING", nodeName: "当前待审节点", ownerId: "user-2" }
|
||||||
|
] as any[];
|
||||||
|
const pending = parseHoseOpenPending(allLogs);
|
||||||
|
expect(pending.length).toBe(1);
|
||||||
|
expect(pending[0]?.name).toBe("当前待审节点");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("parseHoseOpenComposite clears pending nodes when flow is paid or completed", () => {
|
||||||
|
const composite = {
|
||||||
|
flowDetails: {
|
||||||
|
id: "flow-1",
|
||||||
|
state: "paid",
|
||||||
|
logs: []
|
||||||
|
},
|
||||||
|
allLogs: [
|
||||||
|
{ id: "1", logId: -1, state: "APPROVING", nodeName: "残留待审节点", ownerId: "user-1" }
|
||||||
|
]
|
||||||
|
} as any;
|
||||||
|
const detail = parseHoseOpenComposite(composite);
|
||||||
|
expect(detail?.state).toBe("已支付");
|
||||||
|
expect(detail?.pending).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("formatAiDecision maps codes to Chinese labels", () => {
|
||||||
|
expect(formatAiDecision("EXEMPT_APPROVE")).toBe("备注通过");
|
||||||
|
expect(formatAiDecision("ERROR")).toBe("错误");
|
||||||
|
expect(formatAiDecision("APPROVE")).toBe("通过");
|
||||||
|
expect(formatAiDecision("REJECT")).toBe("驳回");
|
||||||
|
expect(formatAiDecision("REVIEW")).toBe("转交复核");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
+140
-77
@@ -250,13 +250,24 @@ export function parseHoseOpenPending(
|
|||||||
allLogs: HoseOpenAllLogsItem[],
|
allLogs: HoseOpenAllLogsItem[],
|
||||||
staffMap?: Map<string, HoseOpenStaffItem>
|
staffMap?: Map<string, HoseOpenStaffItem>
|
||||||
): HoseFlowPendingNode[] {
|
): HoseFlowPendingNode[] {
|
||||||
const pendingItems = allLogs.filter(
|
const pendingItems = allLogs.filter((item) => {
|
||||||
(item) =>
|
const stateUpper = String(item.state || "").toUpperCase();
|
||||||
|
if (
|
||||||
|
stateUpper === "CANCELED" ||
|
||||||
|
stateUpper === "CANCELLED" ||
|
||||||
|
stateUpper === "PROCESSED" ||
|
||||||
|
stateUpper === "COMPLETED" ||
|
||||||
|
stateUpper === "PAID"
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (
|
||||||
item.logId === -1 ||
|
item.logId === -1 ||
|
||||||
item.state === "APPROVING" ||
|
stateUpper === "APPROVING" ||
|
||||||
item.state === "PROCESSING" ||
|
stateUpper === "PROCESSING" ||
|
||||||
item.state === "PAYING"
|
stateUpper === "PAYING"
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
return pendingItems.map((item, index) => {
|
return pendingItems.map((item, index) => {
|
||||||
let approver = extractFlowPerson(item.ownerId);
|
let approver = extractFlowPerson(item.ownerId);
|
||||||
@@ -450,7 +461,19 @@ export function parseHoseOpenComposite(
|
|||||||
|
|
||||||
const form = (flowDetails.form || {}) as Record<string, unknown>;
|
const form = (flowDetails.form || {}) as Record<string, unknown>;
|
||||||
const history = parseHoseTimeline(flowDetails.logs || [], staffMap);
|
const history = parseHoseTimeline(flowDetails.logs || [], staffMap);
|
||||||
const pending = parseHoseOpenPending(allLogs, staffMap);
|
const rawState = flowDetails.state;
|
||||||
|
const state = translateFlowState(rawState);
|
||||||
|
const rawStateUpper = String(rawState || "").toUpperCase();
|
||||||
|
const isFlowInEndState = [
|
||||||
|
"COMPLETED",
|
||||||
|
"APPROVED",
|
||||||
|
"PAID",
|
||||||
|
"REVOKED",
|
||||||
|
"CANCELED",
|
||||||
|
"CANCELLED",
|
||||||
|
"REJECTED"
|
||||||
|
].includes(rawStateUpper);
|
||||||
|
const pending = isFlowInEndState ? [] : parseHoseOpenPending(allLogs, staffMap);
|
||||||
|
|
||||||
const currentNode = pending.find((p) => p.isCurrent)?.name;
|
const currentNode = pending.find((p) => p.isCurrent)?.name;
|
||||||
const metrics = calculateFlowMetrics(
|
const metrics = calculateFlowMetrics(
|
||||||
@@ -462,9 +485,6 @@ export function parseHoseOpenComposite(
|
|||||||
const staffOpinions = extractStaffOpinions(history);
|
const staffOpinions = extractStaffOpinions(history);
|
||||||
const rejections = extractRejections(history);
|
const rejections = extractRejections(history);
|
||||||
|
|
||||||
const rawState = flowDetails.state;
|
|
||||||
const state = translateFlowState(rawState);
|
|
||||||
|
|
||||||
let specification: { id?: string; name?: string; code?: string } | undefined;
|
let specification: { id?: string; name?: string; code?: string } | undefined;
|
||||||
if (form.specificationId && typeof form.specificationId === "object") {
|
if (form.specificationId && typeof form.specificationId === "object") {
|
||||||
const specObj = form.specificationId as Record<string, unknown>;
|
const specObj = form.specificationId as Record<string, unknown>;
|
||||||
@@ -542,11 +562,6 @@ export function parseHoseFlow(
|
|||||||
? nodeState.nodeId
|
? nodeState.nodeId
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const pending = parseHosePending(plan, currentNode, currentNodeId);
|
|
||||||
const metrics = calculateFlowMetrics(flow, history, raw);
|
|
||||||
const staffOpinions = extractStaffOpinions(history);
|
|
||||||
const rejections = extractRejections(history);
|
|
||||||
|
|
||||||
const rawState =
|
const rawState =
|
||||||
typeof raw.state === "string"
|
typeof raw.state === "string"
|
||||||
? raw.state
|
? raw.state
|
||||||
@@ -554,6 +569,20 @@ export function parseHoseFlow(
|
|||||||
? flow.state
|
? flow.state
|
||||||
: undefined;
|
: undefined;
|
||||||
const state = translateFlowState(rawState);
|
const state = translateFlowState(rawState);
|
||||||
|
const rawStateUpper = String(rawState || "").toUpperCase();
|
||||||
|
const isFlowInEndState = [
|
||||||
|
"COMPLETED",
|
||||||
|
"APPROVED",
|
||||||
|
"PAID",
|
||||||
|
"REVOKED",
|
||||||
|
"CANCELED",
|
||||||
|
"CANCELLED",
|
||||||
|
"REJECTED"
|
||||||
|
].includes(rawStateUpper);
|
||||||
|
const pending = isFlowInEndState ? [] : parseHosePending(plan, currentNode, currentNodeId);
|
||||||
|
const metrics = calculateFlowMetrics(flow, history, raw);
|
||||||
|
const staffOpinions = extractStaffOpinions(history);
|
||||||
|
const rejections = extractRejections(history);
|
||||||
|
|
||||||
const lastAttributes =
|
const lastAttributes =
|
||||||
history.at(-1)?.nodeName ??
|
history.at(-1)?.nodeName ??
|
||||||
@@ -648,6 +677,60 @@ export async function getHoseFlow(
|
|||||||
return getHoseOpenFlow(client, flowId, staffCache);
|
return getHoseOpenFlow(client, flowId, staffCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatAiDecision(decision?: string): string {
|
||||||
|
if (!decision) return "-";
|
||||||
|
const norm = decision.toUpperCase();
|
||||||
|
if (norm === "APPROVE" || norm === "通过") return "通过";
|
||||||
|
if (norm === "EXEMPT_APPROVE" || norm === "免审通过" || norm === "备注通过") return "备注通过";
|
||||||
|
if (norm === "REVIEW" || norm === "转交复核") return "转交复核";
|
||||||
|
if (norm === "REJECT" || norm === "驳回") return "驳回";
|
||||||
|
if (norm === "ERROR" || norm === "错误") return "错误";
|
||||||
|
return decision;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatHumanOpinionLines(events: HoseFlowTimelineEntry[]): string[] {
|
||||||
|
const lines: string[] = [];
|
||||||
|
for (const ev of events) {
|
||||||
|
if (
|
||||||
|
(ev.rawAction === "freeflow.carbonCopy" ||
|
||||||
|
ev.rawAction === "freeflow.cc" ||
|
||||||
|
ev.rawAction === "freeflow.print" ||
|
||||||
|
ev.action === "打印提醒" ||
|
||||||
|
ev.action === "抄送通知") &&
|
||||||
|
!ev.comment
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const opName = ev.operator?.name || ev.operator?.id || "未知";
|
||||||
|
const nodePrefix = ev.nodeName?.trim() ? `${ev.nodeName.trim()}(${opName})` : opName;
|
||||||
|
let comment = ev.comment;
|
||||||
|
if (!comment) {
|
||||||
|
if (ev.rawAction === "freeflow.agree" || ev.action === "审批同意") {
|
||||||
|
comment = "同意";
|
||||||
|
} else if (ev.rawAction === "freeflow.autoAgree") {
|
||||||
|
comment = "自动同意";
|
||||||
|
} else if (ev.rawAction === "freeflow.pay" || ev.action === "支付完成") {
|
||||||
|
comment = "支付完成";
|
||||||
|
} else if (ev.rawAction === "freeflow.paying" || ev.action === "支付中") {
|
||||||
|
comment = "支付中";
|
||||||
|
} else if (ev.rawAction === "freeflow.reject" || ev.action === "审批驳回") {
|
||||||
|
comment = "驳回";
|
||||||
|
} else if (ev.rawAction === "freeflow.retract" || ev.action === "单据撤回") {
|
||||||
|
comment = "单据撤回";
|
||||||
|
} else {
|
||||||
|
comment = ev.action || "-";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const line = `${nodePrefix}: ${comment}`;
|
||||||
|
if (lines.length === 0 || lines[lines.length - 1] !== line) {
|
||||||
|
lines.push(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
export function alignApprovalRunsWithHoseFlow(
|
export function alignApprovalRunsWithHoseFlow(
|
||||||
runs: ApprovalRun[],
|
runs: ApprovalRun[],
|
||||||
flow?: HoseFlowDetail
|
flow?: HoseFlowDetail
|
||||||
@@ -663,7 +746,7 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
recordId: run.id,
|
recordId: run.id,
|
||||||
sourceDocumentSN: run.sourceDocumentSN,
|
sourceDocumentSN: run.sourceDocumentSN,
|
||||||
taskMode: run.taskMode,
|
taskMode: run.taskMode,
|
||||||
aiDecision: typeof aiDecision === "string" ? aiDecision : "-",
|
aiDecision: formatAiDecision(typeof aiDecision === "string" ? aiDecision : "-"),
|
||||||
aiAction: "-",
|
aiAction: "-",
|
||||||
eHumanAction: "-",
|
eHumanAction: "-",
|
||||||
eHumanComment: "-",
|
eHumanComment: "-",
|
||||||
@@ -678,11 +761,17 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const history = flow.history || [];
|
const history = flow.history || [];
|
||||||
|
const rawStateUpper = String(flow.rawState || "").toUpperCase();
|
||||||
|
const stateUpper = String(flow.state || "").toUpperCase();
|
||||||
const isFlowCompleted =
|
const isFlowCompleted =
|
||||||
flow.rawState === "COMPLETED" ||
|
rawStateUpper === "COMPLETED" ||
|
||||||
flow.rawState === "APPROVED" ||
|
rawStateUpper === "APPROVED" ||
|
||||||
flow.state === "已完成" ||
|
rawStateUpper === "PAID" ||
|
||||||
flow.state === "审批通过";
|
rawStateUpper === "PAYING" ||
|
||||||
|
stateUpper === "已完成" ||
|
||||||
|
stateUpper === "审批通过" ||
|
||||||
|
stateUpper === "已支付" ||
|
||||||
|
stateUpper === "支付中";
|
||||||
|
|
||||||
for (let i = 0; i < sortedRuns.length; i++) {
|
for (let i = 0; i < sortedRuns.length; i++) {
|
||||||
const run = sortedRuns[i];
|
const run = sortedRuns[i];
|
||||||
@@ -728,6 +817,12 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
normManual === "已取消" ||
|
normManual === "已取消" ||
|
||||||
normManual === "已撤回" ||
|
normManual === "已撤回" ||
|
||||||
normManual === "REVOKED";
|
normManual === "REVOKED";
|
||||||
|
const isRunApprovedInSeal =
|
||||||
|
normManual === "APPROVED" ||
|
||||||
|
normManual === "已支付/审批完成" ||
|
||||||
|
normManual === "已通过" ||
|
||||||
|
normManual === "已完成" ||
|
||||||
|
normManual === "已支付";
|
||||||
|
|
||||||
// 5-second clock skew tolerance window [runTime - 5000, nextRunTime)
|
// 5-second clock skew tolerance window [runTime - 5000, nextRunTime)
|
||||||
const windowEvents = history.filter((e) => {
|
const windowEvents = history.filter((e) => {
|
||||||
@@ -769,9 +864,9 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
!e.isEbot &&
|
!e.isEbot &&
|
||||||
e.rawAction !== "freeflow.submit" &&
|
e.rawAction !== "freeflow.submit" &&
|
||||||
e.action !== "提交送审" &&
|
e.action !== "提交送审" &&
|
||||||
e.rawAction !== "freeflow.print" &&
|
!((e.rawAction === "freeflow.comment" || e.action === "发表评论") && !e.comment) &&
|
||||||
e.action !== "打印提醒" &&
|
!((e.rawAction === "freeflow.print" || e.action === "打印提醒") && !e.comment) &&
|
||||||
e.rawAction !== "freeflow.comment"
|
!(e.rawAction === "freeflow.carbonCopy" || e.rawAction === "freeflow.cc" || e.action === "抄送通知")
|
||||||
);
|
);
|
||||||
|
|
||||||
const retractEvent = subsequentHumanEvents.find(
|
const retractEvent = subsequentHumanEvents.find(
|
||||||
@@ -782,19 +877,19 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const isFlowRetractedOrCancelled =
|
const isFlowRetractedOrCancelled =
|
||||||
flow.rawState === "DRAFT" ||
|
rawStateUpper === "DRAFT" ||
|
||||||
flow.rawState === "REVOKED" ||
|
rawStateUpper === "REVOKED" ||
|
||||||
flow.rawState === "CANCELED" ||
|
rawStateUpper === "CANCELED" ||
|
||||||
flow.rawState === "CANCELLED" ||
|
rawStateUpper === "CANCELLED" ||
|
||||||
flow.state === "草稿" ||
|
stateUpper === "草稿" ||
|
||||||
flow.state === "已撤回" ||
|
stateUpper === "已撤回" ||
|
||||||
flow.state === "已取消";
|
stateUpper === "已取消";
|
||||||
|
|
||||||
const isFlowRejected =
|
const isFlowRejected =
|
||||||
flow.rawState === "REJECTED" ||
|
rawStateUpper === "REJECTED" ||
|
||||||
flow.rawState === "TERMINATED" ||
|
rawStateUpper === "TERMINATED" ||
|
||||||
flow.state === "审批驳回" ||
|
stateUpper === "审批驳回" ||
|
||||||
flow.state === "已驳回";
|
stateUpper === "已驳回";
|
||||||
|
|
||||||
if (!isLatestRun) {
|
if (!isLatestRun) {
|
||||||
// Historical run that has been superseded by a newer run
|
// Historical run that has been superseded by a newer run
|
||||||
@@ -810,23 +905,15 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
eHumanComment = rejectEvent.comment || "驳回";
|
eHumanComment = rejectEvent.comment || "驳回";
|
||||||
} else {
|
} else {
|
||||||
eHumanAction = "已修改重提";
|
eHumanAction = "已修改重提";
|
||||||
const opinionLines: string[] = [];
|
const opinionLines = formatHumanOpinionLines(subsequentHumanEvents);
|
||||||
for (const ev of subsequentHumanEvents) {
|
for (const ev of subsequentHumanEvents) {
|
||||||
const opName = ev.operator?.name || ev.operator?.id || "未知";
|
if (!operator && ev.operator) operator = ev.operator;
|
||||||
const nodePrefix = ev.nodeName?.trim() ? `${ev.nodeName.trim()}(${opName})` : opName;
|
|
||||||
const comment =
|
|
||||||
ev.comment ||
|
|
||||||
(ev.rawAction === "freeflow.agree" || ev.action === "审批同意"
|
|
||||||
? "同意"
|
|
||||||
: ev.action || "-");
|
|
||||||
opinionLines.push(`${nodePrefix}: ${comment}`);
|
|
||||||
if (!operator) operator = ev.operator;
|
|
||||||
}
|
}
|
||||||
eHumanComment = opinionLines.length > 0 ? opinionLines.join("\n") : "-";
|
eHumanComment = opinionLines.length > 0 ? opinionLines.join("\n") : "-";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Latest run for this document
|
// Latest run for this document
|
||||||
if (isFlowCompleted) {
|
if (isFlowCompleted || isRunApprovedInSeal) {
|
||||||
const hasRetract = subsequentHumanEvents.some(
|
const hasRetract = subsequentHumanEvents.some(
|
||||||
(e) => e.rawAction === "freeflow.retract" || e.action === "单据撤回"
|
(e) => e.rawAction === "freeflow.retract" || e.action === "单据撤回"
|
||||||
);
|
);
|
||||||
@@ -845,17 +932,9 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
eHumanComment = rejectEvent.comment || "驳回";
|
eHumanComment = rejectEvent.comment || "驳回";
|
||||||
operator = rejectEvent.operator;
|
operator = rejectEvent.operator;
|
||||||
} else {
|
} else {
|
||||||
const opinionLines: string[] = [];
|
const opinionLines = formatHumanOpinionLines(subsequentHumanEvents);
|
||||||
for (const ev of subsequentHumanEvents) {
|
for (const ev of subsequentHumanEvents) {
|
||||||
const opName = ev.operator?.name || ev.operator?.id || "未知";
|
if (!operator && ev.operator) operator = ev.operator;
|
||||||
const nodePrefix = ev.nodeName?.trim() ? `${ev.nodeName.trim()}(${opName})` : opName;
|
|
||||||
const comment =
|
|
||||||
ev.comment ||
|
|
||||||
(ev.rawAction === "freeflow.agree" || ev.action === "审批同意"
|
|
||||||
? "同意"
|
|
||||||
: ev.action || "-");
|
|
||||||
opinionLines.push(`${nodePrefix}: ${comment}`);
|
|
||||||
if (!operator) operator = ev.operator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opinionLines.length > 0) {
|
if (opinionLines.length > 0) {
|
||||||
@@ -866,7 +945,7 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
.find(
|
.find(
|
||||||
(e) =>
|
(e) =>
|
||||||
!e.isEbot &&
|
!e.isEbot &&
|
||||||
(e.rawAction === "freeflow.agree" || e.action === "审批同意")
|
(e.rawAction === "freeflow.agree" || e.action === "审批同意" || e.rawAction === "freeflow.pay")
|
||||||
);
|
);
|
||||||
eHumanComment = lastHumanApproval?.comment || "-";
|
eHumanComment = lastHumanApproval?.comment || "-";
|
||||||
if (!operator) operator = lastHumanApproval?.operator;
|
if (!operator) operator = lastHumanApproval?.operator;
|
||||||
@@ -875,17 +954,9 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
} else if (isFlowRetractedOrCancelled || (retractEvent && !hasPostAiResubmit) || isRunCancelledInSeal) {
|
} else if (isFlowRetractedOrCancelled || (retractEvent && !hasPostAiResubmit) || isRunCancelledInSeal) {
|
||||||
eHumanAction = "已撤回";
|
eHumanAction = "已撤回";
|
||||||
operator = retractEvent?.operator;
|
operator = retractEvent?.operator;
|
||||||
const opinionLines: string[] = [];
|
const opinionLines = formatHumanOpinionLines(subsequentHumanEvents);
|
||||||
for (const ev of subsequentHumanEvents) {
|
for (const ev of subsequentHumanEvents) {
|
||||||
const opName = ev.operator?.name || ev.operator?.id || "未知";
|
if (!operator && ev.operator) operator = ev.operator;
|
||||||
const nodePrefix = ev.nodeName?.trim() ? `${ev.nodeName.trim()}(${opName})` : opName;
|
|
||||||
const comment =
|
|
||||||
ev.comment ||
|
|
||||||
(ev.rawAction === "freeflow.agree" || ev.action === "审批同意"
|
|
||||||
? "同意"
|
|
||||||
: ev.action || "-");
|
|
||||||
opinionLines.push(`${nodePrefix}: ${comment}`);
|
|
||||||
if (!operator) operator = ev.operator;
|
|
||||||
}
|
}
|
||||||
if (retractEvent && opinionLines.length === 0) {
|
if (retractEvent && opinionLines.length === 0) {
|
||||||
opinionLines.push(`${retractEvent.operator?.name || "提交人"}: 单据撤回`);
|
opinionLines.push(`${retractEvent.operator?.name || "提交人"}: 单据撤回`);
|
||||||
@@ -900,17 +971,9 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
// Flow is still actively approving
|
// Flow is still actively approving
|
||||||
eHumanAction = auditDrift ? "审核中 (⚠️ AI通过后被修改重提)" : "审核中";
|
eHumanAction = auditDrift ? "审核中 (⚠️ AI通过后被修改重提)" : "审核中";
|
||||||
|
|
||||||
const opinionLines: string[] = [];
|
const opinionLines = formatHumanOpinionLines(subsequentHumanEvents);
|
||||||
for (const ev of subsequentHumanEvents) {
|
for (const ev of subsequentHumanEvents) {
|
||||||
const opName = ev.operator?.name || ev.operator?.id || "未知";
|
if (!operator && ev.operator) operator = ev.operator;
|
||||||
const nodePrefix = ev.nodeName?.trim() ? `${ev.nodeName.trim()}(${opName})` : opName;
|
|
||||||
const comment =
|
|
||||||
ev.comment ||
|
|
||||||
(ev.rawAction === "freeflow.agree" || ev.action === "审批同意"
|
|
||||||
? "同意"
|
|
||||||
: ev.action || "-");
|
|
||||||
opinionLines.push(`${nodePrefix}: ${comment}`);
|
|
||||||
if (!operator) operator = ev.operator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const pendingNodes = flow.pending || [];
|
const pendingNodes = flow.pending || [];
|
||||||
@@ -934,7 +997,7 @@ export function alignApprovalRunsWithHoseFlow(
|
|||||||
recordId: run.id,
|
recordId: run.id,
|
||||||
sourceDocumentSN: run.sourceDocumentSN,
|
sourceDocumentSN: run.sourceDocumentSN,
|
||||||
taskMode: run.taskMode,
|
taskMode: run.taskMode,
|
||||||
aiDecision: aiDecisionStr,
|
aiDecision: formatAiDecision(aiDecisionStr),
|
||||||
aiAction,
|
aiAction,
|
||||||
eHumanAction,
|
eHumanAction,
|
||||||
eHumanComment,
|
eHumanComment,
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ export const HOSE_FLOW_ACTION_LABELS: Record<string, string> = {
|
|||||||
"freeflow.print": "打印单据",
|
"freeflow.print": "打印单据",
|
||||||
"freeflow.retract": "单据撤回",
|
"freeflow.retract": "单据撤回",
|
||||||
"freeflow.addnode": "加签/转交",
|
"freeflow.addnode": "加签/转交",
|
||||||
"freeflow.comment": "发表评论"
|
"freeflow.comment": "发表评论",
|
||||||
|
"freeflow.pay": "支付完成",
|
||||||
|
"freeflow.paying": "支付中",
|
||||||
|
"freeflow.carbonCopy": "抄送通知",
|
||||||
|
"freeflow.cc": "抄送通知"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const HOSE_FLOW_STATE_LABELS: Record<string, string> = {
|
export const HOSE_FLOW_STATE_LABELS: Record<string, string> = {
|
||||||
@@ -23,7 +27,9 @@ export const HOSE_FLOW_STATE_LABELS: Record<string, string> = {
|
|||||||
PENDING: "待审批",
|
PENDING: "待审批",
|
||||||
WAITING: "待处理",
|
WAITING: "待处理",
|
||||||
COMPLETED: "已完成",
|
COMPLETED: "已完成",
|
||||||
DRAFT: "草稿"
|
DRAFT: "草稿",
|
||||||
|
PAID: "已支付",
|
||||||
|
PAYING: "支付中"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const FlowPersonSchema = z.object({
|
export const FlowPersonSchema = z.object({
|
||||||
|
|||||||
Reference in new issue
Block a user