44
44
:rows =" 4"
45
45
/>
46
46
</el-form-item >
47
- <el-form-item
48
- label =" 选择下一个节点的审批人"
49
- prop =" nextAssignees"
50
- v-if =" dialogVisibleSelectApproveUser"
51
- >
52
- <ProcessInstanceTimeline
53
- ref =" timelineRef"
54
- :activity-nodes =" activityNodes"
55
- :show-status-icon =" false"
56
- @select-user-confirm =" selectUserConfirm"
57
- />
47
+ <el-form-item label =" 下一个节点的审批人" prop =" nextAssignees" v-if =" nextAssigneesVisible" >
48
+ <div class =" ml-10px -mt-15px -mb-35px" >
49
+ <ProcessInstanceTimeline
50
+ :activity-nodes =" nextAssigneesActivityNode"
51
+ :show-status-icon =" false"
52
+ @select-user-confirm =" selectNextAssigneesConfirm"
53
+ />
54
+ </div >
58
55
</el-form-item >
59
56
<el-form-item
60
57
v-if =" runningTask.signEnable"
78
75
>
79
76
{{ getButtonDisplayName(OperationButtonType.APPROVE) }}
80
77
</el-button >
81
- <el-button @click =" closePropover ('approve', approveFormRef)" > 取消 </el-button >
78
+ <el-button @click =" closePopover ('approve', approveFormRef)" > 取消 </el-button >
82
79
</el-form-item >
83
80
</el-form >
84
81
</div >
123
120
>
124
121
{{ getButtonDisplayName(OperationButtonType.REJECT) }}
125
122
</el-button >
126
- <el-button @click =" closePropover ('reject', rejectFormRef)" > 取消 </el-button >
123
+ <el-button @click =" closePopover ('reject', rejectFormRef)" > 取消 </el-button >
127
124
</el-form-item >
128
125
</el-form >
129
126
</div >
181
178
<el-button :disabled =" formLoading" type =" primary" @click =" handleCopy" >
182
179
{{ getButtonDisplayName(OperationButtonType.COPY) }}
183
180
</el-button >
184
- <el-button @click =" closePropover ('copy', copyFormRef)" > 取消 </el-button >
181
+ <el-button @click =" closePopover ('copy', copyFormRef)" > 取消 </el-button >
185
182
</el-form-item >
186
183
</el-form >
187
184
</div >
233
230
<el-button :disabled =" formLoading" type =" primary" @click =" handleTransfer()" >
234
231
{{ getButtonDisplayName(OperationButtonType.TRANSFER) }}
235
232
</el-button >
236
- <el-button @click =" closePropover ('transfer', transferFormRef)" > 取消 </el-button >
233
+ <el-button @click =" closePopover ('transfer', transferFormRef)" > 取消 </el-button >
237
234
</el-form-item >
238
235
</el-form >
239
236
</div >
285
282
<el-button :disabled =" formLoading" type =" primary" @click =" handleDelegate()" >
286
283
{{ getButtonDisplayName(OperationButtonType.DELEGATE) }}
287
284
</el-button >
288
- <el-button @click =" closePropover ('delegate', delegateFormRef)" > 取消 </el-button >
285
+ <el-button @click =" closePopover ('delegate', delegateFormRef)" > 取消 </el-button >
289
286
</el-form-item >
290
287
</el-form >
291
288
</div >
340
337
<el-button :disabled =" formLoading" type =" primary" @click =" handlerAddSign('after')" >
341
338
向后{{ getButtonDisplayName(OperationButtonType.ADD_SIGN) }}
342
339
</el-button >
343
- <el-button @click =" closePropover ('addSign', addSignFormRef)" > 取消 </el-button >
340
+ <el-button @click =" closePopover ('addSign', addSignFormRef)" > 取消 </el-button >
344
341
</el-form-item >
345
342
</el-form >
346
343
</div >
391
388
<el-button :disabled =" formLoading" type =" primary" @click =" handlerDeleteSign()" >
392
389
减签
393
390
</el-button >
394
- <el-button @click =" closePropover ('deleteSign', deleteSignFormRef)" > 取消 </el-button >
391
+ <el-button @click =" closePopover ('deleteSign', deleteSignFormRef)" > 取消 </el-button >
395
392
</el-form-item >
396
393
</el-form >
397
394
</div >
443
440
<el-button :disabled =" formLoading" type =" primary" @click =" handleReturn()" >
444
441
{{ getButtonDisplayName(OperationButtonType.RETURN) }}
445
442
</el-button >
446
- <el-button @click =" closePropover ('return', returnFormRef)" > 取消 </el-button >
443
+ <el-button @click =" closePopover ('return', returnFormRef)" > 取消 </el-button >
447
444
</el-form-item >
448
445
</el-form >
449
446
</div >
487
484
<el-button :disabled =" formLoading" type =" primary" @click =" handleCancel()" >
488
485
确认
489
486
</el-button >
490
- <el-button @click =" closePropover ('cancel', cancelFormRef)" > 取消 </el-button >
487
+ <el-button @click =" closePopover ('cancel', cancelFormRef)" > 取消 </el-button >
491
488
</el-form-item >
492
489
</el-form >
493
490
</div >
@@ -562,14 +559,14 @@ const runningTask = ref<any>() // 运行中的任务
562
559
const approveForm = ref <any >({}) // 审批通过时,额外的补充信息
563
560
const approveFormFApi = ref <any >({}) // approveForms 的 fAPi
564
561
const nodeTypeName = ref (' 审批' ) // 节点类型名称
565
- const activityNodes = ref <ProcessInstanceApi .ApprovalNodeInfo []>([]) // 审批节点信息
566
- const dialogVisibleSelectApproveUser = ref (false ) // 是否显示节点审批人选择框
567
562
568
563
// 审批通过意见表单
569
564
const reasonRequire = ref ()
570
565
const approveFormRef = ref <FormInstance >()
571
566
const signRef = ref ()
572
567
const approveSignFormRef = ref ()
568
+ const nextAssigneesVisible = ref (false ) // 是否显示下一个节点的审批人
569
+ const nextAssigneesActivityNode = ref <ProcessInstanceApi .ApprovalNodeInfo []>([]) // 下一个审批节点信息
573
570
const approveReasonForm = reactive ({
574
571
reason: ' ' ,
575
572
signPicUrl: ' ' ,
@@ -584,6 +581,7 @@ const approveReasonRule = computed(() => {
584
581
nextAssignees: [{ required: true , message: ' 审批人不能为空' , trigger: ' blur' }]
585
582
}
586
583
})
584
+
587
585
// 拒绝表单
588
586
const rejectFormRef = ref <FormInstance >()
589
587
const rejectReasonForm = reactive ({
@@ -681,11 +679,6 @@ watch(
681
679
}
682
680
)
683
681
684
- /** 选择下一个节点的审批人 */
685
- const selectUserConfirm = (id : string , userList : any []) => {
686
- approveReasonForm .nextAssignees [id ] = userList ?.map ((item : any ) => item .id )
687
- }
688
-
689
682
/** 弹出气泡卡 */
690
683
const openPopover = async (type : string ) => {
691
684
if (type === ' approve' ) {
@@ -695,7 +688,7 @@ const openPopover = async (type: string) => {
695
688
message .warning (' 表单校验不通过,请先完善表单!!' )
696
689
return
697
690
}
698
- initNextTaskSelectAssigneeFormField ()
691
+ initNextAssigneesFormField ()
699
692
}
700
693
if (type === ' return' ) {
701
694
// 获取退回节点
@@ -713,41 +706,49 @@ const openPopover = async (type: string) => {
713
706
}
714
707
715
708
/** 关闭气泡卡 */
716
- const closePropover = (type : string , formRef : FormInstance | undefined ) => {
709
+ const closePopover = (type : string , formRef : FormInstance | undefined ) => {
717
710
if (formRef ) {
718
711
formRef .resetFields ()
719
712
}
720
713
popOverVisible .value [type ] = false
721
- dialogVisibleSelectApproveUser .value = false
714
+ nextAssigneesVisible .value = false
722
715
}
723
716
724
- /** // 流程通过时,根据表单变量查询新的流程节点,判断下一个节点类型是否为自选审批人 */
725
- const initNextTaskSelectAssigneeFormField = async () => {
717
+ /** 流程通过时,根据表单变量查询新的流程节点,判断下一个节点类型是否为自选审批人 */
718
+ const initNextAssigneesFormField = async () => {
726
719
// 获取修改的流程变量, 暂时只支持流程表单
727
720
const variables = getUpdatedProcessInstanceVariables ()
728
- const param = {
721
+ const data = await ProcessInstanceApi . getApprovalDetail ( {
729
722
processInstanceId: props .processInstance .id ,
730
723
processVariablesStr: JSON .stringify (variables )
731
- }
732
- const res = await ProcessInstanceApi .getApprovalDetail (param )
733
- // 当前待审批节点id
734
- const activityId = res .todoTask ?.taskDefinitionKey
735
- if (res .activityNodes && res .activityNodes .length > 0 ) {
724
+ })
725
+
726
+ const activityId = data .todoTask ?.taskDefinitionKey
727
+ if (data .activityNodes && data .activityNodes .length > 0 ) {
736
728
// 找到当前节点的索引
737
- const currentNodeIndex = res .activityNodes .findIndex ((node ) => node .id === activityId )
738
- const nextNode = res .activityNodes [currentNodeIndex + 1 ]
729
+ const currentNodeIndex = data .activityNodes .findIndex ((node : any ) => node .id === activityId )
730
+ const nextNode = data .activityNodes [currentNodeIndex + 1 ]
731
+ // 情况一:发起人选择审批人:此时一般是因为条件发生变化,需要当前审批人补充选择
739
732
if (
740
733
nextNode .candidateStrategy === CandidateStrategy .START_USER_SELECT &&
741
734
! nextNode .tasks &&
742
735
nextNode .candidateUsers ?.length === 0
743
736
) {
744
737
// 自选审批人,则弹出选择审批人弹窗
745
- activityNodes .value = [nextNode ]
746
- dialogVisibleSelectApproveUser .value = true
738
+ // TODO @小北:需要考虑下,这里的 nextNode 可能是多个节点,需要怎么处理;类似你在后端的处理哈
739
+ // TODO @小北:有点纠结,是不是写个预测下一个节点的接口,更合适?
740
+ nextAssigneesActivityNode .value = [nextNode ]
741
+ nextAssigneesVisible .value = true
747
742
}
743
+ // TODO @小北:情况二:审批人选择的情况
748
744
}
749
745
}
750
746
747
+ /** 选择下一个节点的审批人 */
748
+ const selectNextAssigneesConfirm = (id : string , userList : any []) => {
749
+ approveReasonForm .nextAssignees [id ] = userList ?.map ((item : any ) => item .id )
750
+ }
751
+
751
752
/** 处理审批通过和不通过的操作 */
752
753
const handleAudit = async (pass : boolean , formRef : FormInstance | undefined ) => {
753
754
formLoading .value = true
@@ -764,10 +765,7 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
764
765
765
766
if (pass ) {
766
767
// 如果需要自选审批人,则校验自选审批人
767
- if (
768
- dialogVisibleSelectApproveUser .value &&
769
- Object .keys (approveReasonForm .nextAssignees ).length === 0
770
- ) {
768
+ if (nextAssigneesVisible .value && Object .keys (approveReasonForm .nextAssignees ).length === 0 ) {
771
769
message .warning (' 下一个节点的审批人不能为空!' )
772
770
return
773
771
}
@@ -778,7 +776,7 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
778
776
reason: approveReasonForm .reason ,
779
777
variables , // 审批通过, 把修改的字段值赋于流程实例变量
780
778
nextAssignees: approveReasonForm .nextAssignees // 下个自选节点选择的审批人信息
781
- }
779
+ } as any
782
780
// 签名
783
781
if (runningTask .value .signEnable ) {
784
782
data .signPicUrl = approveReasonForm .signPicUrl
@@ -793,7 +791,7 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
793
791
}
794
792
await TaskApi .approveTask (data )
795
793
popOverVisible .value .approve = false
796
- dialogVisibleSelectApproveUser .value = false
794
+ nextAssigneesVisible .value = false
797
795
message .success (' 审批通过成功' )
798
796
} else {
799
797
// 审批不通过数据
0 commit comments