diff --git a/src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue b/src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue index 7a5559386..1b7d5c73d 100644 --- a/src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue +++ b/src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue @@ -51,8 +51,10 @@ >
@@ -571,6 +573,7 @@ const approveFormRef = ref() const signRef = ref() const approveSignFormRef = ref() const nextAssigneesActivityNode = ref([]) // 下一个审批节点信息 +const nextAssigneesTimelineRef = ref() // 下一个节点审批人时间线组件的引用 const approveReasonForm = reactive({ reason: '', signPicUrl: '', @@ -717,6 +720,10 @@ const closePopover = (type: string, formRef: FormInstance | undefined) => { } popOverVisible.value[type] = false nextAssigneesActivityNode.value = [] + // 清理 Timeline 组件中的自定义审批人数据 + if (nextAssigneesTimelineRef.value) { + nextAssigneesTimelineRef.value.batchSetCustomApproveUsers({}) + } } /** 流程通过时,根据表单变量查询新的流程节点,判断下一个节点类型是否为自选审批人 */ @@ -729,6 +736,7 @@ const initNextAssigneesFormField = async () => { processVariablesStr: JSON.stringify(variables) }) if (data && data.length > 0) { + const customApproveUsersData: Record = {} // 用于收集需要设置到 Timeline 组件的自定义审批人数据 data.forEach((node: any) => { if ( // 情况一:当前节点没有审批人,并且是发起人自选 @@ -740,7 +748,18 @@ const initNextAssigneesFormField = async () => { ) { nextAssigneesActivityNode.value.push(node) } + + // 如果节点有 candidateUsers,设置到 customApproveUsers 中 + if (node.candidateUsers && node.candidateUsers.length > 0) { + customApproveUsersData[node.id] = node.candidateUsers + } }) + + // 将 candidateUsers 设置到 Timeline 组件中 + await nextTick() // 等待下一个 tick,确保 Timeline 组件已经渲染 + if (nextAssigneesTimelineRef.value && Object.keys(customApproveUsersData).length > 0) { + nextAssigneesTimelineRef.value.batchSetCustomApproveUsers(customApproveUsersData) + } } } @@ -803,6 +822,10 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) => await TaskApi.approveTask(data) popOverVisible.value.approve = false nextAssigneesActivityNode.value = [] + // 清理 Timeline 组件中的自定义审批人数据 + if (nextAssigneesTimelineRef.value) { + nextAssigneesTimelineRef.value.batchSetCustomApproveUsers({}) + } message.success('审批通过成功') } else { // 审批不通过数据 diff --git a/src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue b/src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue index 8f55c6c4b..91f333e8e 100644 --- a/src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue +++ b/src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue @@ -15,7 +15,7 @@ >
@@ -55,13 +55,13 @@ class="flex flex-wrap gap2 items-center" v-if=" isEmpty(activity.tasks) && - isEmpty(activity.candidateUsers) && - (CandidateStrategy.START_USER_SELECT === activity.candidateStrategy || - CandidateStrategy.APPROVE_USER_SELECT === activity.candidateStrategy) + ((CandidateStrategy.START_USER_SELECT === activity.candidateStrategy && + isEmpty(activity.candidateUsers)) || + (props.enableApproveUserSelect && + CandidateStrategy.APPROVE_USER_SELECT === activity.candidateStrategy)) " > -
@@ -165,7 +165,7 @@
@@ -198,13 +198,15 @@ import transactorSvg from '@/assets/svgs/bpm/transactor.svg' import childProcessSvg from '@/assets/svgs/bpm/child-process.svg' defineOptions({ name: 'BpmProcessInstanceTimeline' }) -withDefaults( +const props = withDefaults( defineProps<{ activityNodes: ProcessInstanceApi.ApprovalNodeInfo[] // 审批节点信息 showStatusIcon?: boolean // 是否显示头像右下角状态图标 + enableApproveUserSelect?: boolean // 是否开启审批人自选功能 }>(), { - showStatusIcon: true // 默认值为 true + showStatusIcon: true, // 默认值为 true + enableApproveUserSelect: false // 默认值为 false } ) const { push } = useRouter() // 路由 @@ -341,4 +343,19 @@ const handleChildProcess = (activity: any) => { } }) } + +/** 设置自定义审批人 */ +const setCustomApproveUsers = (activityId: string, users: any[]) => { + customApproveUsers.value[activityId] = users || [] +} + +/** 批量设置多个节点的自定义审批人 */ +const batchSetCustomApproveUsers = (data: Record) => { + Object.keys(data).forEach((activityId) => { + customApproveUsers.value[activityId] = data[activityId] || [] + }) +} + +// 暴露方法给父组件 +defineExpose({ setCustomApproveUsers, batchSetCustomApproveUsers })