diff --git a/src/domains/hose/flow.test.ts b/src/domains/hose/flow.test.ts index 1d74bca..aebf63a 100644 --- a/src/domains/hose/flow.test.ts +++ b/src/domains/hose/flow.test.ts @@ -789,7 +789,9 @@ describe("Hose Flow Domain", () => { const r1 = aligned.get("run-1")!; expect(r1.eHumanAction).toBe("审批驳回"); - expect(r1.eHumanComment).toBe("主管B: 发票不全缺少总经理审批,退回修改"); + expect(r1.eHumanComment).toBe( + "主管B: 发票不全缺少总经理审批,退回修改\n↳ 驳回至: 提交人\n↳ 重新提交后由主管B继续审批" + ); expect(r1.operator?.name).toBe("主管B"); expect(r1.auditDrift).toBe(false); @@ -1059,10 +1061,116 @@ describe("Hose Flow Domain", () => { expect(r.aiDecision).toBe("备注通过"); expect(r.eHumanAction).toBe("审批驳回"); // Node prefix resolved from熊雪倩's approval node in history: 财务助理(熊雪倩): 修改附件 - expect(r.eHumanComment).toBe("财务助理(熊雪倩): 修改附件"); + expect(r.eHumanComment).toBe( + "财务助理(熊雪倩): 修改附件\n↳ 驳回至: 提交人\n↳ 重新提交后由熊雪倩继续审批" + ); expect(r.auditDrift).toBe(false); expect(r.operator?.name).toBe("熊雪倩"); }); + + test("B26002307 scenario: rejected to intermediate node with 样式 2-B format", () => { + const runs = [ + { + id: "run-2307", + sourceDocumentSN: "B26002307", + taskMode: "assisted", + createdAt: 100000, + manualApprovalRecord: { + nodeName: "合思审批节点", + status: { type: "TERMINATED", label: "已驳回" } + }, + result: { decision: "APPROVE" } + } + ] as any[]; + + const flow = { + state: "已支付", + rawState: "paid", + history: [ + { time: 90000, action: "提交送审", rawAction: "freeflow.submit", operator: { name: "郭宝" } }, + { time: 95000, action: "自动同意", rawAction: "freeflow.autoAgree", isEbot: true, operator: { name: "Ebot" } }, + { time: 98000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "上级主管", operator: { name: "孙麓" }, comment: "同意" }, + { time: 101000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务助理", operator: { name: "熊雪倩" }, comment: "同意" }, + { + time: 110000, + action: "审批驳回", + rawAction: "freeflow.reject", + nodeName: "财务经理", + operator: { name: "周晚容" }, + comment: "修改", + rejectTargetNodeName: "财务助理", + rejectTargetOperator: { name: "熊雪倩" }, + resubmitRuleText: "重新提交后由周晚容继续审批" + }, + { + time: 120000, + action: "修改了单据", + rawAction: "flow.modify", + isModification: true, + nodeName: "财务助理", + operator: { name: "熊雪倩" } + }, + { time: 130000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务助理", operator: { name: "熊雪倩" }, comment: "同意" }, + { time: 140000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "董事长", operator: { name: "甘戈" }, comment: "同意" }, + { time: 150000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务经理", operator: { name: "周晚容" }, comment: "同意" }, + { time: 160000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "CFO", operator: { name: "张舒" }, comment: "同意" }, + { time: 170000, action: "支付成功", rawAction: "freeflow.pay", operator: { name: "高思琦" } } + ] + } as any; + + const aligned = alignApprovalRunsWithHoseFlow(runs, flow); + const r = aligned.get("run-2307")!; + expect(r.eHumanAction).toBe("审批驳回"); + expect(r.eHumanComment).toBe( + "财务经理(周晚容): 修改\n↳ 驳回至: 财务助理(熊雪倩)\n↳ 重新提交后由周晚容继续审批" + ); + expect(r.operator?.name).toBe("周晚容"); + }); + + test("B26002144 scenario: mid-flow document modification yields 已支付 (中途修改) with modification at top", () => { + const runs = [ + { + id: "run-2144", + sourceDocumentSN: "B26002144", + taskMode: "automatic", + createdAt: 92000, + manualApprovalRecord: { + status: { type: "APPROVED", label: "已支付/审批完成" } + }, + result: { decision: "APPROVE" } + } + ] as any[]; + + const flow = { + state: "已支付", + rawState: "paid", + history: [ + { time: 90000, action: "提交送审", rawAction: "freeflow.submit", operator: { name: "郭宝" } }, + { time: 95000, action: "自动同意", rawAction: "freeflow.autoAgree", isEbot: true, operator: { name: "费用标准检查" } }, + { time: 98000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "上级主管", operator: { name: "孙麓" }, comment: "同意" }, + { + time: 105000, + action: "修改了单据", + rawAction: "flow.modify", + isModification: true, + nodeName: "财务助理", + operator: { name: "熊雪倩" } + }, + { time: 110000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务助理", operator: { name: "熊雪倩" }, comment: "同意" }, + { time: 120000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "董事长", operator: { name: "甘戈" }, comment: "同意" }, + { time: 130000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "财务经理", operator: { name: "周晚容" }, comment: "同意" }, + { time: 140000, action: "审批同意", rawAction: "freeflow.agree", nodeName: "CFO", operator: { name: "张舒" }, comment: "同意" }, + { time: 150000, action: "支付成功", rawAction: "freeflow.pay", operator: { name: "高思琦" } } + ] + } as any; + + const aligned = alignApprovalRunsWithHoseFlow(runs, flow); + const r = aligned.get("run-2144")!; + expect(r.eHumanAction).toBe("已支付 (中途修改)"); + expect(r.eHumanComment).toBe( + "1. 财务助理(熊雪倩): 修改了单据\n2. 上级主管(孙麓): 同意\n3. 财务助理(熊雪倩): 同意\n4. 董事长(甘戈): 同意\n5. 财务经理(周晚容): 同意\n6. CFO(张舒): 同意\n7. 高思琦: 支付成功" + ); + }); }); describe("Pending and end-state handling", () => { @@ -1136,7 +1244,9 @@ describe("Hose Flow Domain", () => { { rawAction: "freeflow.agree", nodeName: "财务助理", operator: { name: "熊雪倩" } } as any ] ); - expect(res1.comment).toBe("财务助理(熊雪倩): 修改附件"); + expect(res1.comment).toBe( + "财务助理(熊雪倩): 修改附件\n↳ 驳回至: 提交人\n↳ 重新提交后由熊雪倩继续审批" + ); expect(res1.operator?.name).toBe("熊雪倩"); const res2 = formatRejectionComment( @@ -1147,14 +1257,18 @@ describe("Hose Flow Domain", () => { reason: "单据超标缺少说明" } as any ); - expect(res2.comment).toBe("财务经理(周晚容): 单据超标缺少说明"); + expect(res2.comment).toBe( + "财务经理(周晚容): 单据超标缺少说明\n↳ 驳回至: 提交人\n↳ 重新提交后由周晚容继续审批" + ); const res3 = formatRejectionComment( undefined, undefined, { nodeName: "合思审批节点", rejectComment: "超额报销" } ); - expect(res3.comment).toBe("超额报销"); + expect(res3.comment).toBe( + "超额报销\n↳ 驳回至: 提交人\n↳ 重新提交后继续审批" + ); expect(res3.comment).not.toContain("合思审批节点"); }); @@ -1254,7 +1368,9 @@ describe("Hose Flow Domain", () => { const r = aligned.get("run-june-round1")!; // Must NOT be falsely labeled as "已支付" just because Hose is currently paid! expect(r.eHumanAction).toBe("审批驳回"); - expect(r.eHumanComment).toBe("财务审批(李四): 发票模糊"); + expect(r.eHumanComment).toBe( + "财务审批(李四): 发票模糊\n↳ 驳回至: 提交人\n↳ 重新提交后由李四继续审批" + ); expect(r.auditDrift).toBe(false); }); }); diff --git a/src/domains/hose/flow.ts b/src/domains/hose/flow.ts index c7a03f6..2dfc20b 100644 --- a/src/domains/hose/flow.ts +++ b/src/domains/hose/flow.ts @@ -115,7 +115,9 @@ export function formatOperator( export function parseHoseTimeline( rawLogs: unknown[], - staffMap?: Map + staffMap?: Map, + allLogs?: unknown[], + submitterId?: string ): HoseFlowTimelineEntry[] { const logs = Array.isArray(rawLogs) ? rawLogs.filter((l): l is Record => Boolean(l && typeof l === "object")) @@ -123,18 +125,80 @@ export function parseHoseTimeline( const sortedLogs = [...logs].sort((a, b) => (Number(a.time) || 0) - (Number(b.time) || 0)); - return sortedLogs.map((log, index) => { + const resolveStaff = (personId?: string): FlowPerson | undefined => { + if (!personId) return undefined; + const base = extractFlowPerson(personId); + if (!base) return undefined; + if (!base.name && staffMap && base.id) { + const idParts = base.id.split(":"); + const staff = + staffMap.get(base.id) || + (idParts.length > 1 && idParts[1] ? staffMap.get(idParts[1]) : undefined); + if (staff?.name) { + return { + ...base, + name: staff.name, + code: staff.code || base.code + }; + } + } + return base; + }; + + const entries: HoseFlowTimelineEntry[] = []; + + for (let index = 0; index < sortedLogs.length; index++) { + const log = sortedLogs[index]!; const attributes = log.attributes && typeof log.attributes === "object" ? (log.attributes as Record) : {}; const currentTime = typeof log.time === "number" ? log.time : undefined; - const nextLog = sortedLogs[index + 1]; - const nextTime = typeof nextLog?.time === "number" ? nextLog.time : undefined; - const durationMs = - currentTime !== undefined && nextTime !== undefined && nextTime >= currentTime - ? nextTime - currentTime - : undefined; + + // Check for inline document modification log (modifyFlowLog) + if (Array.isArray(log.modifyFlowLog)) { + for (const m of log.modifyFlowLog as Array>) { + if (m && typeof m === "object" && m.operatorState === "UPDATE") { + const modTime = typeof m.operatorTime === "number" ? m.operatorTime : currentTime; + const modOpId = typeof m.operatorId === "string" ? m.operatorId : undefined; + const modPerson = resolveStaff(modOpId); + + let modNodeName = "单据修改"; + if (modOpId && modOpId === submitterId) { + modNodeName = "提交人"; + } else if (Array.isArray(allLogs) && modOpId) { + const matchedAllLog: any = allLogs.find( + (a: any) => + a && + typeof a === "object" && + a.ownerId === modOpId && + typeof a.nodeName === "string" + ); + if (matchedAllLog?.nodeName) { + modNodeName = String(matchedAllLog.nodeName).trim(); + } + } + + entries.push({ + id: typeof m.flowVersionedId === "string" ? `modify-${m.flowVersionedId}` : undefined, + time: modTime, + state: "审批中", + rawState: "MODIFY", + action: "修改了单据", + rawAction: "flow.modify", + nodeName: modNodeName, + comment: "修改了单据", + rawComment: "修改了单据", + automatic: false, + isEbot: false, + skipped: false, + isModification: true, + operator: modPerson, + nextOperators: [] + }); + } + } + } const rawOperator = extractFlowPerson(log.operatorId); const isEbot = isEbotOperator(rawOperator, attributes); @@ -147,17 +211,8 @@ export function parseHoseTimeline( ); let operator = formatOperator(rawOperator, automatic, isEbot); if (operator && !operator.name && staffMap && operator.id) { - const idParts = operator.id.split(":"); - const staff = - staffMap.get(operator.id) || - (idParts.length > 1 && idParts[1] ? staffMap.get(idParts[1]) : undefined); - if (staff?.name) { - operator = { - ...operator, - name: staff.name, - code: staff.code || operator.code - }; - } + const resolved = resolveStaff(operator.id); + if (resolved?.name) operator = resolved; } const rawAction = typeof log.action === "string" ? log.action : undefined; @@ -165,14 +220,101 @@ export function parseHoseTimeline( const rawState = typeof log.state === "string" ? log.state : undefined; const state = translateFlowState(rawState); - const nodeName = - typeof attributes.nodeName === "string" && attributes.nodeName - ? attributes.nodeName - : typeof attributes.nextName === "string" && attributes.nextName - ? attributes.nextName - : action === "打印单据" - ? "打印提醒" - : undefined; + // Node name & Rejection-specific metadata handling + let nodeName: string | undefined; + let rejectTargetNodeName: string | undefined; + let rejectTargetOperator: FlowPerson | undefined; + let resubmitRuleText: string | undefined; + + if (rawAction === "freeflow.reject") { + // 1. Originating node name + let originNode: string | undefined; + if (Array.isArray(allLogs)) { + const match = allLogs.find( + (a: any) => + a && + typeof a === "object" && + a.action === "freeflow.reject" && + (a.ownerId === log.operatorId || + Math.abs((Number(a.updateTime) || 0) - (currentTime || 0)) < 2000) + ); + if (match && typeof (match as any).nodeName === "string") { + originNode = (match as any).nodeName.trim(); + } + } + if (!originNode && attributes.nodeId) { + const match = sortedLogs.find( + (l: any) => + l && + typeof l === "object" && + l.attributes?.nodeId === attributes.nodeId && + l.action !== "freeflow.reject" && + l.attributes?.nodeName + ); + if (match) originNode = String((match as any).attributes.nodeName).trim(); + } + if (!originNode) { + const opId = typeof log.operatorId === "object" ? (log.operatorId as any)?.id : log.operatorId; + const match = sortedLogs.find((l: any) => { + const lOpId = typeof l.operatorId === "object" ? (l.operatorId as any)?.id : l.operatorId; + return lOpId === opId && l.action !== "freeflow.reject" && l.attributes?.nodeName; + }); + if (match) { + originNode = String((match as any).attributes.nodeName).trim(); + } else if (attributes.nodeName && attributes.nodeName !== "提交人") { + originNode = String(attributes.nodeName).trim(); + } + } + nodeName = originNode || "审批节点"; + + // 2. Target node name + rejectTargetNodeName = + typeof attributes.nodeName === "string" && attributes.nodeName + ? attributes.nodeName.trim() + : typeof attributes.nextName === "string" && attributes.nextName + ? attributes.nextName.trim() + : "提交人"; + + // 3. Target operator person + const nextOpId = typeof log.nextOperatorId === "string" ? log.nextOperatorId : undefined; + if (nextOpId) { + rejectTargetOperator = resolveStaff(nextOpId); + } + if ( + (!rejectTargetOperator || !rejectTargetOperator.name) && + (rejectTargetNodeName === "提交人" || rejectTargetNodeName.includes("提交")) && + submitterId + ) { + rejectTargetOperator = resolveStaff(submitterId); + } + + // 4. Resubmit rule text + const method = String(attributes.resubmitMethod || "").toUpperCase(); + const opDisplayName = operator?.name || "原审批人"; + if (method === "TO_REJECTOR") { + resubmitRuleText = `重新提交后由${opDisplayName}继续审批`; + } else if ( + method === "START_OVER" || + method === "TO_START" || + method === "ALL" || + method === "RE_START" + ) { + resubmitRuleText = "重新提交后重新全流程审批"; + } else if (method === "NEXT_NODE") { + resubmitRuleText = "重新提交后流转至下一节点"; + } else { + resubmitRuleText = `重新提交后由${opDisplayName}继续审批`; + } + } else { + nodeName = + typeof attributes.nodeName === "string" && attributes.nodeName + ? attributes.nodeName + : typeof attributes.nextName === "string" && attributes.nextName + ? attributes.nextName + : action === "打印单据" + ? "打印提醒" + : undefined; + } const rawComment = typeof attributes.comment === "string" ? attributes.comment : undefined; const comment = cleanCommentText(rawComment); @@ -186,7 +328,7 @@ export function parseHoseTimeline( ? [log.nextOperatorId] : []; const nextOperators = nextIds - .map(extractFlowPerson) + .map(resolveStaff) .filter((p): p is FlowPerson => Boolean(p)); const nodeId = @@ -196,11 +338,10 @@ export function parseHoseTimeline( ? log.nodeId : undefined; - return { + entries.push({ id: typeof log.id === "string" ? log.id : undefined, nodeId, time: currentTime, - durationMs, state, rawState, action, @@ -212,9 +353,25 @@ export function parseHoseTimeline( isEbot, skipped, operator, - nextOperators - }; - }); + nextOperators, + rejectTargetNodeName, + rejectTargetOperator, + resubmitRuleText, + isModification: false + }); + } + + // Sort all entries (including modification entries) chronologically and compute durations + entries.sort((a, b) => (Number(a.time) || 0) - (Number(b.time) || 0)); + for (let i = 0; i < entries.length; i++) { + const cur = entries[i]!; + const next = entries[i + 1]; + if (cur.time !== undefined && next?.time !== undefined && next.time >= cur.time) { + cur.durationMs = next.time - cur.time; + } + } + + return entries; } export function parseHosePending( @@ -453,7 +610,11 @@ export function extractRejections(history: HoseFlowTimelineEntry[]): HoseRejecti operator: entry.operator, isEbot: entry.isEbot, reason: entry.comment || "未填写驳回原因", - rawComment: entry.rawComment + rawComment: entry.rawComment, + fromNodeName: entry.nodeName, + targetNodeName: entry.rejectTargetNodeName, + targetOperator: entry.rejectTargetOperator, + resubmitRuleText: entry.resubmitRuleText })); } @@ -468,7 +629,13 @@ export function parseHoseOpenComposite( if (!flowDetails) return undefined; const form = (flowDetails.form || {}) as Record; - const history = parseHoseTimeline(flowDetails.logs || [], staffMap); + const submitterId = + typeof form.submitterId === "string" + ? form.submitterId + : typeof flowDetails.ownerId === "string" + ? flowDetails.ownerId + : undefined; + const history = parseHoseTimeline(flowDetails.logs || [], staffMap, allLogs, submitterId); const rawState = flowDetails.state; const state = translateFlowState(rawState); const rawStateUpper = String(rawState || "").toUpperCase(); @@ -724,7 +891,9 @@ export function formatHumanOpinionLines(events: HoseFlowTimelineEntry[]): string : opName; let comment = ev.comment; if (!comment) { - if (ev.rawAction === "freeflow.agree" || ev.action === "审批同意") { + if (ev.rawAction === "flow.modify" || ev.action === "修改了单据" || ev.isModification) { + comment = "修改了单据"; + } else if (ev.rawAction === "freeflow.agree" || ev.action === "审批同意") { comment = "同意"; } else if (ev.rawAction === "freeflow.autoAgree") { comment = "自动同意"; @@ -761,7 +930,10 @@ export function formatNumberedHumanOpinions( } if (mode === "forward") { - const all = [...historyLines, ...pendingLines]; + // If any history line records document modification ("修改了单据"), place all modification lines at the top + const modLines = historyLines.filter((l) => l.includes("修改了单据")); + const normalHistory = historyLines.filter((l) => !l.includes("修改了单据")); + const all = [...modLines, ...normalHistory, ...pendingLines]; return all.map((line, idx) => `${idx + 1}. ${line}`).join("\n"); } @@ -788,13 +960,15 @@ export function formatRejectionComment( rejectEvent?: HoseFlowTimelineEntry, rejectionDetail?: HoseRejectionDetail, mar?: Record, - history?: HoseFlowTimelineEntry[] + history?: HoseFlowTimelineEntry[], + flow?: HoseFlowDetail ): { comment: string; operator?: FlowPerson } { const op = rejectEvent?.operator || rejectionDetail?.operator || (mar as any)?.operator; const opName = op?.name || op?.id || (mar as any)?.operatorName || ""; let rawNodeName = ( rejectEvent?.nodeName || + rejectionDetail?.fromNodeName || rejectionDetail?.nodeName || (mar as any)?.nodeName || "" @@ -810,20 +984,18 @@ export function formatRejectionComment( rawNodeName = ""; } - // In Hose, freeflow.reject often records target node "提交人" (meaning rejected back to submitter) - // If we have an operator name, lookup their actual approval nodeName in history - if ((!rawNodeName || rawNodeName === "提交人") && opName && history) { + // If nodeName is still missing or default, lookup their actual approval nodeName in history + if ((!rawNodeName || rawNodeName === "提交人" || rawNodeName === "审批节点") && opName && history) { const matchedLog = history.find( (h) => h.operator?.name === opName && h.nodeName && h.nodeName.trim() !== "提交人" && - !h.isEbot + !h.isEbot && + h.rawAction !== "freeflow.reject" ); if (matchedLog?.nodeName) { rawNodeName = matchedLog.nodeName.trim(); - } else if (rawNodeName === "提交人") { - rawNodeName = "驳回至提交人"; } } @@ -831,23 +1003,43 @@ export function formatRejectionComment( rejectEvent?.comment || rejectionDetail?.reason || (mar as any)?.rejectComment || - "审批驳回"; + "修改"; - let commentStr = rawComment; + let mainLine = rawComment; if (rawNodeName && opName) { if (!rawComment.startsWith(`${rawNodeName}(${opName}):`)) { - commentStr = `${rawNodeName}(${opName}): ${rawComment}`; + mainLine = `${rawNodeName}(${opName}): ${rawComment}`; } } else if (opName) { if (!rawComment.startsWith(`${opName}:`)) { - commentStr = `${opName}: ${rawComment}`; + mainLine = `${opName}: ${rawComment}`; } } else if (rawNodeName) { if (!rawComment.startsWith(`${rawNodeName}:`)) { - commentStr = `${rawNodeName}: ${rawComment}`; + mainLine = `${rawNodeName}: ${rawComment}`; } } + // Target node & operator + const targetNode = + rejectEvent?.rejectTargetNodeName || + rejectionDetail?.targetNodeName || + "提交人"; + const targetOpName = + rejectEvent?.rejectTargetOperator?.name || + rejectionDetail?.targetOperator?.name || + flow?.submitter?.name; + const targetStr = targetOpName ? `${targetNode}(${targetOpName})` : targetNode; + + // Resubmit rule text + const ruleStr = + rejectEvent?.resubmitRuleText || + rejectionDetail?.resubmitRuleText || + (opName ? `重新提交后由${opName}继续审批` : "重新提交后继续审批"); + + // 样式 2-B(三行展开式,驳回目标与重审规则各占一行) + const commentStr = `${mainLine}\n↳ 驳回至: ${targetStr}\n↳ ${ruleStr}`; + return { comment: commentStr, operator: op @@ -1010,7 +1202,14 @@ export function alignApprovalRunsWithHoseFlow( (e) => (e.time ?? 0) > effectiveRunTime + 5000 && e.isEbot && - (e.rawAction === "freeflow.agree" || e.action === "智能审批" || e.nodeName?.includes("智能")) + (e.nodeName?.includes("智能") || + e.nodeName?.includes("AI") || + e.action?.includes("智能") || + e.comment?.includes("AI") || + e.comment?.includes("approval-result")) && + !e.nodeName?.includes("费用标准检查") && + !e.nodeName?.includes("标准检查") && + !e.nodeName?.includes("预算") ); if (subsequentEbot) { @@ -1147,7 +1346,7 @@ export function alignApprovalRunsWithHoseFlow( eHumanAction = "审批驳回"; auditDrift = false; auditDriftReason = undefined; - const rejInfo = formatRejectionComment(rejectEvent, undefined, mar, history); + const rejInfo = formatRejectionComment(rejectEvent, undefined, mar, history, flow); eHumanComment = rejInfo.comment; operator = rejInfo.operator; } else if (retractEvent || isRunCancelledInSeal || (!rejectEvent && marSourceStatus.includes("单据撤回"))) { @@ -1195,11 +1394,20 @@ export function alignApprovalRunsWithHoseFlow( eHumanAction = "审批驳回"; auditDrift = false; auditDriftReason = undefined; - const rejInfo = formatRejectionComment(rejectEvent, undefined, mar, history); + const rejInfo = formatRejectionComment(rejectEvent, undefined, mar, history, flow); eHumanComment = rejInfo.comment; operator = rejInfo.operator; } else if (isFlowCompleted || (!flow && isRunApprovedInSeal)) { - eHumanAction = isFlowPaid ? "已支付" : "审批通过"; + const hasModification = windowEvents.some( + (e) => e.rawAction === "flow.modify" || e.isModification || e.action === "修改了单据" + ); + eHumanAction = isFlowPaid + ? hasModification + ? "已支付 (中途修改)" + : "已支付" + : hasModification + ? "审批通过 (中途修改)" + : "审批通过"; const opinionLines = formatHumanOpinionLines(subsequentHumanEvents); for (const ev of subsequentHumanEvents) { @@ -1251,7 +1459,7 @@ export function alignApprovalRunsWithHoseFlow( eHumanAction = "审批驳回"; auditDrift = false; auditDriftReason = undefined; - const rejInfo = formatRejectionComment(undefined, flow?.rejections?.[0], mar, history); + const rejInfo = formatRejectionComment(undefined, flow?.rejections?.[0], mar, history, flow); eHumanComment = rejInfo.comment; operator = rejInfo.operator; } else { diff --git a/src/domains/hose/types.ts b/src/domains/hose/types.ts index 35f5185..2102002 100644 --- a/src/domains/hose/types.ts +++ b/src/domains/hose/types.ts @@ -56,7 +56,11 @@ export const HoseFlowTimelineEntrySchema = z.object({ isEbot: z.boolean().default(false), skipped: z.boolean().default(false), operator: FlowPersonSchema.optional(), - nextOperators: z.array(FlowPersonSchema).default([]) + nextOperators: z.array(FlowPersonSchema).default([]), + rejectTargetNodeName: z.string().optional(), + rejectTargetOperator: FlowPersonSchema.optional(), + resubmitRuleText: z.string().optional(), + isModification: z.boolean().default(false) }); export type HoseFlowTimelineEntry = z.infer; @@ -98,7 +102,11 @@ export const HoseRejectionDetailSchema = z.object({ operator: FlowPersonSchema.optional(), isEbot: z.boolean().default(false), reason: z.string(), - rawComment: z.string().optional() + rawComment: z.string().optional(), + fromNodeName: z.string().optional(), + targetNodeName: z.string().optional(), + targetOperator: FlowPersonSchema.optional(), + resubmitRuleText: z.string().optional() }); export type HoseRejectionDetail = z.infer;