Pre Merge pull request !710 from Lemon/feature/bpm-审核超时跳转任意节点

pull/710/MERGE
Lemon 2025-03-25 04:58:00 +00:00 committed by Gitee
commit f6277ae4a0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 194 additions and 38 deletions

View File

@ -81,6 +81,7 @@
/>
</template>
<script setup lang="ts">
//
import StartUserNode from './nodes/StartUserNode.vue'
import EndEventNode from './nodes/EndEventNode.vue'
import UserTaskNode from './nodes/UserTaskNode.vue'
@ -94,57 +95,98 @@ import TriggerNode from './nodes/TriggerNode.vue'
import ChildProcessNode from './nodes/ChildProcessNode.vue'
import { SimpleFlowNode, NodeType } from './consts'
import { useWatchNode } from './node'
//
defineOptions({
name: 'ProcessNodeTree'
})
// props
const props = defineProps({
//
parentNode: {
type: Object as () => SimpleFlowNode,
default: () => null
},
//
flowNode: {
type: Object as () => SimpleFlowNode,
default: () => null
}
})
//
const emits = defineEmits<{
//
'update:flowNode': [node: SimpleFlowNode | undefined]
//
'find:recursiveFindParentNode': [
nodeList: SimpleFlowNode[],
curentNode: SimpleFlowNode,
nodeType: number
nodeList: SimpleFlowNode[], //
curentNode: SimpleFlowNode, //
nodeType: number //
]
}>()
// 使 useWatchNode hook
const currentNode = useWatchNode(props)
//
//
const handleModelValueUpdate = (updateValue) => {
emits('update:flowNode', updateValue)
}
//
const findFromParentNode = (nodeList: SimpleFlowNode[], nodeType: number) => {
emits('find:recursiveFindParentNode', nodeList, props.parentNode, nodeType)
}
//
//
const nodeCache = new Map<string, SimpleFlowNode[]>()
const recursiveFindParentNode = (
nodeList: SimpleFlowNode[],
findNode: SimpleFlowNode,
nodeType: number
nodeList: SimpleFlowNode[],
findNode: SimpleFlowNode,
nodeType: number
) => {
if (!findNode) {
return
}
if (findNode.type === NodeType.START_USER_NODE) {
nodeList.push(findNode)
return
if (!findNode) return
// Create a Set to track visited nodes and prevent cycles
const visitedNodes = new Set<string>()
const findNodesRecursive = (node: SimpleFlowNode) => {
if (!node || visitedNodes.has(node.id)) return
visitedNodes.add(node.id)
// Check current node
if (node.type === nodeType) {
if (!nodeList.some(n => n.id === node.id)) {
nodeList.push(node)
}
}
// Check child node
if (node.childNode) {
findNodesRecursive(node.childNode)
}
// Check condition nodes if present
if (node.type === NodeType.CONDITION_BRANCH_NODE && node.conditionNodes) {
node.conditionNodes.forEach(conditionNode => {
if (conditionNode.childNode) {
findNodesRecursive(conditionNode.childNode)
}
})
}
}
if (findNode.type === nodeType) {
nodeList.push(findNode)
// Start recursive search
findNodesRecursive(findNode)
// Continue search in parent node
if (props.parentNode) {
emits('find:recursiveFindParentNode', nodeList, props.parentNode, nodeType)
}
emits('find:recursiveFindParentNode', nodeList, props.parentNode, nodeType)
}
</script>
<style lang="scss" scoped></style>

View File

@ -244,6 +244,8 @@ export type TimeoutHandler = {
timeDuration?: string
// 执行动作是自动提醒, 最大提醒次数
maxRemindCount?: number
// 执行动作是自动跳转时跳转的节点ID
returnNodeId?: string
}
/**
@ -302,6 +304,16 @@ export enum RejectHandlerType {
*/
RETURN_USER_TASK = 2
}
export enum DelaySettingType {
/**
*
*/
FINISH_PROCESS = 1,
/**
*
*/
RETURN_USER_TASK = 2
}
// 用户任务超时处理类型枚举
export enum TimeoutHandlerType {
/**
@ -315,7 +327,11 @@ export enum TimeoutHandlerType {
/**
*
*/
REJECT = 3
REJECT = 3,
/**
*
*/
AUTO_JUMP = 4
}
// 用户任务的审批人为空时,处理类型枚举
export enum AssignEmptyHandlerType {
@ -583,7 +599,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 },
@ -708,11 +725,11 @@ export enum ProcessVariableEnum {
/**
*
*/
export type DelaySetting = {
// 延迟类型
delayType: number
// 延迟时间表达式
export interface DelaySetting {
delayType: DelayTypeEnum
delayTime: string
autoJumpEnable?: boolean
returnNodeId?: string
}
/**
*

View File

@ -156,6 +156,7 @@ export type UserTaskFormType = {
assignStartUserHandlerType?: AssignStartUserHandlerType
timeDuration?: number
maxRemindCount?: number
timeoutReturnNodeId?: string
buttonsSetting: any[]
taskCreateListenerEnable?: boolean
taskCreateListenerPath?: string

View File

@ -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
}
}

View File

@ -41,7 +41,7 @@
</div>
<div v-if="!readonly" class="node-toolbar">
<div class="toolbar-icon"
><Icon color="#0089ff" icon="ep:circle-close-filled" :size="18" @click="deleteNode"
><Icon color="#0089ff" icon="ep:circle-close-filled" :size="18" @click="deleteNode"
/></div>
</div>
</div>
@ -147,12 +147,16 @@ const nodeSetting = ref()
const nodeClick = () => {
if (readonly) {
console.log('[UserTaskNode] 开始处理只读模式点击, tasks长度:', tasks.value?.length)
if (tasks && tasks.value) {
dialogTitle.value = currentNode.value.name
console.time('过滤任务耗时')
//
selectTasks.value = tasks.value.filter(
(item: any) => item?.taskDefinitionKey === currentNode.value.id
)
console.timeEnd('过滤任务耗时')
console.log('[UserTaskNode] 过滤后的任务数:', selectTasks.value.length)
dialogVisible.value = true
}
} else {
@ -165,12 +169,69 @@ const nodeClick = () => {
const deleteNode = () => {
emits('update:flowNode', currentNode.value.childNode)
}
//
const findReturnTaskNodes = (
matchNodeList: SimpleFlowNode[] //
) => {
//
//
const findReturnTaskNodes = (matchNodeList: SimpleFlowNode[]) => {
console.time('findReturnTaskNodes总耗时')
// 使Set
const uniqueNodes = new Set<SimpleFlowNode>()
const currentNodeId = currentNode.value.id
const processedNodes = new Set<string>() //
//
console.time('父节点查找耗时')
emits('find:parentNode', matchNodeList, NodeType.USER_TASK_NODE)
console.timeEnd('父节点查找耗时')
//
matchNodeList.forEach(node => {
if (!processedNodes.has(node.id) && node.id !== currentNodeId) {
uniqueNodes.add(node)
processedNodes.add(node.id)
}
})
//
findChildUserTaskNodes(currentNode.value, uniqueNodes, currentNodeId, processedNodes)
//
matchNodeList.length = 0
matchNodeList.push(...Array.from(uniqueNodes))
console.log('[findReturnTaskNodes] 最终找到的节点数:', matchNodeList.length)
console.timeEnd('findReturnTaskNodes总耗时')
}
//
const findChildUserTaskNodes = (
node: SimpleFlowNode,
uniqueNodes: Set<SimpleFlowNode>,
currentNodeId: string,
processedNodes: Set<string>
) => {
if (!node || processedNodes.has(node.id)) return
processedNodes.add(node.id)
//
if (node.childNode) {
if (node.childNode.type === NodeType.USER_TASK_NODE &&
node.childNode.id !== currentNodeId &&
!processedNodes.has(node.childNode.id)) {
uniqueNodes.add(node.childNode)
processedNodes.add(node.childNode.id)
}
findChildUserTaskNodes(node.childNode, uniqueNodes, currentNodeId, processedNodes)
}
//
if (node.type === NodeType.CONDITION_BRANCH_NODE && node.conditionNodes) {
for (const conditionNode of node.conditionNodes) {
if (conditionNode.childNode) {
findChildUserTaskNodes(conditionNode.childNode, uniqueNodes, currentNodeId, processedNodes)
}
}
}
}
//