gaoluyang
2026-06-24 c0cb161bb52ce0fbdce5c66ec391d107c75e2452
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<script setup lang="ts">
import type { SimpleFlowNode } from '../consts';
 
import { BpmNodeTypeEnum } from '..\..\..\..\..\packages\constants\src';
 
import { useWatchNode } from '../helpers';
import ChildProcessNode from './nodes/child-process-node.vue';
import CopyTaskNode from './nodes/copy-task-node.vue';
import DelayTimerNode from './nodes/delay-timer-node.vue';
import EndEventNode from './nodes/end-event-node.vue';
import ExclusiveNode from './nodes/exclusive-node.vue';
import InclusiveNode from './nodes/inclusive-node.vue';
import ParallelNode from './nodes/parallel-node.vue';
import RouterNode from './nodes/router-node.vue';
import StartUserNode from './nodes/start-user-node.vue';
import TriggerNode from './nodes/trigger-node.vue';
import UserTaskNode from './nodes/user-task-node.vue';
 
defineOptions({ name: 'ProcessNodeTree' });
 
const props = defineProps({
  parentNode: {
    type: Object as () => SimpleFlowNode,
    default: () => null,
  },
  flowNode: {
    type: Object as () => SimpleFlowNode,
    default: () => null,
  },
});
 
const emits = defineEmits<{
  recursiveFindParentNode: [
    nodeList: SimpleFlowNode[],
    currentNode: SimpleFlowNode,
    nodeType: number,
  ];
  'update:flowNode': [node: SimpleFlowNode | undefined];
}>();
 
const currentNode = useWatchNode(props);
 
// 用于删除节点
 
const handleModelValueUpdate = (updateValue: any) => {
  emits('update:flowNode', updateValue);
};
 
const findParentNode = (nodeList: SimpleFlowNode[], nodeType: number) => {
  emits('recursiveFindParentNode', nodeList, props.parentNode, nodeType);
};
 
// 递归从父节点中查询匹配的节点
function recursiveFindParentNode(
  nodeList: SimpleFlowNode[],
  findNode: SimpleFlowNode,
  nodeType: number,
) {
  if (!findNode) {
    return;
  }
  if (findNode.type === BpmNodeTypeEnum.START_USER_NODE) {
    nodeList.push(findNode);
    return;
  }
 
  if (findNode.type === nodeType) {
    nodeList.push(findNode);
  }
  emits('recursiveFindParentNode', nodeList, props.parentNode, nodeType);
}
</script>
<template>
  <!-- 发起人节点 -->
  <StartUserNode
    v-if="currentNode && currentNode.type === BpmNodeTypeEnum.START_USER_NODE"
    :flow-node="currentNode"
  />
  <!-- 审批节点 -->
  <UserTaskNode
    v-if="
      currentNode &&
      (currentNode.type === BpmNodeTypeEnum.USER_TASK_NODE ||
        currentNode.type === BpmNodeTypeEnum.TRANSACTOR_NODE)
    "
    :flow-node="currentNode"
    @update:flow-node="handleModelValueUpdate"
    @find-parent-node="findParentNode"
  />
  <!-- 抄送节点 -->
  <CopyTaskNode
    v-if="currentNode && currentNode.type === BpmNodeTypeEnum.COPY_TASK_NODE"
    :flow-node="currentNode"
    @update:flow-node="handleModelValueUpdate"
  />
  <!-- 条件节点 -->
  <ExclusiveNode
    v-if="
      currentNode && currentNode.type === BpmNodeTypeEnum.CONDITION_BRANCH_NODE
    "
    :flow-node="currentNode"
    @update:model-value="handleModelValueUpdate"
    @find-parent-node="findParentNode"
  />
  <!-- 并行节点 -->
  <ParallelNode
    v-if="
      currentNode && currentNode.type === BpmNodeTypeEnum.PARALLEL_BRANCH_NODE
    "
    :flow-node="currentNode"
    @update:model-value="handleModelValueUpdate"
    @find-parent-node="findParentNode"
  />
  <!-- 包容分支节点 -->
  <InclusiveNode
    v-if="
      currentNode && currentNode.type === BpmNodeTypeEnum.INCLUSIVE_BRANCH_NODE
    "
    :flow-node="currentNode"
    @update:model-value="handleModelValueUpdate"
    @find-parent-node="findParentNode"
  />
  <!-- 延迟器节点 -->
  <DelayTimerNode
    v-if="currentNode && currentNode.type === BpmNodeTypeEnum.DELAY_TIMER_NODE"
    :flow-node="currentNode"
    @update:flow-node="handleModelValueUpdate"
  />
  <!-- 路由分支节点 -->
  <RouterNode
    v-if="
      currentNode && currentNode.type === BpmNodeTypeEnum.ROUTER_BRANCH_NODE
    "
    :flow-node="currentNode"
    @update:flow-node="handleModelValueUpdate"
  />
  <!-- 触发器节点 -->
  <TriggerNode
    v-if="currentNode && currentNode.type === BpmNodeTypeEnum.TRIGGER_NODE"
    :flow-node="currentNode"
    @update:flow-node="handleModelValueUpdate"
  />
  <!-- 子流程节点 -->
  <ChildProcessNode
    v-if="
      currentNode && currentNode.type === BpmNodeTypeEnum.CHILD_PROCESS_NODE
    "
    :flow-node="currentNode"
    @update:flow-node="handleModelValueUpdate"
  />
  <!-- 递归显示孩子节点  -->
  <ProcessNodeTree
    v-if="currentNode && currentNode.childNode"
    v-model:flow-node="currentNode.childNode"
    :parent-node="currentNode"
    @recursive-find-parent-node="recursiveFindParentNode"
  />
 
  <!-- 结束节点 -->
  <EndEventNode
    v-if="currentNode && currentNode.type === BpmNodeTypeEnum.END_EVENT_NODE"
    :flow-node="currentNode"
  />
</template>