优化节点超时节点卡顿问题

pull/710/head
Lemon 2025-02-24 17:00:05 +08:00
parent 4b96a6458b
commit da7c9e9796
1 changed files with 34 additions and 30 deletions

View File

@ -165,53 +165,57 @@ const nodeClick = () => {
const deleteNode = () => { const deleteNode = () => {
emits('update:flowNode', currentNode.value.childNode) emits('update:flowNode', currentNode.value.childNode)
} }
// //
const findReturnTaskNodes = ( const findReturnTaskNodes = (matchNodeList: SimpleFlowNode[]) => {
matchNodeList: SimpleFlowNode[] // // Set ,
) => { const uniqueNodes = new Set<SimpleFlowNode>()
// const currentNodeId = currentNode.value.id
//
emits('find:parentNode', matchNodeList, NodeType.USER_TASK_NODE) emits('find:parentNode', matchNodeList, NodeType.USER_TASK_NODE)
// // Set
findChildUserTaskNodes(currentNode.value, matchNodeList)
//
const currentNodeId = currentNode.value.id
// 使 Map , id key
const uniqueNodes = new Map()
matchNodeList.forEach(node => { matchNodeList.forEach(node => {
if (node.id !== currentNodeId) { if (node.id !== currentNodeId) {
uniqueNodes.set(node.id, node) uniqueNodes.add(node)
} }
}) })
// // Set
findChildUserTaskNodes(currentNode.value, uniqueNodes, currentNodeId)
// Set
matchNodeList.length = 0 matchNodeList.length = 0
matchNodeList.push(...Array.from(uniqueNodes.values())) matchNodeList.push(...uniqueNodes)
} }
// //
const findChildUserTaskNodes = (node: SimpleFlowNode, matchNodeList: SimpleFlowNode[]) => { const findChildUserTaskNodes = (
node: SimpleFlowNode,
uniqueNodes: Set<SimpleFlowNode>,
currentNodeId: string
) => {
if (!node) return if (!node) return
// //
if (node.childNode) { if (node.childNode) {
if (node.childNode.type === NodeType.USER_TASK_NODE) { if (node.childNode.type === NodeType.USER_TASK_NODE && node.childNode.id !== currentNodeId) {
matchNodeList.push(node.childNode) uniqueNodes.add(node.childNode)
} }
findChildUserTaskNodes(node.childNode, matchNodeList) findChildUserTaskNodes(node.childNode, uniqueNodes, currentNodeId)
} }
// //
if (node.type === NodeType.CONDITION_BRANCH_NODE && node.conditionNodes) { if (node.type === NodeType.CONDITION_BRANCH_NODE && node.conditionNodes) {
node.conditionNodes.forEach(conditionNode => { for (const conditionNode of node.conditionNodes) {
if (conditionNode.childNode) { if (conditionNode.childNode) {
if (conditionNode.childNode.type === NodeType.USER_TASK_NODE) { if (conditionNode.childNode.type === NodeType.USER_TASK_NODE &&
matchNodeList.push(conditionNode.childNode) conditionNode.childNode.id !== currentNodeId) {
uniqueNodes.add(conditionNode.childNode)
} }
findChildUserTaskNodes(conditionNode.childNode, matchNodeList) findChildUserTaskNodes(conditionNode.childNode, uniqueNodes, currentNodeId)
} }
}) }
} }
} }