36
36
:rule =" approveForm.rule"
37
37
/>
38
38
</el-card >
39
+ <el-form-item
40
+ label =" 选择审批人"
41
+ prop =" selectApproveUser"
42
+ v-if =" dialogVisibleSelectApproveUser"
43
+ >
44
+ <ProcessInstanceTimeline
45
+ ref =" timelineRef"
46
+ :activity-nodes =" activityNodes"
47
+ :show-status-icon =" false"
48
+ @select-user-confirm =" selectUserConfirm"
49
+ />
50
+ </el-form-item >
39
51
<el-form-item :label =" `${nodeTypeName}意见`" prop =" reason" >
40
52
<el-input
41
53
v-model =" approveReasonForm.reason"
@@ -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
+ selectApproveUser: {}
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
+ selectApproveUser: [{ required: true , message: ' 审批人不能为空' , trigger: ' change' }]
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 .selectApproveUser [id ] = userList ?.map ((item : any ) => item .id )
687
+ }
688
+
666
689
/** 弹出气泡卡 */
667
690
const openPopover = async (type : string ) => {
668
691
if (type === ' approve' ) {
@@ -694,6 +717,7 @@ const closePropover = (type: string, formRef: FormInstance | undefined) => {
694
717
formRef .resetFields ()
695
718
}
696
719
popOverVisible .value [type ] = false
720
+ dialogVisibleSelectApproveUser .value = false
697
721
}
698
722
699
723
/** 处理审批通过和不通过的操作 */
@@ -711,13 +735,44 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
711
735
}
712
736
713
737
if (pass ) {
738
+ // 如果需要自选审批人,则校验自选审批人
739
+ if (
740
+ dialogVisibleSelectApproveUser .value &&
741
+ Object .keys (approveReasonForm .selectApproveUser ).length === 0
742
+ ) {
743
+ message .warning (' 审批人不能为空!' )
744
+ return
745
+ }
714
746
// 获取修改的流程变量, 暂时只支持流程表单
715
747
const variables = getUpdatedProcessInstanceVariables ()
748
+ const param = {
749
+ processInstanceId: props .processInstance .id ,
750
+ processVariablesStr: JSON .stringify (variables )
751
+ }
752
+ // 流程通过时,根据表单变量查询新的流程节点,判断下一个节点类型是否为自选审批人
753
+ const res = await ProcessInstanceApi .getApprovalDetail (param )
754
+ // 当前待审批节点id
755
+ const activityId = res .todoTask ?.taskDefinitionKey
756
+ if (res .activityNodes && res .activityNodes .length > 0 ) {
757
+ // 找到当前节点的索引
758
+ const currentNodeIndex = res .activityNodes .findIndex ((node ) => node .id === activityId )
759
+ const nextNode = res .activityNodes [currentNodeIndex + 1 ]
760
+ if (
761
+ nextNode .candidateStrategy === CandidateStrategy .START_USER_SELECT &&
762
+ ! nextNode .tasks &&
763
+ nextNode .candidateUsers ?.length === 0
764
+ ) {
765
+ // 自选审批人,则弹出选择审批人弹窗
766
+ activityNodes .value = [nextNode ]
767
+ dialogVisibleSelectApproveUser .value = true
768
+ }
769
+ }
716
770
// 审批通过数据
717
771
const data = {
718
772
id: runningTask .value .id ,
719
773
reason: approveReasonForm .reason ,
720
- variables // 审批通过, 把修改的字段值赋于流程实例变量
774
+ variables , // 审批通过, 把修改的字段值赋于流程实例变量
775
+ startUserSelectAssignees: approveReasonForm .selectApproveUser // 下个自选节点选择的审批人信息
721
776
}
722
777
// 签名
723
778
if (runningTask .value .signEnable ) {
0 commit comments