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
+ />
58
+ </el-form-item >
47
59
<el-form-item
48
60
v-if =" runningTask.signEnable"
49
61
label =" 签名"
@@ -506,11 +518,13 @@ import * as UserApi from '@/api/system/user'
506
518
import {
507
519
NodeType ,
508
520
OPERATION_BUTTON_NAME ,
509
- OperationButtonType
521
+ OperationButtonType ,
522
+ CandidateStrategy
510
523
} from ' @/components/SimpleProcessDesignerV2/src/consts'
511
524
import { BpmModelFormType , BpmProcessInstanceStatus } from ' @/utils/constants'
512
525
import type { FormInstance , FormRules } from ' element-plus'
513
526
import SignDialog from ' ./SignDialog.vue'
527
+ import ProcessInstanceTimeline from ' ../detail/ProcessInstanceTimeline.vue'
514
528
515
529
defineOptions ({ name: ' ProcessInstanceBtnContainer' })
516
530
@@ -548,6 +562,8 @@ const runningTask = ref<any>() // 运行中的任务
548
562
const approveForm = ref <any >({}) // 审批通过时,额外的补充信息
549
563
const approveFormFApi = ref <any >({}) // approveForms 的 fAPi
550
564
const nodeTypeName = ref (' 审批' ) // 节点类型名称
565
+ const activityNodes = ref <ProcessInstanceApi .ApprovalNodeInfo []>([]) // 审批节点信息
566
+ const dialogVisibleSelectApproveUser = ref (false ) // 是否显示节点审批人选择框
551
567
552
568
// 审批通过意见表单
553
569
const reasonRequire = ref ()
@@ -556,14 +572,16 @@ const signRef = ref()
556
572
const approveSignFormRef = ref ()
557
573
const approveReasonForm = reactive ({
558
574
reason: ' ' ,
559
- signPicUrl: ' '
575
+ signPicUrl: ' ' ,
576
+ nextAssignees: {}
560
577
})
561
578
const approveReasonRule = computed (() => {
562
579
return {
563
580
reason: [
564
581
{ required: reasonRequire .value , message: nodeTypeName + ' 意见不能为空' , trigger: ' blur' }
565
582
],
566
- signPicUrl: [{ required: true , message: ' 签名不能为空' , trigger: ' change' }]
583
+ signPicUrl: [{ required: true , message: ' 签名不能为空' , trigger: ' change' }],
584
+ nextAssignees: [{ required: true , message: ' 审批人不能为空' , trigger: ' blur' }]
567
585
}
568
586
})
569
587
// 拒绝表单
@@ -663,6 +681,11 @@ watch(
663
681
}
664
682
)
665
683
684
+ /** 选择下一个节点的审批人 */
685
+ const selectUserConfirm = (id : string , userList : any []) => {
686
+ approveReasonForm .nextAssignees [id ] = userList ?.map ((item : any ) => item .id )
687
+ }
688
+
666
689
/** 弹出气泡卡 */
667
690
const openPopover = async (type : string ) => {
668
691
if (type === ' approve' ) {
@@ -672,6 +695,7 @@ const openPopover = async (type: string) => {
672
695
message .warning (' 表单校验不通过,请先完善表单!!' )
673
696
return
674
697
}
698
+ initNextTaskSelectAssigneeFormField ()
675
699
}
676
700
if (type === ' return' ) {
677
701
// 获取退回节点
@@ -694,6 +718,34 @@ const closePropover = (type: string, formRef: FormInstance | undefined) => {
694
718
formRef .resetFields ()
695
719
}
696
720
popOverVisible .value [type ] = false
721
+ dialogVisibleSelectApproveUser .value = false
722
+ }
723
+
724
+ /** // 流程通过时,根据表单变量查询新的流程节点,判断下一个节点类型是否为自选审批人 */
725
+ const initNextTaskSelectAssigneeFormField = async () => {
726
+ // 获取修改的流程变量, 暂时只支持流程表单
727
+ const variables = getUpdatedProcessInstanceVariables ()
728
+ const param = {
729
+ processInstanceId: props .processInstance .id ,
730
+ 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 ) {
736
+ // 找到当前节点的索引
737
+ const currentNodeIndex = res .activityNodes .findIndex ((node ) => node .id === activityId )
738
+ const nextNode = res .activityNodes [currentNodeIndex + 1 ]
739
+ if (
740
+ nextNode .candidateStrategy === CandidateStrategy .START_USER_SELECT &&
741
+ ! nextNode .tasks &&
742
+ nextNode .candidateUsers ?.length === 0
743
+ ) {
744
+ // 自选审批人,则弹出选择审批人弹窗
745
+ activityNodes .value = [nextNode ]
746
+ dialogVisibleSelectApproveUser .value = true
747
+ }
748
+ }
697
749
}
698
750
699
751
/** 处理审批通过和不通过的操作 */
@@ -711,13 +763,21 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
711
763
}
712
764
713
765
if (pass ) {
714
- // 获取修改的流程变量, 暂时只支持流程表单
766
+ // 如果需要自选审批人,则校验自选审批人
767
+ if (
768
+ dialogVisibleSelectApproveUser .value &&
769
+ Object .keys (approveReasonForm .nextAssignees ).length === 0
770
+ ) {
771
+ message .warning (' 下一个节点的审批人不能为空!' )
772
+ return
773
+ }
715
774
const variables = getUpdatedProcessInstanceVariables ()
716
775
// 审批通过数据
717
776
const data = {
718
777
id: runningTask .value .id ,
719
778
reason: approveReasonForm .reason ,
720
- variables // 审批通过, 把修改的字段值赋于流程实例变量
779
+ variables , // 审批通过, 把修改的字段值赋于流程实例变量
780
+ nextAssignees: approveReasonForm .nextAssignees // 下个自选节点选择的审批人信息
721
781
}
722
782
// 签名
723
783
if (runningTask .value .signEnable ) {
@@ -733,6 +793,7 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
733
793
}
734
794
await TaskApi .approveTask (data )
735
795
popOverVisible .value .approve = false
796
+ dialogVisibleSelectApproveUser .value = false
736
797
message .success (' 审批通过成功' )
737
798
} else {
738
799
// 审批不通过数据
@@ -1009,6 +1070,11 @@ const validateNormalForm = async () => {
1009
1070
}
1010
1071
}
1011
1072
1073
+ /**
1074
+ * TODO @小北 TO @芋道
1075
+ * 问题:这里存在一种场景会出现问题,流程发起后,A节点审批完成,B节点没有可编辑的流程字段且B节点为自选审批人节点,会导致流程审批人为空,
1076
+ * 原因:因为没有可编辑的流程字段时props.writableFields为空,参数variables传递时也为空
1077
+ */
1012
1078
/** 从可以编辑的流程表单字段,获取需要修改的流程实例的变量 */
1013
1079
const getUpdatedProcessInstanceVariables = () => {
1014
1080
const variables = {}
0 commit comments