feat:【bpm 工作流】审批人自选时,相同节点共享数据

pull/796/MERGE
YunaiV 2025-08-02 22:08:32 +08:00
parent 120499a07d
commit ca17d5ac21
2 changed files with 49 additions and 9 deletions

View File

@ -51,8 +51,10 @@
>
<div class="ml-10px -mt-15px -mb-35px">
<ProcessInstanceTimeline
ref="nextAssigneesTimelineRef"
:activity-nodes="nextAssigneesActivityNode"
:show-status-icon="false"
:enable-approve-user-select="true"
@select-user-confirm="selectNextAssigneesConfirm"
/>
</div>
@ -571,6 +573,7 @@ const approveFormRef = ref<FormInstance>()
const signRef = ref()
const approveSignFormRef = ref()
const nextAssigneesActivityNode = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([]) //
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<string, any[]> = {} // 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 {
//

View File

@ -15,7 +15,7 @@
>
<img class="w-full h-full" :src="getApprovalNodeImg(activity.nodeType)" alt="" />
<div
v-if="showStatusIcon"
v-if="props.showStatusIcon"
class="position-absolute top-17px left-17px rounded-full flex items-center p-1px border-2 border-white border-solid"
:style="{ backgroundColor: getApprovalNodeColor(activity.status) }"
>
@ -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))
"
>
<!-- && activity.nodeType === NodeType.USER_TASK_NODE -->
<el-tooltip content="添加用户" placement="left">
<el-button
class="!px-6px"
@ -119,7 +119,7 @@
</template>
<!-- 信息任务 ICON -->
<div
v-if="showStatusIcon && onlyStatusIconShow.includes(task.status)"
v-if="props.showStatusIcon && onlyStatusIconShow.includes(task.status)"
class="position-absolute top-19px left-23px rounded-full flex items-center p-1px border-2 border-white border-solid"
:style="{ backgroundColor: statusIconMap2[task.status]?.color }"
>
@ -165,7 +165,7 @@
<!-- 信息任务 ICON -->
<div
v-if="showStatusIcon"
v-if="props.showStatusIcon"
class="position-absolute top-20px left-24px rounded-full flex items-center p-1px border-2 border-white border-solid"
:style="{ backgroundColor: statusIconMap2['-1']?.color }"
>
@ -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<string, any[]>) => {
Object.keys(data).forEach((activityId) => {
customApproveUsers.value[activityId] = data[activityId] || []
})
}
//
defineExpose({ setCustomApproveUsers, batchSetCustomApproveUsers })
</script>