Skip to content

Commit 202d4b6

Browse files
YunaiVgitee-org
authored andcommitted
!723 fix: 流程再次发起,预测节点查询
Merge pull request !723 from SamllNorth_Lee/feature/bpm
2 parents a26cb12 + 8244050 commit 202d4b6

File tree

5 files changed

+58
-34
lines changed

5 files changed

+58
-34
lines changed

src/api/bpm/processInstance/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ export const getApprovalDetail = async (params: any) => {
9393
return await request.get({ url: '/bpm/process-instance/get-approval-detail', params })
9494
}
9595

96+
// 获取下一个执行的流程节点
97+
export const getNextApprovalNodes = async (params: any) => {
98+
return await request.get({ url: '/bpm/process-instance/get-next-approval-nodes', params })
99+
}
100+
96101
// 获取表单字段权限
97102
export const getFormFieldsPermission = async (params: any) => {
98103
return await request.get({ url: '/bpm/process-instance/get-form-fields-permission', params })

src/components/SimpleProcessDesignerV2/src/consts.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ export enum CandidateStrategy {
162162
* 指定用户
163163
*/
164164
USER = 30,
165+
/**
166+
* 审批人自选
167+
*/
168+
APPROVE_USER_SELECT = 34,
165169
/**
166170
* 发起人自选
167171
*/
@@ -542,6 +546,7 @@ export const CANDIDATE_STRATEGY: DictDataVO[] = [
542546
{ label: '连续多级部门负责人', value: CandidateStrategy.MULTI_LEVEL_DEPT_LEADER },
543547
{ label: '指定岗位', value: CandidateStrategy.MULTI_LEVEL_DEPT_LEADER },
544548
{ label: '发起人自选', value: CandidateStrategy.START_USER_SELECT },
549+
{ label: '审批人自选', value: CandidateStrategy.APPROVE_USER_SELECT },
545550
{ label: '发起人本人', value: CandidateStrategy.START_USER },
546551
{ label: '发起人部门负责人', value: CandidateStrategy.START_USER_DEPT_LEADER },
547552
{ label: '发起人连续部门负责人', value: CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER },

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

Lines changed: 7 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,12 @@ 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+
await getApprovalDetail({
144+
id: row.id,
145+
processVariablesStr: JSON.stringify(formVariables)
146+
})
147+
// }
144148
// 加载流程图
145149
const processDefinitionDetail = await DefinitionApi.getProcessDefinition(row.id)
146150
if (processDefinitionDetail) {

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

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@
4444
:rows="4"
4545
/>
4646
</el-form-item>
47-
<el-form-item label="下一个节点的审批人" prop="nextAssignees" v-if="nextAssigneesVisible">
47+
<el-form-item
48+
label="下一个节点的审批人"
49+
prop="nextAssignees"
50+
v-if="nextAssigneesActivityNode.length > 0"
51+
>
4852
<div class="ml-10px -mt-15px -mb-35px">
4953
<ProcessInstanceTimeline
5054
:activity-nodes="nextAssigneesActivityNode"
@@ -522,6 +526,7 @@ import { BpmModelFormType, BpmProcessInstanceStatus } from '@/utils/constants'
522526
import type { FormInstance, FormRules } from 'element-plus'
523527
import SignDialog from './SignDialog.vue'
524528
import ProcessInstanceTimeline from '../detail/ProcessInstanceTimeline.vue'
529+
import { isEmpty } from '@/utils/is'
525530
526531
defineOptions({ name: 'ProcessInstanceBtnContainer' })
527532
@@ -565,7 +570,6 @@ const reasonRequire = ref()
565570
const approveFormRef = ref<FormInstance>()
566571
const signRef = ref()
567572
const approveSignFormRef = ref()
568-
const nextAssigneesVisible = ref(false) // 是否显示下一个节点的审批人
569573
const nextAssigneesActivityNode = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([]) // 下一个审批节点信息
570574
const approveReasonForm = reactive({
571575
reason: '',
@@ -711,43 +715,51 @@ const closePopover = (type: string, formRef: FormInstance | undefined) => {
711715
formRef.resetFields()
712716
}
713717
popOverVisible.value[type] = false
714-
nextAssigneesVisible.value = false
718+
nextAssigneesActivityNode.value = []
715719
}
716720
717721
/** 流程通过时,根据表单变量查询新的流程节点,判断下一个节点类型是否为自选审批人 */
718722
const initNextAssigneesFormField = async () => {
719723
// 获取修改的流程变量, 暂时只支持流程表单
720724
const variables = getUpdatedProcessInstanceVariables()
721-
const data = await ProcessInstanceApi.getApprovalDetail({
725+
const data = await ProcessInstanceApi.getNextApprovalNodes({
722726
processInstanceId: props.processInstance.id,
727+
taskId: runningTask.value.id,
723728
processVariablesStr: JSON.stringify(variables)
724729
})
725-
726-
const activityId = data.todoTask?.taskDefinitionKey
727-
if (data.activityNodes && data.activityNodes.length > 0) {
728-
// 找到当前节点的索引
729-
const currentNodeIndex = data.activityNodes.findIndex((node: any) => node.id === activityId)
730-
const nextNode = data.activityNodes[currentNodeIndex + 1]
731-
// 情况一:发起人选择审批人:此时一般是因为条件发生变化,需要当前审批人补充选择
732-
if (
733-
nextNode.candidateStrategy === CandidateStrategy.START_USER_SELECT &&
734-
!nextNode.tasks &&
735-
nextNode.candidateUsers?.length === 0
736-
) {
737-
// 自选审批人,则弹出选择审批人弹窗
738-
// TODO @小北:需要考虑下,这里的 nextNode 可能是多个节点,需要怎么处理;类似你在后端的处理哈
739-
// TODO @小北:有点纠结,是不是写个预测下一个节点的接口,更合适?
740-
nextAssigneesActivityNode.value = [nextNode]
741-
nextAssigneesVisible.value = true
742-
}
743-
// TODO @小北:情况二:审批人选择的情况
730+
if (data && data.length > 0) {
731+
data.forEach((node: any) => {
732+
// 如果是发起人自选,并且没有审批人 或者 是审批人自选
733+
if (
734+
(isEmpty(node.tasks) &&
735+
isEmpty(node.candidateUsers) &&
736+
CandidateStrategy.START_USER_SELECT === node.candidateStrategy) ||
737+
CandidateStrategy.APPROVE_USER_SELECT === node.candidateStrategy
738+
) {
739+
nextAssigneesActivityNode.value.push(node)
740+
}
741+
})
744742
}
745743
}
746744
747745
/** 选择下一个节点的审批人 */
748746
const selectNextAssigneesConfirm = (id: string, userList: any[]) => {
749747
approveReasonForm.nextAssignees[id] = userList?.map((item: any) => item.id)
750748
}
749+
/** 审批通过时,校验每个自选审批人的节点是否都已配置了审批人 */
750+
const validateNextAssignees = () => {
751+
// 如果需要自选审批人,则校验自选审批人
752+
if (Object.keys(nextAssigneesActivityNode.value).length > 0) {
753+
// 校验每个节点是否都已配置审批人
754+
for (const item of nextAssigneesActivityNode.value) {
755+
if (isEmpty(approveReasonForm.nextAssignees[item.id])) {
756+
message.warning('下一个节点的审批人不能为空!')
757+
return false
758+
}
759+
}
760+
}
761+
return true
762+
}
751763
752764
/** 处理审批通过和不通过的操作 */
753765
const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) => {
@@ -764,11 +776,8 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
764776
}
765777
766778
if (pass) {
767-
// 如果需要自选审批人,则校验自选审批人
768-
if (nextAssigneesVisible.value && Object.keys(approveReasonForm.nextAssignees).length === 0) {
769-
message.warning('下一个节点的审批人不能为空!')
770-
return
771-
}
779+
const nextAssigneesValid = validateNextAssignees()
780+
if (!nextAssigneesValid) return
772781
const variables = getUpdatedProcessInstanceVariables()
773782
// 审批通过数据
774783
const data = {
@@ -791,7 +800,7 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
791800
}
792801
await TaskApi.approveTask(data)
793802
popOverVisible.value.approve = false
794-
nextAssigneesVisible.value = false
803+
nextAssigneesActivityNode.value = []
795804
message.success('审批通过成功')
796805
} else {
797806
// 审批不通过数据

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
v-if="
4444
isEmpty(activity.tasks) &&
4545
isEmpty(activity.candidateUsers) &&
46-
CandidateStrategy.START_USER_SELECT === activity.candidateStrategy
46+
(CandidateStrategy.START_USER_SELECT === activity.candidateStrategy ||
47+
CandidateStrategy.APPROVE_USER_SELECT === activity.candidateStrategy)
4748
"
4849
>
4950
<!-- && activity.nodeType === NodeType.USER_TASK_NODE -->
@@ -252,7 +253,7 @@ const nodeTypeSvgMap = {
252253
// 并行分支节点
253254
[NodeType.PARALLEL_BRANCH_NODE]: { color: '#14bb83', svg: parallelSvg },
254255
// 子流程节点
255-
[NodeType.CHILD_PROCESS_NODE]: { color: '#14bb83', svg: childProcessSvg },
256+
[NodeType.CHILD_PROCESS_NODE]: { color: '#14bb83', svg: childProcessSvg }
256257
}
257258
258259
// 只有只有状态是 -1、0、1 才展示头像右小角状态小icon

0 commit comments

Comments
 (0)