feat: 流程审批,预测下个节点是否需要选择审批人

This commit is contained in:
lizhixian 2025-02-25 17:01:26 +08:00
parent de35fd0a7c
commit b346545cbf
4 changed files with 85 additions and 32 deletions

View File

@ -157,25 +157,24 @@ const initProcessInfo = async (row: any, formVariables?: any) => {
} }
/** 预测流程节点会因为输入的参数值而产生新的预测结果值,所以需重新预测一次 */ /** 预测流程节点会因为输入的参数值而产生新的预测结果值,所以需重新预测一次 */
// TODO @ @lesan watch(
// watch( detailForm.value,
// detailForm.value, (newValue) => {
// (newValue) => { if (newValue && Object.keys(newValue.value).length > 0) {
// if (newValue && Object.keys(newValue.value).length > 0) { //
// // tempStartUserSelectAssignees.value = startUserSelectAssignees.value
// tempStartUserSelectAssignees.value = startUserSelectAssignees.value startUserSelectAssignees.value = {}
// startUserSelectAssignees.value = {} //
// // getApprovalDetail({
// getApprovalDetail({ id: props.selectProcessDefinition.id,
// id: props.selectProcessDefinition.id, processVariablesStr: newValue.value // GET String JSON
// processVariablesStr: JSON.stringify(newValue.value) // GET String JSON })
// }) }
// } },
// }, {
// { immediate: true
// immediate: true }
// } )
// )
/** 获取审批详情 */ /** 获取审批详情 */
const getApprovalDetail = async (row: any) => { const getApprovalDetail = async (row: any) => {

View File

@ -36,6 +36,18 @@
:rule="approveForm.rule" :rule="approveForm.rule"
/> />
</el-card> </el-card>
<el-form-item
label="选择审批人"
prop="selectApproveUser"
v-if="dialogVisibleSelectApproveUser"
>
<ProcessInstanceTimeline
ref="timelineRef"
:activity-nodes="activityNodes"
:show-status-icon="false"
@select-user-confirm="selectUserConfirm"
/>
</el-form-item>
<el-form-item :label="`${nodeTypeName}意见`" prop="reason"> <el-form-item :label="`${nodeTypeName}意见`" prop="reason">
<el-input <el-input
v-model="approveReasonForm.reason" v-model="approveReasonForm.reason"
@ -506,11 +518,13 @@ import * as UserApi from '@/api/system/user'
import { import {
NodeType, NodeType,
OPERATION_BUTTON_NAME, OPERATION_BUTTON_NAME,
OperationButtonType OperationButtonType,
CandidateStrategy
} from '@/components/SimpleProcessDesignerV2/src/consts' } from '@/components/SimpleProcessDesignerV2/src/consts'
import { BpmModelFormType, BpmProcessInstanceStatus } from '@/utils/constants' import { BpmModelFormType, BpmProcessInstanceStatus } from '@/utils/constants'
import type { FormInstance, FormRules } from 'element-plus' import type { FormInstance, FormRules } from 'element-plus'
import SignDialog from './SignDialog.vue' import SignDialog from './SignDialog.vue'
import ProcessInstanceTimeline from '../detail/ProcessInstanceTimeline.vue'
defineOptions({ name: 'ProcessInstanceBtnContainer' }) defineOptions({ name: 'ProcessInstanceBtnContainer' })
@ -548,6 +562,8 @@ const runningTask = ref<any>() // 运行中的任务
const approveForm = ref<any>({}) // const approveForm = ref<any>({}) //
const approveFormFApi = ref<any>({}) // approveForms fAPi const approveFormFApi = ref<any>({}) // approveForms fAPi
const nodeTypeName = ref('审批') // const nodeTypeName = ref('审批') //
const activityNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([]) //
const dialogVisibleSelectApproveUser = ref(false) //
// //
const reasonRequire = ref() const reasonRequire = ref()
@ -556,14 +572,16 @@ const signRef = ref()
const approveSignFormRef = ref() const approveSignFormRef = ref()
const approveReasonForm = reactive({ const approveReasonForm = reactive({
reason: '', reason: '',
signPicUrl: '' signPicUrl: '',
selectApproveUser: {}
}) })
const approveReasonRule = computed(() => { const approveReasonRule = computed(() => {
return { return {
reason: [ reason: [
{ required: reasonRequire.value, message: nodeTypeName + '意见不能为空', trigger: 'blur' } { required: reasonRequire.value, message: nodeTypeName + '意见不能为空', trigger: 'blur' }
], ],
signPicUrl: [{ required: true, message: '签名不能为空', trigger: 'change' }] signPicUrl: [{ required: true, message: '签名不能为空', trigger: 'change' }],
selectApproveUser: [{ required: true, message: '审批人不能为空', trigger: 'change' }]
} }
}) })
// //
@ -663,6 +681,11 @@ watch(
} }
) )
/** 选择发起人 */
const selectUserConfirm = (id: string, userList: any[]) => {
approveReasonForm.selectApproveUser[id] = userList?.map((item: any) => item.id)
}
/** 弹出气泡卡 */ /** 弹出气泡卡 */
const openPopover = async (type: string) => { const openPopover = async (type: string) => {
if (type === 'approve') { if (type === 'approve') {
@ -694,6 +717,7 @@ const closePropover = (type: string, formRef: FormInstance | undefined) => {
formRef.resetFields() formRef.resetFields()
} }
popOverVisible.value[type] = false popOverVisible.value[type] = false
dialogVisibleSelectApproveUser.value = false
} }
/** 处理审批通过和不通过的操作 */ /** 处理审批通过和不通过的操作 */
@ -711,13 +735,44 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
} }
if (pass) { if (pass) {
//
if (
dialogVisibleSelectApproveUser.value &&
Object.keys(approveReasonForm.selectApproveUser).length === 0
) {
message.warning('审批人不能为空!')
return
}
// , // ,
const variables = getUpdatedProcessInstanceVariables() const variables = getUpdatedProcessInstanceVariables()
const param = {
processInstanceId: props.processInstance.id,
processVariablesStr: JSON.stringify(variables)
}
//
const res = await ProcessInstanceApi.getApprovalDetail(param)
//id
const activityId = res.todoTask?.taskDefinitionKey
if (res.activityNodes && res.activityNodes.length > 0) {
//
const currentNodeIndex = res.activityNodes.findIndex((node) => node.id === activityId)
const nextNode = res.activityNodes[currentNodeIndex + 1]
if (
nextNode.candidateStrategy === CandidateStrategy.START_USER_SELECT &&
!nextNode.tasks &&
nextNode.candidateUsers?.length === 0
) {
//
activityNodes.value = [nextNode]
dialogVisibleSelectApproveUser.value = true
}
}
// //
const data = { const data = {
id: runningTask.value.id, id: runningTask.value.id,
reason: approveReasonForm.reason, reason: approveReasonForm.reason,
variables // , variables, // ,
startUserSelectAssignees: approveReasonForm.selectApproveUser //
} }
// //
if (runningTask.value.signEnable) { if (runningTask.value.signEnable) {

View File

@ -48,7 +48,7 @@ watch(
finishedActivityIds, finishedActivityIds,
finishedSequenceFlowActivityIds finishedSequenceFlowActivityIds
) )
simpleModel.value = newModelView.simpleModel simpleModel.value = newModelView.simpleModel == null ? {} : newModelView.simpleModel
} }
} }
) )

View File

@ -178,22 +178,21 @@ const writableFields: Array<string> = [] // 表单可以编辑的字段
/** 获得详情 */ /** 获得详情 */
const getDetail = () => { const getDetail = () => {
getApprovalDetail() const param = {
processInstanceId: props.id,
activityId: props.activityId,
taskId: props.taskId
}
getApprovalDetail(param)
getProcessModelView() getProcessModelView()
} }
/** 加载流程实例 */ /** 加载流程实例 */
const BusinessFormComponent = ref<any>(null) // const BusinessFormComponent = ref<any>(null) //
/** 获取审批详情 */ /** 获取审批详情 */
const getApprovalDetail = async () => { const getApprovalDetail = async (param?: any) => {
processInstanceLoading.value = true processInstanceLoading.value = true
try { try {
const param = {
processInstanceId: props.id,
activityId: props.activityId,
taskId: props.taskId
}
const data = await ProcessInstanceApi.getApprovalDetail(param) const data = await ProcessInstanceApi.getApprovalDetail(param)
if (!data) { if (!data) {
message.error('查询不到审批详情信息!') message.error('查询不到审批详情信息!')