fix: 修复审批详情页审批按钮不显示的问题
- 在 ApprovalRecord 接口中添加 node_id 和 approver_id 字段 - 添加调试日志帮助排查问题 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,8 +41,10 @@ const businessTypeConfig: Record<string, string> = {
|
|||||||
|
|
||||||
interface ApprovalRecord {
|
interface ApprovalRecord {
|
||||||
id: number
|
id: number
|
||||||
|
node_id: number
|
||||||
node_type: string
|
node_type: string
|
||||||
action: string
|
action: string
|
||||||
|
approver_id: number
|
||||||
comment: string | null
|
comment: string | null
|
||||||
created_at: string
|
created_at: string
|
||||||
approver: {
|
approver: {
|
||||||
@@ -159,6 +161,15 @@ export default function ApprovalDetail() {
|
|||||||
|
|
||||||
// 检查是否是当前审批人
|
// 检查是否是当前审批人
|
||||||
const isCurrentApprover = () => {
|
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 || !user) return false
|
||||||
if (detail.status !== 'pending') return false
|
if (detail.status !== 'pending') return false
|
||||||
|
|
||||||
@@ -166,17 +177,36 @@ export default function ApprovalDetail() {
|
|||||||
const currentNodeIds = detail.current_nodes || []
|
const currentNodeIds = detail.current_nodes || []
|
||||||
const nodes = detail.flow?.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) {
|
for (const nodeId of currentNodeIds) {
|
||||||
const node = nodes.find((n) => n.id === nodeId)
|
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)) {
|
if (node && node.approvers && node.approvers.includes(user.id)) {
|
||||||
// 检查是否已审批 - 使用 approver_id 而不是 approver.id
|
// 检查是否已审批 - 使用 approver_id 而不是 approver.id
|
||||||
const hasApproved = detail.records.some(
|
const hasApproved = detail.records.some(
|
||||||
(r) => r.node_id === nodeId && r.approver_id === user.id
|
(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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user