Skip to content

Commit 3b5a0ae

Browse files
committed
fix: 流程再次发起,预测节点查询
1 parent c2e99fb commit 3b5a0ae

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

src/views/bpm/processInstance/create/ProcessDefinitionDetail.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const activityNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([]) // 审批
117117
118118
/** 设置表单信息、获取流程图数据 **/
119119
const initProcessInfo = async (row: any, formVariables?: any) => {
120+
120121
// 重置指定审批人
121122
startUserSelectTasks.value = []
122123
startUserSelectAssignees.value = {}
@@ -138,9 +139,13 @@ const initProcessInfo = async (row: any, formVariables?: any) => {
138139
await nextTick()
139140
fApi.value?.btn.show(false) // 隐藏提交按钮
140141
141-
// 获取流程审批信息
142-
await getApprovalDetail(row)
143-
142+
// 获取流程审批信息,当再次发起时,流程审批节点要根据原始表单参数预测出来
143+
const param = {
144+
id: row.id,
145+
processVariablesStr: JSON.stringify(formVariables)
146+
}
147+
await getApprovalDetail(param)
148+
// }
144149
// 加载流程图
145150
const processDefinitionDetail = await DefinitionApi.getProcessDefinition(row.id)
146151
if (processDefinitionDetail) {

src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
:rows="4"
4545
/>
4646
</el-form-item>
47-
<el-form-item label="下一个节点的审批人" prop="nextAssignees" v-if="nextAssigneesVisible">
47+
<el-form-item label="下一个节点的审批人" prop="nextAssignees" v-if="nextAssigneesActivityNode.length > 0">
4848
<div class="ml-10px -mt-15px -mb-35px">
4949
<ProcessInstanceTimeline
5050
:activity-nodes="nextAssigneesActivityNode"
@@ -522,6 +522,7 @@ import { BpmModelFormType, BpmProcessInstanceStatus } from '@/utils/constants'
522522
import type { FormInstance, FormRules } from 'element-plus'
523523
import SignDialog from './SignDialog.vue'
524524
import ProcessInstanceTimeline from '../detail/ProcessInstanceTimeline.vue'
525+
import { isEmpty } from '@/utils/is'
525526
526527
defineOptions({ name: 'ProcessInstanceBtnContainer' })
527528
@@ -565,7 +566,6 @@ const reasonRequire = ref()
565566
const approveFormRef = ref<FormInstance>()
566567
const signRef = ref()
567568
const approveSignFormRef = ref()
568-
const nextAssigneesVisible = ref(false) // 是否显示下一个节点的审批人
569569
const nextAssigneesActivityNode = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([]) // 下一个审批节点信息
570570
const approveReasonForm = reactive({
571571
reason: '',
@@ -711,7 +711,7 @@ const closePopover = (type: string, formRef: FormInstance | undefined) => {
711711
formRef.resetFields()
712712
}
713713
popOverVisible.value[type] = false
714-
nextAssigneesVisible.value = false
714+
nextAssigneesActivityNode.value = []
715715
}
716716
717717
/** 流程通过时,根据表单变量查询新的流程节点,判断下一个节点类型是否为自选审批人 */
@@ -726,23 +726,14 @@ const initNextAssigneesFormField = async () => {
726726
if (data && data.length > 0) {
727727
data.forEach((node: any) => {
728728
if (
729-
node.candidateStrategy === CandidateStrategy.START_USER_SELECT &&
730-
node.candidateUsers && node.task
729+
isEmpty(node.tasks) &&
730+
isEmpty(node.candidateUsers) &&
731+
(CandidateStrategy.START_USER_SELECT === node.candidateStrategy ||
732+
CandidateStrategy.APPROVE_USER_SELECT === node.candidateStrategy)
731733
) {
732734
nextAssigneesActivityNode.value.push(node)
733735
}
734736
})
735-
if (nextAssigneesActivityNode.value.length > 0) {
736-
nextAssigneesVisible.value = true
737-
}
738-
739-
// // 自选审批人,则弹出选择审批人弹窗
740-
// // TODO @小北:需要考虑下,这里的 nextNode 可能是多个节点,需要怎么处理;类似你在后端的处理哈
741-
// // TODO @小北:有点纠结,是不是写个预测下一个节点的接口,更合适?
742-
// nextAssigneesActivityNode.value = [nextNode]
743-
// nextAssigneesVisible.value = true
744-
// }
745-
// // TODO @小北:情况二:审批人选择的情况
746737
}
747738
}
748739
@@ -767,7 +758,8 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
767758
768759
if (pass) {
769760
// 如果需要自选审批人,则校验自选审批人
770-
if (nextAssigneesVisible.value && Object.keys(approveReasonForm.nextAssignees).length === 0) {
761+
if (Object.keys(nextAssigneesActivityNode.value).length > 0
762+
&& Object.keys(approveReasonForm.nextAssignees).length === 0) {
771763
message.warning('下一个节点的审批人不能为空!')
772764
return
773765
}
@@ -793,7 +785,7 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
793785
}
794786
await TaskApi.approveTask(data)
795787
popOverVisible.value.approve = false
796-
nextAssigneesVisible.value = false
788+
nextAssigneesActivityNode.value = []
797789
message.success('审批通过成功')
798790
} else {
799791
// 审批不通过数据

0 commit comments

Comments
 (0)