审核节点-优化代码-修复跳转任意节点
parent
b2ddefe4a0
commit
4b96a6458b
|
|
@ -129,14 +129,28 @@ const recursiveFindParentNode = (
|
|||
if (!findNode) {
|
||||
return
|
||||
}
|
||||
if (findNode.type === NodeType.START_USER_NODE) {
|
||||
nodeList.push(findNode)
|
||||
return
|
||||
}
|
||||
|
||||
// 检查当前节点
|
||||
if (findNode.type === nodeType) {
|
||||
nodeList.push(findNode)
|
||||
}
|
||||
|
||||
// 检查子节点
|
||||
if (findNode.childNode) {
|
||||
if (findNode.childNode.type === nodeType) {
|
||||
nodeList.push(findNode.childNode)
|
||||
}
|
||||
recursiveFindParentNode(nodeList, findNode.childNode, nodeType)
|
||||
}
|
||||
|
||||
// 检查条件分支节点
|
||||
if (findNode.type === NodeType.CONDITION_BRANCH_NODE && findNode.conditionNodes) {
|
||||
findNode.conditionNodes.forEach(conditionNode => {
|
||||
if (conditionNode.childNode) {
|
||||
recursiveFindParentNode(nodeList, conditionNode.childNode, nodeType)
|
||||
}
|
||||
})
|
||||
}
|
||||
emits('find:recursiveFindParentNode', nodeList, props.parentNode, nodeType)
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -233,6 +233,8 @@ export type TimeoutHandler = {
|
|||
timeDuration?: string
|
||||
// 执行动作是自动提醒, 最大提醒次数
|
||||
maxRemindCount?: number
|
||||
// 执行动作是自动跳转时,跳转的节点ID
|
||||
returnNodeId?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -291,6 +293,16 @@ export enum RejectHandlerType {
|
|||
*/
|
||||
RETURN_USER_TASK = 2
|
||||
}
|
||||
export enum DelaySettingType {
|
||||
/**
|
||||
* 默认开启
|
||||
*/
|
||||
FINISH_PROCESS = 1,
|
||||
/**
|
||||
* 延迟器指定节点
|
||||
*/
|
||||
RETURN_USER_TASK = 2
|
||||
}
|
||||
// 用户任务超时处理类型枚举
|
||||
export enum TimeoutHandlerType {
|
||||
/**
|
||||
|
|
@ -304,7 +316,11 @@ export enum TimeoutHandlerType {
|
|||
/**
|
||||
* 自动拒绝
|
||||
*/
|
||||
REJECT = 3
|
||||
REJECT = 3,
|
||||
/**
|
||||
* 自动跳转
|
||||
*/
|
||||
AUTO_JUMP = 4
|
||||
}
|
||||
// 用户任务的审批人为空时,处理类型枚举
|
||||
export enum AssignEmptyHandlerType {
|
||||
|
|
@ -570,7 +586,8 @@ export const TIME_UNIT_TYPES: DictDataVO[] = [
|
|||
export const TIMEOUT_HANDLER_TYPES: DictDataVO[] = [
|
||||
{ label: '自动提醒', value: 1 },
|
||||
{ label: '自动同意', value: 2 },
|
||||
{ label: '自动拒绝', value: 3 }
|
||||
{ label: '自动拒绝', value: 3 },
|
||||
{ label: '自动跳转', value: 4 }
|
||||
]
|
||||
export const REJECT_HANDLER_TYPES: DictDataVO[] = [
|
||||
{ label: '终止流程', value: RejectHandlerType.FINISH_PROCESS },
|
||||
|
|
@ -695,11 +712,11 @@ export enum ProcessVariableEnum {
|
|||
/**
|
||||
* 延迟设置
|
||||
*/
|
||||
export type DelaySetting = {
|
||||
// 延迟类型
|
||||
delayType: number
|
||||
// 延迟时间表达式
|
||||
export interface DelaySetting {
|
||||
delayType: DelayTypeEnum
|
||||
delayTime: string
|
||||
autoJumpEnable?: boolean
|
||||
returnNodeId?: string
|
||||
}
|
||||
/**
|
||||
* 延迟类型
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ export type UserTaskFormType = {
|
|||
assignStartUserHandlerType?: AssignStartUserHandlerType
|
||||
timeDuration?: number
|
||||
maxRemindCount?: number
|
||||
timeoutReturnNodeId?: string
|
||||
buttonsSetting: any[]
|
||||
taskCreateListenerEnable?: boolean
|
||||
taskCreateListenerPath?: string
|
||||
|
|
|
|||
|
|
@ -347,6 +347,25 @@
|
|||
>
|
||||
<el-input-number v-model="configForm.maxRemindCount" :min="1" :max="10" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="configForm.timeoutHandlerEnable && configForm.timeoutHandlerType === TimeoutHandlerType.AUTO_JUMP"
|
||||
label="跳转节点"
|
||||
prop="timeoutReturnNodeId"
|
||||
>
|
||||
<el-select
|
||||
filterable
|
||||
v-model="configForm.timeoutReturnNodeId"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in returnTaskList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-divider content-position="left">{{ nodeTypeName }}人为空时</el-divider>
|
||||
|
|
@ -729,7 +748,9 @@ const saveConfig = async () => {
|
|||
enable: configForm.value.timeoutHandlerEnable!,
|
||||
type: cTimeoutType.value,
|
||||
timeDuration: isoTimeDuration.value,
|
||||
maxRemindCount: cTimeoutMaxRemindCount.value
|
||||
maxRemindCount: cTimeoutMaxRemindCount.value,
|
||||
returnNodeId: configForm.value.timeoutHandlerType === TimeoutHandlerType.AUTO_JUMP ?
|
||||
configForm.value.timeoutReturnNodeId : undefined
|
||||
}
|
||||
// 设置审批人为空时
|
||||
currentNode.value.assignEmptyHandler = {
|
||||
|
|
@ -803,15 +824,24 @@ const showUserTaskNodeConfig = (node: SimpleFlowNode) => {
|
|||
returnTaskList.value = matchNodeList
|
||||
// 2.4 设置审批超时处理
|
||||
configForm.value.timeoutHandlerEnable = node.timeoutHandler?.enable
|
||||
if (node.timeoutHandler?.enable && node.timeoutHandler?.timeDuration) {
|
||||
const strTimeDuration = node.timeoutHandler.timeDuration
|
||||
let parseTime = strTimeDuration.slice(2, strTimeDuration.length - 1)
|
||||
let parseTimeUnit = strTimeDuration.slice(strTimeDuration.length - 1)
|
||||
configForm.value.timeDuration = parseInt(parseTime)
|
||||
timeUnit.value = convertTimeUnit(parseTimeUnit)
|
||||
if (node.timeoutHandler?.enable) {
|
||||
configForm.value.timeoutHandlerType = node.timeoutHandler.type
|
||||
configForm.value.timeoutReturnNodeId = node.timeoutHandler.returnNodeId
|
||||
|
||||
if (node.timeoutHandler.timeDuration) {
|
||||
const strTimeDuration = node.timeoutHandler.timeDuration
|
||||
let parseTime = strTimeDuration.slice(2, strTimeDuration.length - 1)
|
||||
let parseTimeUnit = strTimeDuration.slice(strTimeDuration.length - 1)
|
||||
configForm.value.timeDuration = parseInt(parseTime)
|
||||
timeUnit.value = convertTimeUnit(parseTimeUnit)
|
||||
}
|
||||
|
||||
if (node.timeoutHandler.type === TimeoutHandlerType.AUTO_JUMP) {
|
||||
const matchNodeList: SimpleFlowNode[] = []
|
||||
emits('find:returnTaskNodes', matchNodeList)
|
||||
returnTaskList.value = matchNodeList
|
||||
}
|
||||
}
|
||||
configForm.value.timeoutHandlerType = node.timeoutHandler?.type
|
||||
configForm.value.maxRemindCount = node.timeoutHandler?.maxRemindCount
|
||||
// 2.5 设置审批人为空时
|
||||
configForm.value.assignEmptyHandlerType = node.assignEmptyHandler?.type
|
||||
configForm.value.assignEmptyHandlerUserIds = node.assignEmptyHandler?.userIds
|
||||
|
|
@ -902,6 +932,11 @@ function useTimeoutHandler() {
|
|||
const timeoutHandlerTypeChanged = () => {
|
||||
if (configForm.value.timeoutHandlerType === TimeoutHandlerType.REMINDER) {
|
||||
configForm.value.maxRemindCount = 1 // 超时提醒次数,默认为1
|
||||
} else if (configForm.value.timeoutHandlerType === TimeoutHandlerType.AUTO_JUMP) {
|
||||
// 获取可跳转节点列表
|
||||
const matchNodeList: SimpleFlowNode[] = []
|
||||
emits('find:returnTaskNodes', matchNodeList)
|
||||
returnTaskList.value = matchNodeList
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,8 +169,50 @@ const deleteNode = () => {
|
|||
const findReturnTaskNodes = (
|
||||
matchNodeList: SimpleFlowNode[] // 匹配的节点
|
||||
) => {
|
||||
// 从父节点查找
|
||||
// 从父节点查找所有用户任务节点
|
||||
emits('find:parentNode', matchNodeList, NodeType.USER_TASK_NODE)
|
||||
|
||||
// 递归查找当前节点的子节点
|
||||
findChildUserTaskNodes(currentNode.value, matchNodeList)
|
||||
|
||||
// 过滤掉当前节点和重复节点
|
||||
const currentNodeId = currentNode.value.id
|
||||
// 使用 Map 来去重,以节点 id 为 key
|
||||
const uniqueNodes = new Map()
|
||||
matchNodeList.forEach(node => {
|
||||
if (node.id !== currentNodeId) {
|
||||
uniqueNodes.set(node.id, node)
|
||||
}
|
||||
})
|
||||
|
||||
// 清空原数组并添加去重后的节点
|
||||
matchNodeList.length = 0
|
||||
matchNodeList.push(...Array.from(uniqueNodes.values()))
|
||||
}
|
||||
|
||||
// 递归查找子节点中的用户任务节点
|
||||
const findChildUserTaskNodes = (node: SimpleFlowNode, matchNodeList: SimpleFlowNode[]) => {
|
||||
if (!node) return
|
||||
|
||||
// 检查子节点
|
||||
if (node.childNode) {
|
||||
if (node.childNode.type === NodeType.USER_TASK_NODE) {
|
||||
matchNodeList.push(node.childNode)
|
||||
}
|
||||
findChildUserTaskNodes(node.childNode, matchNodeList)
|
||||
}
|
||||
|
||||
// 检查条件分支节点
|
||||
if (node.type === NodeType.CONDITION_BRANCH_NODE && node.conditionNodes) {
|
||||
node.conditionNodes.forEach(conditionNode => {
|
||||
if (conditionNode.childNode) {
|
||||
if (conditionNode.childNode.type === NodeType.USER_TASK_NODE) {
|
||||
matchNodeList.push(conditionNode.childNode)
|
||||
}
|
||||
findChildUserTaskNodes(conditionNode.childNode, matchNodeList)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 任务的弹窗显示,用于只读模式
|
||||
|
|
|
|||
Loading…
Reference in New Issue