【功能新增】工作流:支持审批人为空时,根据配置进行自动通过、自动拒绝、指定人审批的配置

pull/452/head
YunaiV 2024-08-17 17:03:58 +08:00
parent 6b31a32a2d
commit 8b3c294e5c
4 changed files with 108 additions and 13 deletions

View File

@ -43,13 +43,16 @@
<script setup lang="ts">
import {
SimpleFlowNode,
NodeType,
NODE_DEFAULT_NAME,
ApproveMethodType,
RejectHandlerType
AssignEmptyHandlerType,
AssignStartUserHandlerType,
NODE_DEFAULT_NAME,
NodeType,
RejectHandlerType,
SimpleFlowNode
} from './consts'
import { generateUUID } from '@/utils'
defineOptions({
name: 'NodeHandler'
})
@ -86,6 +89,10 @@ const addNode = (type: number) => {
timeoutHandler: {
enable: false
},
assignEmptyHandler: {
type: AssignEmptyHandlerType.APPROVE
},
assignStartUserHandlerType: AssignStartUserHandlerType.START_USER_AUDIT,
childNode: props.childNode
}
emits('update:childNode', data)

View File

@ -78,6 +78,8 @@ export interface SimpleFlowNode {
timeoutHandler?: TimeoutHandler
// 审批任务拒绝处理
rejectHandler?: RejectHandler
// 审批人为空的处理
assignEmptyHandler?: AssignEmptyHandler
// 审批节点的审批人与发起人相同时,对应的处理类型
assignStartUserHandlerType?: number
}
@ -169,7 +171,7 @@ export type RejectHandler = {
*
*/
export type TimeoutHandler = {
//是否开启超时处理
// 是否开启超时处理
enable: boolean
// 超时执行的动作
type?: number
@ -178,6 +180,17 @@ export type TimeoutHandler = {
// 执行动作是自动提醒, 最大提醒次数
maxRemindCount?: number
}
/**
*
*/
export type AssignEmptyHandler = {
// 审批人为空的处理类型
type: AssignEmptyHandlerType
// 指定用户的编号数组
userIds?: number[]
}
// 审批拒绝类型枚举
export enum RejectHandlerType {
/**
@ -204,6 +217,25 @@ export enum TimeoutHandlerType {
*/
REJECT = 3
}
// 用户任务的审批人为空时,处理类型枚举
export enum AssignEmptyHandlerType {
/**
*
*/
APPROVE = 1,
/**
*
*/
REJECT = 2,
/**
*
*/
ASSIGN_USER,
/**
*
*/
ASSIGN_ADMIN = 4
}
// 用户任务的审批人与发起人相同时,处理类型枚举
export enum AssignStartUserHandlerType {
/**
@ -369,6 +401,12 @@ export const REJECT_HANDLER_TYPES: DictDataVO[] = [
{ label: '驳回到指定节点', value: RejectHandlerType.RETURN_USER_TASK }
// { label: '结束任务', value: RejectHandlerType.FINISH_TASK }
]
export const ASSIGN_EMPTY_HANDLER_TYPES: DictDataVO[] = [
{ label: '自动通过', value: 1 },
{ label: '自动拒绝', value: 2 },
{ label: '指定成员审批', value: 3 },
{ label: '转交给流程管理员', value: 4 }
]
export const ASSIGN_START_USER_HANDLER_TYPES: DictDataVO[] = [
{ label: '由发起人对自己审批', value: 1 },
{ label: '自动跳过', value: 2 },

View File

@ -12,7 +12,7 @@ import {
RejectHandlerType,
NODE_DEFAULT_NAME,
AssignStartUserHandlerType,
ASSIGN_START_USER_HANDLER_TYPES
AssignEmptyHandlerType
} from './consts'
export function useWatchNode(props: { flowNode: SimpleFlowNode }): Ref<SimpleFlowNode> {
const node = ref<SimpleFlowNode>(props.flowNode)
@ -57,7 +57,7 @@ export function useFormFieldsPermission() {
fieldsPermission: Array<Record<string, string>>,
parentTitle: string = ''
) => {
const { type, field, title: tempTitle, children } = rule
const { /**type,*/ field, title: tempTitle, children } = rule
if (field && tempTitle) {
let title = tempTitle
if (parentTitle) {
@ -106,6 +106,8 @@ export type UserTaskFormType = {
returnNodeId?: string
timeoutHandlerEnable?: boolean
timeoutHandlerType?: number
assignEmptyHandlerType?: AssignEmptyHandlerType
assignEmptyHandlerUserIds?: number[]
assignStartUserHandlerType?: AssignStartUserHandlerType
timeDuration?: number
maxRemindCount?: number

View File

@ -196,6 +196,7 @@
</div>
</el-radio-group>
</el-form-item>
<el-divider content-position="left">审批人拒绝时</el-divider>
<el-form-item prop="rejectHandlerType">
<el-radio-group v-model="configForm.rejectHandlerType">
@ -206,7 +207,6 @@
</div>
</el-radio-group>
</el-form-item>
<el-form-item
v-if="configForm.rejectHandlerType == RejectHandlerType.RETURN_USER_TASK"
label="驳回节点"
@ -221,6 +221,7 @@
/>
</el-select>
</el-form-item>
<el-divider content-position="left">审批人超时未处理时</el-divider>
<el-form-item label="启用开关" prop="timeoutHandlerEnable">
<el-switch
@ -281,6 +282,37 @@
<el-input-number v-model="configForm.maxRemindCount" :min="1" :max="10" />
</el-form-item>
<el-divider content-position="left">审批人为空时</el-divider>
<el-form-item prop="assignEmptyHandlerType">
<el-radio-group v-model="configForm.assignEmptyHandlerType">
<div class="flex-col">
<div v-for="(item, index) in ASSIGN_EMPTY_HANDLER_TYPES" :key="index">
<el-radio :key="item.value" :value="item.value" :label="item.label" />
</div>
</div>
</el-radio-group>
</el-form-item>
<el-form-item
v-if="configForm.assignEmptyHandlerType == AssignEmptyHandlerType.ASSIGN_USER"
label="指定用户"
prop="assignEmptyHandlerUserIds"
span="24"
>
<el-select
v-model="configForm.assignEmptyHandlerUserIds"
clearable
multiple
style="width: 100%"
>
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-divider content-position="left">审批人与提交人为同一人时</el-divider>
<el-form-item prop="assignStartUserHandlerType">
<el-radio-group v-model="configForm.assignStartUserHandlerType">
@ -384,7 +416,9 @@ import {
MULTI_LEVEL_DEPT,
CANDIDATE_STRATEGY,
ASSIGN_START_USER_HANDLER_TYPES,
TimeoutHandlerType
TimeoutHandlerType,
ASSIGN_EMPTY_HANDLER_TYPES,
AssignEmptyHandlerType
} from '../consts'
import {
@ -450,7 +484,10 @@ const formRules = reactive({
timeoutHandlerEnable: [{ required: true }],
timeoutHandlerType: [{ required: true }],
timeDuration: [{ required: true, message: '超时时间不能为空', trigger: 'blur' }],
maxRemindCount: [{ required: true, message: '提醒次数不能为空', trigger: 'blur' }]
maxRemindCount: [{ required: true, message: '提醒次数不能为空', trigger: 'blur' }],
assignEmptyHandlerType: [{ required: true }],
assignEmptyHandlerUserIds: [{ required: true, message: '用户不能为空', trigger: 'change' }],
assignStartUserHandlerType: [{ required: true }]
})
const {
@ -549,7 +586,15 @@ const saveConfig = async () => {
timeDuration: isoTimeDuration.value,
maxRemindCount: cTimeoutMaxRemindCount.value
}
//
//
currentNode.value.assignEmptyHandler = {
type: configForm.value.assignEmptyHandlerType!,
userIds:
configForm.value.assignEmptyHandlerType === AssignEmptyHandlerType.ASSIGN_USER
? configForm.value.assignEmptyHandlerUserIds
: undefined
}
//
currentNode.value.assignStartUserHandlerType = configForm.value.assignStartUserHandlerType
//
currentNode.value.fieldsPermission = fieldsPermissionConfig.value
@ -573,7 +618,7 @@ const showUserTaskNodeConfig = (node: SimpleFlowNode) => {
} else {
notAllowedMultiApprovers.value = false
}
//1.2
// 1.2
configForm.value.approveMethod = node.approveMethod!
if (node.approveMethod == ApproveMethodType.APPROVE_BY_RATIO) {
configForm.value.approveRatio = node.approveRatio!
@ -595,7 +640,10 @@ const showUserTaskNodeConfig = (node: SimpleFlowNode) => {
}
configForm.value.timeoutHandlerType = node.timeoutHandler?.type
configForm.value.maxRemindCount = node.timeoutHandler?.maxRemindCount
// 1.5
// 1.5
configForm.value.assignEmptyHandlerType = node.assignEmptyHandler?.type
configForm.value.assignEmptyHandlerUserIds = node.assignEmptyHandler?.userIds
// 1.6
configForm.value.assignStartUserHandlerType = node.assignStartUserHandlerType
// 2.
buttonsSetting.value = cloneDeep(node.buttonsSetting) || DEFAULT_BUTTON_SETTING