From 71a9ec2eda4c47d46043efb212d9feacd7ab2697 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Feb 2026 00:05:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E5=AE=A1=E6=89=B9=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ApprovalRecord 接口中添加 node_id 和 approver_id 字段 - 添加调试日志帮助排查问题 Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/approval/detail.tsx | 32 +++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/approval/detail.tsx b/frontend/src/pages/approval/detail.tsx index 066a9af..991f5a3 100644 --- a/frontend/src/pages/approval/detail.tsx +++ b/frontend/src/pages/approval/detail.tsx @@ -41,8 +41,10 @@ const businessTypeConfig: Record = { interface ApprovalRecord { id: number + node_id: number node_type: string action: string + approver_id: number comment: string | null created_at: string approver: { @@ -159,6 +161,15 @@ export default function ApprovalDetail() { // 检查是否是当前审批人 const isCurrentApprover = () => { + console.log('🔍 isCurrentApprover 检查:', { + hasDetail: !!detail, + hasUser: !!user, + userId: user?.id, + status: detail?.status, + currentNodes: detail?.current_nodes, + nodesCount: detail?.flow?.nodes?.length, + }) + if (!detail || !user) return false if (detail.status !== 'pending') return false @@ -166,17 +177,36 @@ export default function ApprovalDetail() { const currentNodeIds = detail.current_nodes || [] const nodes = detail.flow?.nodes || [] + console.log('🔍 节点信息:', { + currentNodeIds, + nodes: nodes.map(n => ({ id: n.id, name: n.name, approvers: n.approvers })), + }) + for (const nodeId of currentNodeIds) { const node = nodes.find((n) => n.id === nodeId) + console.log(`🔍 检查节点 ${nodeId}:`, { + node, + approvers: node?.approvers, + userId: user.id, + isInApprovers: node?.approvers?.includes(user.id), + }) if (node && node.approvers && node.approvers.includes(user.id)) { // 检查是否已审批 - 使用 approver_id 而不是 approver.id const hasApproved = detail.records.some( (r) => r.node_id === nodeId && r.approver_id === user.id ) - if (!hasApproved) return true + console.log(`🔍 节点 ${nodeId} 审批状态:`, { + hasApproved, + records: detail.records.filter(r => r.node_id === nodeId), + }) + if (!hasApproved) { + console.log('✅ 是当前审批人!') + return true + } } } + console.log('❌ 不是当前审批人') return false }