adtec-core-package 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.en.md +36 -36
  2. package/eslint.config.js +11 -21
  3. package/package.json +71 -71
  4. package/src/api/BasicApi.ts +26 -26
  5. package/src/api/DeptInfoApi.ts +19 -19
  6. package/src/api/DocumentApi.ts +27 -27
  7. package/src/api/EmployeeInfoApi.ts +17 -17
  8. package/src/api/SysDictCacheApi.ts +29 -29
  9. package/src/api/SysUserApi.ts +35 -35
  10. package/src/api/framework.ts +12 -12
  11. package/src/api/workflow/workflow.ts +31 -31
  12. package/src/api/workflow/workflowInstApi.ts +72 -72
  13. package/src/assets/style/ant.scss +19 -19
  14. package/src/assets/style/index.less +180 -180
  15. package/src/components/ElCardList.vue +64 -64
  16. package/src/components/ElFlex/ElFlex.vue +297 -297
  17. package/src/components/ElTotalTools.vue +70 -70
  18. package/src/components/OperationAuth/operationAuth.vue +32 -32
  19. package/src/components/RichTextEditor/RichTextEditor.vue +414 -414
  20. package/src/components/Scrollbars/ElScrollbars.vue +21 -21
  21. package/src/components/Search/ElIconSearch.vue +267 -267
  22. package/src/components/Search/ElSearch.vue +154 -154
  23. package/src/components/SelectInDicators/SelectInDicators.vue +225 -225
  24. package/src/components/SelectInDicators/api/DataIndicatorsApi.ts +28 -28
  25. package/src/components/SelectInDicators/interface/IComIndex.ts +26 -26
  26. package/src/components/SelectInDicators/interface/IComIndexAttri.ts +18 -18
  27. package/src/components/Table/ElTableColumnDynamic.vue +25 -25
  28. package/src/components/Table/ElTableColumnEdit.vue +265 -265
  29. package/src/components/Table/ElTableTool.ts +37 -37
  30. package/src/components/Title/ElTitle.vue +53 -53
  31. package/src/components/autoToolTip/ElAutoToolTip.vue +62 -62
  32. package/src/components/baseEcharts/index.vue +48 -48
  33. package/src/components/bpmntree/api/modules/role.ts +31 -31
  34. package/src/components/bpmntree/api/modules/user.ts +17 -17
  35. package/src/components/bpmntree/components/AdvancedFilter/Operator.vue +112 -112
  36. package/src/components/bpmntree/components/AdvancedFilter/Trigger.vue +23 -23
  37. package/src/components/bpmntree/components/AdvancedFilter/index.vue +230 -230
  38. package/src/components/bpmntree/components/AdvancedFilter/type.ts +20 -20
  39. package/src/components/bpmntree/components/FlowIcon/index.scss +7 -7
  40. package/src/components/bpmntree/components/FlowIcon/index.tsx +68 -68
  41. package/src/components/bpmntree/components/Render/render.vue +90 -90
  42. package/src/components/bpmntree/components/Render/type.ts +12 -12
  43. package/src/components/bpmntree/components/RoleSelector/RolePicker.vue +264 -264
  44. package/src/components/bpmntree/components/RoleSelector/RoleTag.vue +48 -48
  45. package/src/components/bpmntree/components/RoleSelector/index.vue +113 -113
  46. package/src/components/bpmntree/components/UserSelector/UserTag.vue +73 -73
  47. package/src/components/bpmntree/components/UserSelector/index.vue +140 -140
  48. package/src/components/bpmntree/hooks/useDraggableScroll.ts +44 -44
  49. package/src/components/bpmntree/typings/index.d.ts +1 -1
  50. package/src/components/bpmntree/views/flowDesign/index.vue +653 -653
  51. package/src/components/bpmntree/views/flowDesign/nodes/Add.vue +184 -184
  52. package/src/components/bpmntree/views/flowDesign/nodes/ApprovalNode.vue +127 -127
  53. package/src/components/bpmntree/views/flowDesign/nodes/CcNode.vue +93 -93
  54. package/src/components/bpmntree/views/flowDesign/nodes/ConcurrentNode.vue +61 -61
  55. package/src/components/bpmntree/views/flowDesign/nodes/ConditionNode.vue +60 -60
  56. package/src/components/bpmntree/views/flowDesign/nodes/EndNode.vue +80 -80
  57. package/src/components/bpmntree/views/flowDesign/nodes/ExclusiveNode.vue +20 -20
  58. package/src/components/bpmntree/views/flowDesign/nodes/GatewayNode.vue +173 -173
  59. package/src/components/bpmntree/views/flowDesign/nodes/InclusiveNode.vue +20 -20
  60. package/src/components/bpmntree/views/flowDesign/nodes/JumpNode.vue +49 -49
  61. package/src/components/bpmntree/views/flowDesign/nodes/Node.vue +346 -346
  62. package/src/components/bpmntree/views/flowDesign/nodes/NotifyNode.vue +115 -115
  63. package/src/components/bpmntree/views/flowDesign/nodes/ParallelNode.vue +20 -20
  64. package/src/components/bpmntree/views/flowDesign/nodes/PopoverView.vue +78 -78
  65. package/src/components/bpmntree/views/flowDesign/nodes/StartNode.vue +84 -84
  66. package/src/components/bpmntree/views/flowDesign/nodes/TimerNode.vue +50 -50
  67. package/src/components/bpmntree/views/flowDesign/nodes/TreeNode.vue +45 -45
  68. package/src/components/bpmntree/views/flowDesign/nodes/type.ts +196 -196
  69. package/src/components/bpmntree/views/flowDesign/panels/ApprovalPanel.vue +553 -553
  70. package/src/components/bpmntree/views/flowDesign/panels/AssigneePanel.vue +120 -120
  71. package/src/components/bpmntree/views/flowDesign/panels/CcPanel.vue +99 -99
  72. package/src/components/bpmntree/views/flowDesign/panels/ConditionPanel.vue +41 -41
  73. package/src/components/bpmntree/views/flowDesign/panels/EndPanel.vue +18 -18
  74. package/src/components/bpmntree/views/flowDesign/panels/ExecutionListeners.vue +110 -110
  75. package/src/components/bpmntree/views/flowDesign/panels/JumpPanel.vue +32 -32
  76. package/src/components/bpmntree/views/flowDesign/panels/NotifyPanel.vue +101 -101
  77. package/src/components/bpmntree/views/flowDesign/panels/ParaPanel.vue +248 -248
  78. package/src/components/bpmntree/views/flowDesign/panels/StartPanel.vue +160 -160
  79. package/src/components/bpmntree/views/flowDesign/panels/TaskListeners.vue +110 -110
  80. package/src/components/bpmntree/views/flowDesign/panels/TimerPanel.vue +51 -51
  81. package/src/components/bpmntree/views/flowDesign/panels/index.vue +85 -85
  82. package/src/components/bpmntree/views/view.index.vue +291 -291
  83. package/src/components/business/comp.selectUser.vue +60 -60
  84. package/src/components/business/comp.userForm.vue +312 -311
  85. package/src/components/business/userSelect.vue +413 -413
  86. package/src/components/icon/ElIconBtn.vue +243 -243
  87. package/src/components/kFrame/IframeOptions.ts +116 -116
  88. package/src/components/kFrame/KFrame.vue +161 -161
  89. package/src/components/upload/ElUploads.vue +364 -331
  90. package/src/components/upload/FileView.vue +214 -214
  91. package/src/components/upload/FileViewComponents.vue +56 -56
  92. package/src/components/workflow/TaskOperation.vue +241 -240
  93. package/src/components/workflow/WorkflowTodoDialog.vue +83 -83
  94. package/src/components/workflow/components/AddOrMinusMultiDialog.vue +159 -159
  95. package/src/components/workflow/components/CheckDialog.vue +350 -350
  96. package/src/components/workflow/components/ProcessDetailComp.vue +149 -149
  97. package/src/components/workflow/components/ProcessDetailDialog.vue +129 -129
  98. package/src/components/workflow/components/ProcessInstance.vue +117 -117
  99. package/src/components/workflow/components/ProcessInstanceStep.vue +266 -266
  100. package/src/components/workflow/components/SelectAssigneeDialog.vue +109 -109
  101. package/src/components/workflow/components/SelectReturnActivityDialog.vue +104 -104
  102. package/src/config/ElementPlusConfig.ts +95 -95
  103. package/src/config/VxeTableConfig.ts +247 -247
  104. package/src/css/elementUI/autocomplete.scss +89 -89
  105. package/src/css/elementUI/checkbox.scss +298 -298
  106. package/src/css/elementUI/common/var.scss +1549 -1549
  107. package/src/css/elementUI/date-picker/picker.scss +219 -219
  108. package/src/css/elementUI/descriptions.scss +152 -152
  109. package/src/css/elementUI/drawer.scss +164 -164
  110. package/src/css/elementUI/radio.scss +215 -215
  111. package/src/css/elementUI/table.scss +697 -697
  112. package/src/css/elementUI/tabs.scss +659 -659
  113. package/src/css/vxeTableUI/all.scss +9 -9
  114. package/src/css/vxeTableUI/base.scss +16 -16
  115. package/src/css/vxeTableUI/components/colgroup.scss +0 -0
  116. package/src/css/vxeTableUI/components/column.scss +0 -0
  117. package/src/css/vxeTableUI/components/grid.scss +83 -83
  118. package/src/css/vxeTableUI/components/icon.scss +1017 -1017
  119. package/src/css/vxeTableUI/components/iconTable.scss +205 -205
  120. package/src/css/vxeTableUI/components/old-icon.scss +715 -715
  121. package/src/css/vxeTableUI/components/table-module/all.scss +6 -6
  122. package/src/css/vxeTableUI/components/table-module/custom.scss +490 -490
  123. package/src/css/vxeTableUI/components/table-module/edit.scss +0 -0
  124. package/src/css/vxeTableUI/components/table-module/export.scss +130 -130
  125. package/src/css/vxeTableUI/components/table-module/filter.scss +127 -127
  126. package/src/css/vxeTableUI/components/table-module/keyboard.scss +0 -0
  127. package/src/css/vxeTableUI/components/table-module/menu.scss +85 -85
  128. package/src/css/vxeTableUI/components/table-module/validator.scss +0 -0
  129. package/src/css/vxeTableUI/components/table.scss +2256 -2256
  130. package/src/css/vxeTableUI/components/toolbar.scss +99 -99
  131. package/src/css/vxeTableUI/components/ui.scss +0 -0
  132. package/src/css/vxeTableUI/components/v-x-e-table.scss +0 -0
  133. package/src/css/vxeTableUI/cssvar.scss +2 -2
  134. package/src/css/vxeTableUI/default.scss +2 -2
  135. package/src/css/vxeTableUI/helpers/baseMixin.scss +82 -82
  136. package/src/css/vxeTableUI/icon/iconfont.ttf +0 -0
  137. package/src/css/vxeTableUI/icon/iconfont.woff +0 -0
  138. package/src/css/vxeTableUI/icon/iconfont.woff2 +0 -0
  139. package/src/css/vxeTableUI/index.scss +4 -4
  140. package/src/css/vxeTableUI/modules.scss +5 -5
  141. package/src/css/vxeTableUI/theme/base.scss +88 -88
  142. package/src/css/vxeTableUI/theme/dark.scss +46 -46
  143. package/src/css/vxeTableUI/theme/light.scss +41 -41
  144. package/src/css/vxeTableUI/variable.scss +41 -41
  145. package/src/directives/vKeydown.ts +91 -91
  146. package/src/hooks/useDictHooks.ts +119 -119
  147. package/src/hooks/useEcharts.ts +58 -58
  148. package/src/hooks/useFileView.ts +11 -11
  149. package/src/hooks/useListenerHooks.ts +137 -137
  150. package/src/hooks/useMessageHooks.ts +132 -132
  151. package/src/hooks/usePermissionToolHooks.ts +21 -21
  152. package/src/hooks/useResetRefHooks.ts +18 -18
  153. package/src/hooks/userWorkflowHooks.ts +106 -106
  154. package/src/hooks/workflowTodo.ts +85 -85
  155. package/src/interface/BaseEntity.ts +30 -30
  156. package/src/interface/IMdmDept.ts +84 -84
  157. package/src/interface/IMdmEmployee.ts +153 -153
  158. package/src/interface/IMdmEmployeeQuery.ts +21 -21
  159. package/src/interface/IMdmOrg.ts +29 -29
  160. package/src/interface/IMdmOrgQuery.ts +13 -13
  161. package/src/interface/IOrgDeptInfo.ts +12 -12
  162. package/src/interface/ISortList.ts +6 -6
  163. package/src/interface/ISysDictDataCacheVo.ts +46 -46
  164. package/src/interface/ISysDictType.ts +37 -37
  165. package/src/interface/ISysMenuDataVo.ts +22 -22
  166. package/src/interface/ISysMenuInfoVo.ts +83 -83
  167. package/src/interface/ISysMenuOperationVo.ts +21 -21
  168. package/src/interface/ISysUploadFiles.ts +16 -16
  169. package/src/interface/ISysUserInfo.ts +70 -70
  170. package/src/interface/IUserBaseInfo.ts +90 -90
  171. package/src/interface/IUserPermissionVo.ts +41 -41
  172. package/src/interface/IVxeTable.ts +1 -1
  173. package/src/interface/Message.ts +72 -73
  174. package/src/interface/PageData.ts +17 -17
  175. package/src/interface/ResponseData.ts +16 -16
  176. package/src/interface/dictMapType.ts +11 -11
  177. package/src/interface/enum/MessageEnum.ts +41 -41
  178. package/src/interface/workflow/IWfProcessDefVo.ts +14 -14
  179. package/src/interface/workflow/IWfReturnNodeVo.ts +16 -16
  180. package/src/interface/workflow/IWfTaskAskVo.ts +65 -65
  181. package/src/interface/workflow/IWfTaskQueryVo.ts +30 -30
  182. package/src/interface/workflow/IWfTaskUsersVo.ts +21 -21
  183. package/src/interface/workflow/IWfTaskVo.ts +187 -187
  184. package/src/interface/workflow/workflow.ts +22 -22
  185. package/src/mixin/globalMixin.ts +48 -48
  186. package/src/packages/index.ts +18 -18
  187. package/src/packages/text.vue +13 -13
  188. package/src/plugins/echartsConfig.ts +74 -74
  189. package/src/plugins/plugins.ts +12 -12
  190. package/src/plugins/renderDialog.ts +74 -74
  191. package/src/stores/dictStore.ts +51 -51
  192. package/src/stores/messageStore.ts +49 -49
  193. package/src/stores/permissionStore.ts +112 -112
  194. package/src/stores/storeConfig.ts +23 -23
  195. package/src/stores/userInfoStore.ts +31 -31
  196. package/src/utils/AxiosConfig.ts +226 -226
  197. package/src/utils/FrameworkUtils.ts +358 -358
  198. package/src/utils/commonUtils.ts +115 -115
  199. package/src/utils/encrypt.ts +18 -18
  200. package/src/utils/modules.ts +8 -8
  201. package/src/utils/request.ts +76 -76
  202. package/src/utils/tree.ts +50 -50
  203. package/adtec-core-package/adtec-core-package.css +0 -1
  204. package/adtec-core-package/adtec-core-package.js +0 -41605
  205. package/adtec-core-package/adtec-core-package.umd.cjs +0 -79
  206. package/adtec-core-package/favicon.ico +0 -0
@@ -1,653 +1,653 @@
1
- <script setup lang="ts">
2
- import TreeNode from './nodes/TreeNode.vue'
3
- import Panel from './panels/index.vue'
4
- import type {
5
- ApprovalNode,
6
- BranchNode,
7
- CcNode,
8
- ConditionNode,
9
- ErrorInfo,
10
- ExclusiveNode,
11
- FlowNode,
12
- InclusiveNode,
13
- JumpNode,
14
- NodeType,
15
- NotifyNode,
16
- ParallelNode,
17
- TimerNode,
18
- } from './nodes/type'
19
- import type { FilterRules } from '../../components/AdvancedFilter/type'
20
- import type { Field } from '../../components/Render/type'
21
- // import BpmnComp from '@/framework/views/workflow/bpmnpackage/view.index.vue'
22
- // import ProcessDiagram from '@/framework/views/workflow/components/ProcessDiagram.vue'
23
- import { useDraggableScroll } from '../../hooks/useDraggableScroll'
24
- import { ElMessage } from 'element-plus'
25
- import { computed, provide, ref } from 'vue'
26
- import type { IWfProcessInstVo } from '../../../../interface/workflow/IWfTaskVo'
27
-
28
- const props = withDefaults(
29
- defineProps<{
30
- process: FlowNode
31
- fields: Field[]
32
- readOnly?: boolean
33
- defaultZoom?: number
34
- bgColor?: string
35
- bpmnView?: boolean
36
- bpmnXml?: string
37
- processInst?: IWfProcessInstVo
38
- }>(),
39
- {
40
- readOnly: false,
41
- defaultZoom: 100,
42
- bgColor: 'var(--el-bg-color-page)',
43
- bpmnView: false,
44
- bpmnXml: '',
45
- },
46
- )
47
- const processInstData = computed(() => {
48
- return props.processInst
49
- })
50
- const flatFields = computed(() => {
51
- const all: Field[] = []
52
- const loop = (children: Field[]) => {
53
- children.forEach((field) => {
54
- if (field.type === 'formItem') {
55
- all.push(field)
56
- }
57
- if (Array.isArray(field.children)) {
58
- loop(field.children)
59
- }
60
- })
61
- }
62
- loop(props.fields)
63
- return all
64
- })
65
- const getScale = computed(() => zoom.value / 100)
66
- const zoom = ref(props.defaultZoom)
67
- const readOnly = computed(() => props.readOnly)
68
- const activeData = ref<FlowNode>({
69
- id: '',
70
- name: '',
71
- type: 'start',
72
- })
73
- const penalVisible = ref(false)
74
- const nodesError = ref<Recordable<ErrorInfo[]>>({})
75
- const treeRoot = ref(null)
76
- const designerContainerRef = ref<HTMLElement | null>(null)
77
- const getTaskNodes = (id: string) => {
78
- let res = [] as FlowNode[]
79
- const allNodes = getAllNodes(props.process)
80
- for (let i in allNodes) {
81
- if (
82
- allNodes[i].id !== id &&
83
- !res.some((x) => x.id === allNodes[i].id) &&
84
- ['cc', 'approval', 'timer', 'notify'].includes(allNodes[i].type)
85
- ) {
86
- res.push(allNodes[i])
87
- }
88
- }
89
- return res
90
- }
91
- const addFormItem = (item: Field) => {
92
- props.fields.push(item)
93
- }
94
- const deleteFormItem = (id: string) => {
95
- const nodes = getAllNodes(props.process)
96
- for (const node of nodes) {
97
- if (node.type === 'condition') {
98
- if ((node as ConditionNode)?.conditions.conditions.findIndex((x) => x.field === id) > -1) {
99
- ElMessage.warning('参数已作为条件使用,无法删除!')
100
- return
101
- }
102
- }
103
- }
104
- props.fields.splice(
105
- props.fields.findIndex((x) => x.id === id),
106
- 1,
107
- )
108
- }
109
- const getParentNodes = (id: string) => {
110
- const nodes = getPathNodes(id, props.process, [])
111
- if (nodes && nodes.length > 0) {
112
- return nodes.filter((x) => x.type === 'approval')
113
- } else {
114
- return []
115
- }
116
- }
117
- const getPathNodes = (
118
- id: string,
119
- node: BranchNode | FlowNode,
120
- parents: (BranchNode | FlowNode)[],
121
- ): FlowNode[] => {
122
- const nodes = []
123
- if (node.id === id) {
124
- return parents
125
- }
126
- parents.push(node)
127
- if ('children' in node && Array.isArray(node.children) && node.children.length > 0) {
128
- // 如果是数组,递归遍历每个子节点
129
- node.children.forEach((childNode) => {
130
- nodes.push(...getPathNodes(id, childNode, [...parents]))
131
- })
132
- }
133
- if (node.child) {
134
- // 如果是单个子节点
135
- nodes.push(...getPathNodes(id, node.child, [...parents]))
136
- }
137
- return nodes
138
- }
139
- const getNodeById = (id: string) => {
140
- const nodes = getAllNodes(props.process)
141
- const node = nodes.find((x) => x.id === id)
142
- if (node) {
143
- return node
144
- } else {
145
- return undefined
146
- }
147
- }
148
- provide('flowDesign', {
149
- processInst: processInstData,
150
- readOnly: readOnly,
151
- fields: flatFields,
152
- nodesError: nodesError,
153
- getTaskNodes: getTaskNodes,
154
- getParentNodes: getParentNodes,
155
- addFormItem: addFormItem,
156
- deleteFormItem: deleteFormItem,
157
- getNodeById: getNodeById,
158
- })
159
-
160
- useDraggableScroll(designerContainerRef)
161
-
162
- const openPenal = (node: FlowNode) => {
163
- activeData.value = node
164
- penalVisible.value = true
165
- }
166
- const nextId = (): string => {
167
- let id = `node_${Math.random().toString(36).substring(2, 7)}`
168
- const findId = (node: FlowNode, id: string): boolean => {
169
- if (node.id === id) {
170
- return true
171
- }
172
- if (node.child) {
173
- return findId(node.child, id)
174
- }
175
- if ('children' in node) {
176
- const branchNode = node as BranchNode
177
- if (branchNode.children && branchNode.children.length > 0) {
178
- return branchNode.children.some((item) => {
179
- return findId(item, id)
180
- })
181
- }
182
- }
183
- return false
184
- }
185
- if (findId(props.process, id)) {
186
- return nextId()
187
- }
188
- return id
189
- }
190
- const addExclusive = (node: FlowNode) => {
191
- const child = node.child
192
- const id = nextId()
193
- const exclusiveNode = {
194
- id: id,
195
- pid: node.id,
196
- type: 'exclusive',
197
- name: '独占网关',
198
- child: child,
199
- children: [],
200
- } as ExclusiveNode
201
- if (child) {
202
- child.pid = id
203
- }
204
- addCondition(exclusiveNode)
205
- addCondition(exclusiveNode)
206
- node.child = exclusiveNode
207
- if (exclusiveNode.children.length > 0) {
208
- const condition = exclusiveNode.children[exclusiveNode.children.length - 1] as ConditionNode
209
- condition.def = true
210
- condition.name = '默认条件'
211
- }
212
- }
213
- const addInclusive = (node: FlowNode) => {
214
- const child = node.child
215
- const id = nextId()
216
- const inclusiveNode = {
217
- id: id,
218
- pid: node.id,
219
- type: 'inclusive',
220
- name: '包容网关',
221
- child: child,
222
- children: [],
223
- } as InclusiveNode
224
- if (child) {
225
- child.pid = id
226
- }
227
- addCondition(inclusiveNode)
228
- addCondition(inclusiveNode)
229
- node.child = inclusiveNode
230
- if (inclusiveNode.children.length > 0) {
231
- const condition = inclusiveNode.children[inclusiveNode.children.length - 1] as ConditionNode
232
- condition.def = true
233
- condition.name = '默认条件'
234
- }
235
- }
236
- const addParallel = (node: FlowNode) => {
237
- const child = node.child
238
- const id = nextId()
239
- const parallelNode = {
240
- id: id,
241
- pid: node.id,
242
- type: 'parallel',
243
- name: '并行网关',
244
- child: child,
245
- children: [],
246
- } as ParallelNode
247
- if (child) {
248
- child.pid = id
249
- }
250
- addConcurrent(parallelNode)
251
- addConcurrent(parallelNode)
252
- node.child = parallelNode
253
- }
254
- const addCondition = (node: FlowNode) => {
255
- const exclusive = node as ExclusiveNode
256
- exclusive.children.splice(exclusive.children.length == 0 ? 0 : exclusive.children.length - 1, 0, {
257
- id: nextId(),
258
- pid: exclusive.id,
259
- type: 'condition',
260
- def: false,
261
- name: `条件${exclusive.children.length == 0 ? 1 : exclusive.children.length}`,
262
- conditions: {
263
- operator: 'and',
264
- conditions: [],
265
- groups: [],
266
- } as FilterRules,
267
- child: undefined,
268
- })
269
- }
270
- const addConcurrent = (node: FlowNode) => {
271
- const parallel = node as ParallelNode
272
- parallel.children.splice(parallel.children.length, 0, {
273
- id: nextId(),
274
- pid: parallel.id,
275
- type: 'concurrent',
276
- name: `分支${parallel.children.length + 1}`,
277
- // conditions: {
278
- // operator: 'and',
279
- // conditions: [],
280
- // groups: []
281
- // } as FilterRules,
282
- child: undefined,
283
- })
284
- }
285
- // const addCondition = (node: FlowNode) => {
286
- // const exclusive = node as ExclusiveNode
287
- // exclusive.children.splice(exclusive.children.length - 1, 0, {
288
- // id: nextId(),
289
- // pid: exclusive.id,
290
- // type: 'condition',
291
- // def: false,
292
- // name: `条件${exclusive.children.length + 1}`,
293
- // conditions: {
294
- // operator: 'and',
295
- // conditions: [],
296
- // groups: []
297
- // } as FilterRules,
298
- // child: undefined
299
- // })
300
- // }
301
- const addCc = (node: FlowNode) => {
302
- const child = node.child
303
- const id = nextId()
304
- node.child = {
305
- id: id,
306
- pid: node.id,
307
- type: 'cc',
308
- name: '抄送人',
309
- child: child,
310
- assigneeType: 'user',
311
- formUser: '',
312
- formRole: '',
313
- users: [],
314
- roles: [],
315
- leader: 1,
316
- orgLeader: 1,
317
- choice: false,
318
- self: false,
319
- formProperties: [],
320
- } as CcNode
321
- if (child) {
322
- child.pid = id
323
- }
324
- }
325
- const addTimer = (node: FlowNode) => {
326
- const child = node.child
327
- const id = nextId()
328
- node.child = {
329
- id: id,
330
- pid: node.id,
331
- name: '计时等待',
332
- type: 'timer',
333
- child: child,
334
- waitType: 'duration',
335
- unit: 'PT%sS',
336
- duration: 0,
337
- timeDate: undefined,
338
- } as TimerNode
339
- if (child) {
340
- child.pid = id
341
- }
342
- }
343
- const addJump = (node: FlowNode) => {
344
- const child = node.child
345
- const id = nextId()
346
- node.child = {
347
- id: id,
348
- pid: node.id,
349
- name: '节点跳转',
350
- type: 'jump',
351
- child: child,
352
- targetNode: '',
353
- } as JumpNode
354
- if (child) {
355
- child.pid = id
356
- }
357
- }
358
- const addNotify = (node: FlowNode) => {
359
- const child = node.child
360
- const id = nextId()
361
- node.child = {
362
- id: id,
363
- pid: node.id,
364
- name: '消息通知',
365
- type: 'notify',
366
- child: child,
367
- assigneeType: 'user',
368
- formUser: '',
369
- formRole: '',
370
- users: [],
371
- roles: [],
372
- leader: 1,
373
- orgLeader: 1,
374
- choice: false,
375
- self: false,
376
- types: ['site'],
377
- subject: '',
378
- content: '',
379
- nodeTag: '',
380
- nodeParam: '',
381
- } as NotifyNode
382
- if (child) {
383
- child.pid = id
384
- }
385
- }
386
- const addApproval = (node: FlowNode) => {
387
- const child = node.child
388
- const id = nextId()
389
- node.child = {
390
- id: id,
391
- pid: node.id,
392
- type: 'approval',
393
- name: '审批步骤',
394
- executionListeners: [],
395
- child: child,
396
- // 属性
397
- manualUsers: false,
398
- hideUsers: false,
399
- filterUsers: 'no',
400
- assigneeType: 'user',
401
- formUser: '',
402
- formRole: '',
403
- users: [],
404
- roles: [],
405
- leader: 1,
406
- orgLeader: 1,
407
- choice: false,
408
- self: false,
409
- multi: 'single',
410
- multiPercent: 100,
411
- nobody: 'pass',
412
- nobodyUsers: [],
413
- formProperties: [],
414
- operations: {
415
- complete: true,
416
- refuse: false,
417
- back: true,
418
- transfer: false,
419
- delegate: false,
420
- addMulti: false,
421
- minusMulti: false,
422
- },
423
- msgTypes: ['site'],
424
- msgLevel: '50',
425
- msgSubject: '',
426
- msgContent: '',
427
- nodeTag: '',
428
- nodeParam: '',
429
- backNodes: [],
430
- sameUser: 'normal',
431
- } as ApprovalNode
432
- if (child) {
433
- child.pid = id
434
- }
435
- }
436
- const addNode = (type: NodeType, node: FlowNode) => {
437
- const addMap: Recordable<(node: FlowNode) => void> = {
438
- exclusive: addExclusive,
439
- inclusive: addInclusive,
440
- parallel: addParallel,
441
- condition: addCondition,
442
- concurrent: addConcurrent,
443
- cc: addCc,
444
- timer: addTimer,
445
- jump: addJump,
446
- notify: addNotify,
447
- approval: addApproval,
448
- }
449
- const fun = addMap[type]
450
- fun && fun(node)
451
- }
452
- const delNode = (del: FlowNode) => {
453
- delete nodesError.value[del.id]
454
- delNodeNext(props.process, del)
455
- }
456
- const delNodeNext = (next: FlowNode, del: FlowNode) => {
457
- delete nodesError.value[del.id]
458
- if (next.id === del.pid) {
459
- if ('children' in next && next.child?.id !== del.id) {
460
- const branchNode = next as BranchNode
461
- const index = branchNode.children.findIndex((item) => item.id === del.id)
462
- if (index !== -1) {
463
- if (branchNode.children.length <= 2) {
464
- delError(branchNode)
465
- delNode(branchNode)
466
- } else {
467
- delError(del)
468
- branchNode.children.splice(index, 1)
469
- }
470
- }
471
- } else {
472
- if (del.child && del.child.pid) {
473
- del.child.pid = next.id
474
- }
475
- next.child = del.child
476
- }
477
- } else {
478
- if (next.child) {
479
- delNodeNext(next.child, del)
480
- }
481
- if ('children' in next) {
482
- const nextBranch = next as BranchNode
483
- if (nextBranch.children && nextBranch.children.length > 0) {
484
- nextBranch.children.forEach((item) => {
485
- delNodeNext(item, del)
486
- })
487
- }
488
- }
489
- }
490
- }
491
- const delError = (node: FlowNode) => {
492
- delete nodesError.value[node.id]
493
- if (node.child) {
494
- delError(node.child)
495
- }
496
- if ('children' in node) {
497
- const branchNode = node as BranchNode
498
- if (branchNode.children && branchNode.children.length > 0) {
499
- branchNode.children.forEach((item) => {
500
- delError(item)
501
- })
502
- }
503
- }
504
- }
505
- const validate = () => {
506
- return new Promise((resolve, reject) => {
507
- const errors = Object.values(nodesError.value).flat()
508
- if (errors.length > 0) {
509
- reject(errors)
510
- } else {
511
- resolve(true)
512
- }
513
- })
514
- }
515
-
516
- const getAllNodes = (node: BranchNode | FlowNode): FlowNode[] => {
517
- const nodes = []
518
- if (node) {
519
- nodes.push(node)
520
- if ('children' in node && Array.isArray(node.children) && node.children.length > 0) {
521
- // 如果是数组,递归遍历每个子节点
522
- node.children.forEach((childNode) => {
523
- nodes.push(...getAllNodes(childNode))
524
- })
525
- }
526
- if (node.child) {
527
- // 如果是单个子节点
528
- nodes.push(...getAllNodes(node.child))
529
- }
530
- }
531
- return nodes
532
- }
533
-
534
- defineExpose({
535
- validate,
536
- })
537
- </script>
538
-
539
- <template>
540
- <div class="designer-container cursor-default active:cursor-grabbing" ref="designerContainerRef">
541
- <div class="tool">
542
- <slot></slot>
543
- </div>
544
- <!-- <template v-if="props.bpmnView && props.bpmnXml">-->
545
- <!-- <process-diagram :xml="bpmnXml"></process-diagram>-->
546
- <!-- </template>-->
547
- <!-- <template>-->
548
- <el-flex
549
- width="300px"
550
- height="30px"
551
- align="center"
552
- v-if="processInstData?.hisTasks?.length || processInstData?.hisTasks?.length"
553
- class="legend"
554
- >
555
- <div style="height: 15px; width: 15px; border-radius: 5px; background: #18ad43" />
556
- <span>已完成</span>
557
- <div
558
- style="
559
- height: 15px;
560
- width: 15px;
561
- border-radius: 5px;
562
- background: #0b83de;
563
- margin-left: 20px;
564
- "
565
- />
566
- <span>进行中</span>
567
- <div
568
- style="
569
- height: 15px;
570
- width: 15px;
571
- border-radius: 5px;
572
- background: #9b9ea1;
573
- margin-left: 20px;
574
- "
575
- />
576
- <span>未开始</span>
577
- </el-flex>
578
- <!--放大/缩小-->
579
- <div class="zoom">
580
- <el-tooltip content="放大" placement="bottom-start">
581
- <el-button icon="plus" @click="zoom += 10" :disabled="zoom >= 150" circle></el-button>
582
- </el-tooltip>
583
- <span>{{ zoom }}%</span>
584
- <el-tooltip content="缩小" placement="bottom-start">
585
- <el-button icon="minus" @click="zoom -= 10" circle :disabled="zoom <= 50"></el-button>
586
- </el-tooltip>
587
- </div>
588
- <!--流程树-->
589
- <el-scrollbar style="width: 100%">
590
- <div class="node-container">
591
- <TreeNode
592
- ref="treeRoot"
593
- :node="process"
594
- @addNode="addNode"
595
- @delNode="delNode"
596
- @activeNode="openPenal"
597
- />
598
- </div>
599
- </el-scrollbar>
600
- <!--属性面板-->
601
- <Panel v-model="penalVisible" :active-data="activeData" />
602
- <!-- </template>-->
603
- </div>
604
- </template>
605
-
606
- <style scoped lang="scss">
607
- .designer-container {
608
- --flow-bg-color: v-bind(bgColor);
609
- position: relative;
610
- display: flex;
611
- flex-direction: row;
612
- height: 100%;
613
- width: 100%;
614
- overflow: auto;
615
- background-color: var(--flow-bg-color);
616
-
617
- .legend {
618
- position: absolute;
619
- z-index: 999;
620
- top: 10px;
621
- left: 40px;
622
- }
623
-
624
- .zoom {
625
- position: absolute;
626
- z-index: 999;
627
- top: 10px;
628
- right: 40px;
629
-
630
- span {
631
- margin: 0 10px;
632
- }
633
- }
634
-
635
- .tool {
636
- position: absolute;
637
- z-index: 999;
638
- top: 10px;
639
- left: 15px;
640
- display: flex;
641
- gap: 5px;
642
- }
643
-
644
- .node-container {
645
- margin: 0 auto;
646
- transform: scale(v-bind(getScale));
647
- transform-origin: 50% 0 0;
648
- display: flex;
649
- align-items: center;
650
- flex-direction: column;
651
- }
652
- }
653
- </style>
1
+ <script setup lang="ts">
2
+ import TreeNode from './nodes/TreeNode.vue'
3
+ import Panel from './panels/index.vue'
4
+ import type {
5
+ ApprovalNode,
6
+ BranchNode,
7
+ CcNode,
8
+ ConditionNode,
9
+ ErrorInfo,
10
+ ExclusiveNode,
11
+ FlowNode,
12
+ InclusiveNode,
13
+ JumpNode,
14
+ NodeType,
15
+ NotifyNode,
16
+ ParallelNode,
17
+ TimerNode,
18
+ } from './nodes/type'
19
+ import type { FilterRules } from '../../components/AdvancedFilter/type'
20
+ import type { Field } from '../../components/Render/type'
21
+ // import BpmnComp from '@/framework/views/workflow/bpmnpackage/view.index.vue'
22
+ // import ProcessDiagram from '@/framework/views/workflow/components/ProcessDiagram.vue'
23
+ import { useDraggableScroll } from '../../hooks/useDraggableScroll'
24
+ import { ElMessage } from 'element-plus'
25
+ import { computed, provide, ref } from 'vue'
26
+ import type { IWfProcessInstVo } from '../../../../interface/workflow/IWfTaskVo'
27
+
28
+ const props = withDefaults(
29
+ defineProps<{
30
+ process: FlowNode
31
+ fields: Field[]
32
+ readOnly?: boolean
33
+ defaultZoom?: number
34
+ bgColor?: string
35
+ bpmnView?: boolean
36
+ bpmnXml?: string
37
+ processInst?: IWfProcessInstVo
38
+ }>(),
39
+ {
40
+ readOnly: false,
41
+ defaultZoom: 100,
42
+ bgColor: 'var(--el-bg-color-page)',
43
+ bpmnView: false,
44
+ bpmnXml: '',
45
+ },
46
+ )
47
+ const processInstData = computed(() => {
48
+ return props.processInst
49
+ })
50
+ const flatFields = computed(() => {
51
+ const all: Field[] = []
52
+ const loop = (children: Field[]) => {
53
+ children.forEach((field) => {
54
+ if (field.type === 'formItem') {
55
+ all.push(field)
56
+ }
57
+ if (Array.isArray(field.children)) {
58
+ loop(field.children)
59
+ }
60
+ })
61
+ }
62
+ loop(props.fields)
63
+ return all
64
+ })
65
+ const getScale = computed(() => zoom.value / 100)
66
+ const zoom = ref(props.defaultZoom)
67
+ const readOnly = computed(() => props.readOnly)
68
+ const activeData = ref<FlowNode>({
69
+ id: '',
70
+ name: '',
71
+ type: 'start',
72
+ })
73
+ const penalVisible = ref(false)
74
+ const nodesError = ref<Recordable<ErrorInfo[]>>({})
75
+ const treeRoot = ref(null)
76
+ const designerContainerRef = ref<HTMLElement | null>(null)
77
+ const getTaskNodes = (id: string) => {
78
+ let res = [] as FlowNode[]
79
+ const allNodes = getAllNodes(props.process)
80
+ for (let i in allNodes) {
81
+ if (
82
+ allNodes[i].id !== id &&
83
+ !res.some((x) => x.id === allNodes[i].id) &&
84
+ ['cc', 'approval', 'timer', 'notify'].includes(allNodes[i].type)
85
+ ) {
86
+ res.push(allNodes[i])
87
+ }
88
+ }
89
+ return res
90
+ }
91
+ const addFormItem = (item: Field) => {
92
+ props.fields.push(item)
93
+ }
94
+ const deleteFormItem = (id: string) => {
95
+ const nodes = getAllNodes(props.process)
96
+ for (const node of nodes) {
97
+ if (node.type === 'condition') {
98
+ if ((node as ConditionNode)?.conditions.conditions.findIndex((x) => x.field === id) > -1) {
99
+ ElMessage.warning('参数已作为条件使用,无法删除!')
100
+ return
101
+ }
102
+ }
103
+ }
104
+ props.fields.splice(
105
+ props.fields.findIndex((x) => x.id === id),
106
+ 1,
107
+ )
108
+ }
109
+ const getParentNodes = (id: string) => {
110
+ const nodes = getPathNodes(id, props.process, [])
111
+ if (nodes && nodes.length > 0) {
112
+ return nodes.filter((x) => x.type === 'approval')
113
+ } else {
114
+ return []
115
+ }
116
+ }
117
+ const getPathNodes = (
118
+ id: string,
119
+ node: BranchNode | FlowNode,
120
+ parents: (BranchNode | FlowNode)[],
121
+ ): FlowNode[] => {
122
+ const nodes = []
123
+ if (node.id === id) {
124
+ return parents
125
+ }
126
+ parents.push(node)
127
+ if ('children' in node && Array.isArray(node.children) && node.children.length > 0) {
128
+ // 如果是数组,递归遍历每个子节点
129
+ node.children.forEach((childNode) => {
130
+ nodes.push(...getPathNodes(id, childNode, [...parents]))
131
+ })
132
+ }
133
+ if (node.child) {
134
+ // 如果是单个子节点
135
+ nodes.push(...getPathNodes(id, node.child, [...parents]))
136
+ }
137
+ return nodes
138
+ }
139
+ const getNodeById = (id: string) => {
140
+ const nodes = getAllNodes(props.process)
141
+ const node = nodes.find((x) => x.id === id)
142
+ if (node) {
143
+ return node
144
+ } else {
145
+ return undefined
146
+ }
147
+ }
148
+ provide('flowDesign', {
149
+ processInst: processInstData,
150
+ readOnly: readOnly,
151
+ fields: flatFields,
152
+ nodesError: nodesError,
153
+ getTaskNodes: getTaskNodes,
154
+ getParentNodes: getParentNodes,
155
+ addFormItem: addFormItem,
156
+ deleteFormItem: deleteFormItem,
157
+ getNodeById: getNodeById,
158
+ })
159
+
160
+ useDraggableScroll(designerContainerRef)
161
+
162
+ const openPenal = (node: FlowNode) => {
163
+ activeData.value = node
164
+ penalVisible.value = true
165
+ }
166
+ const nextId = (): string => {
167
+ let id = `node_${Math.random().toString(36).substring(2, 7)}`
168
+ const findId = (node: FlowNode, id: string): boolean => {
169
+ if (node.id === id) {
170
+ return true
171
+ }
172
+ if (node.child) {
173
+ return findId(node.child, id)
174
+ }
175
+ if ('children' in node) {
176
+ const branchNode = node as BranchNode
177
+ if (branchNode.children && branchNode.children.length > 0) {
178
+ return branchNode.children.some((item) => {
179
+ return findId(item, id)
180
+ })
181
+ }
182
+ }
183
+ return false
184
+ }
185
+ if (findId(props.process, id)) {
186
+ return nextId()
187
+ }
188
+ return id
189
+ }
190
+ const addExclusive = (node: FlowNode) => {
191
+ const child = node.child
192
+ const id = nextId()
193
+ const exclusiveNode = {
194
+ id: id,
195
+ pid: node.id,
196
+ type: 'exclusive',
197
+ name: '独占网关',
198
+ child: child,
199
+ children: [],
200
+ } as ExclusiveNode
201
+ if (child) {
202
+ child.pid = id
203
+ }
204
+ addCondition(exclusiveNode)
205
+ addCondition(exclusiveNode)
206
+ node.child = exclusiveNode
207
+ if (exclusiveNode.children.length > 0) {
208
+ const condition = exclusiveNode.children[exclusiveNode.children.length - 1] as ConditionNode
209
+ condition.def = true
210
+ condition.name = '默认条件'
211
+ }
212
+ }
213
+ const addInclusive = (node: FlowNode) => {
214
+ const child = node.child
215
+ const id = nextId()
216
+ const inclusiveNode = {
217
+ id: id,
218
+ pid: node.id,
219
+ type: 'inclusive',
220
+ name: '包容网关',
221
+ child: child,
222
+ children: [],
223
+ } as InclusiveNode
224
+ if (child) {
225
+ child.pid = id
226
+ }
227
+ addCondition(inclusiveNode)
228
+ addCondition(inclusiveNode)
229
+ node.child = inclusiveNode
230
+ if (inclusiveNode.children.length > 0) {
231
+ const condition = inclusiveNode.children[inclusiveNode.children.length - 1] as ConditionNode
232
+ condition.def = true
233
+ condition.name = '默认条件'
234
+ }
235
+ }
236
+ const addParallel = (node: FlowNode) => {
237
+ const child = node.child
238
+ const id = nextId()
239
+ const parallelNode = {
240
+ id: id,
241
+ pid: node.id,
242
+ type: 'parallel',
243
+ name: '并行网关',
244
+ child: child,
245
+ children: [],
246
+ } as ParallelNode
247
+ if (child) {
248
+ child.pid = id
249
+ }
250
+ addConcurrent(parallelNode)
251
+ addConcurrent(parallelNode)
252
+ node.child = parallelNode
253
+ }
254
+ const addCondition = (node: FlowNode) => {
255
+ const exclusive = node as ExclusiveNode
256
+ exclusive.children.splice(exclusive.children.length == 0 ? 0 : exclusive.children.length - 1, 0, {
257
+ id: nextId(),
258
+ pid: exclusive.id,
259
+ type: 'condition',
260
+ def: false,
261
+ name: `条件${exclusive.children.length == 0 ? 1 : exclusive.children.length}`,
262
+ conditions: {
263
+ operator: 'and',
264
+ conditions: [],
265
+ groups: [],
266
+ } as FilterRules,
267
+ child: undefined,
268
+ })
269
+ }
270
+ const addConcurrent = (node: FlowNode) => {
271
+ const parallel = node as ParallelNode
272
+ parallel.children.splice(parallel.children.length, 0, {
273
+ id: nextId(),
274
+ pid: parallel.id,
275
+ type: 'concurrent',
276
+ name: `分支${parallel.children.length + 1}`,
277
+ // conditions: {
278
+ // operator: 'and',
279
+ // conditions: [],
280
+ // groups: []
281
+ // } as FilterRules,
282
+ child: undefined,
283
+ })
284
+ }
285
+ // const addCondition = (node: FlowNode) => {
286
+ // const exclusive = node as ExclusiveNode
287
+ // exclusive.children.splice(exclusive.children.length - 1, 0, {
288
+ // id: nextId(),
289
+ // pid: exclusive.id,
290
+ // type: 'condition',
291
+ // def: false,
292
+ // name: `条件${exclusive.children.length + 1}`,
293
+ // conditions: {
294
+ // operator: 'and',
295
+ // conditions: [],
296
+ // groups: []
297
+ // } as FilterRules,
298
+ // child: undefined
299
+ // })
300
+ // }
301
+ const addCc = (node: FlowNode) => {
302
+ const child = node.child
303
+ const id = nextId()
304
+ node.child = {
305
+ id: id,
306
+ pid: node.id,
307
+ type: 'cc',
308
+ name: '抄送人',
309
+ child: child,
310
+ assigneeType: 'user',
311
+ formUser: '',
312
+ formRole: '',
313
+ users: [],
314
+ roles: [],
315
+ leader: 1,
316
+ orgLeader: 1,
317
+ choice: false,
318
+ self: false,
319
+ formProperties: [],
320
+ } as CcNode
321
+ if (child) {
322
+ child.pid = id
323
+ }
324
+ }
325
+ const addTimer = (node: FlowNode) => {
326
+ const child = node.child
327
+ const id = nextId()
328
+ node.child = {
329
+ id: id,
330
+ pid: node.id,
331
+ name: '计时等待',
332
+ type: 'timer',
333
+ child: child,
334
+ waitType: 'duration',
335
+ unit: 'PT%sS',
336
+ duration: 0,
337
+ timeDate: undefined,
338
+ } as TimerNode
339
+ if (child) {
340
+ child.pid = id
341
+ }
342
+ }
343
+ const addJump = (node: FlowNode) => {
344
+ const child = node.child
345
+ const id = nextId()
346
+ node.child = {
347
+ id: id,
348
+ pid: node.id,
349
+ name: '节点跳转',
350
+ type: 'jump',
351
+ child: child,
352
+ targetNode: '',
353
+ } as JumpNode
354
+ if (child) {
355
+ child.pid = id
356
+ }
357
+ }
358
+ const addNotify = (node: FlowNode) => {
359
+ const child = node.child
360
+ const id = nextId()
361
+ node.child = {
362
+ id: id,
363
+ pid: node.id,
364
+ name: '消息通知',
365
+ type: 'notify',
366
+ child: child,
367
+ assigneeType: 'user',
368
+ formUser: '',
369
+ formRole: '',
370
+ users: [],
371
+ roles: [],
372
+ leader: 1,
373
+ orgLeader: 1,
374
+ choice: false,
375
+ self: false,
376
+ types: ['site'],
377
+ subject: '',
378
+ content: '',
379
+ nodeTag: '',
380
+ nodeParam: '',
381
+ } as NotifyNode
382
+ if (child) {
383
+ child.pid = id
384
+ }
385
+ }
386
+ const addApproval = (node: FlowNode) => {
387
+ const child = node.child
388
+ const id = nextId()
389
+ node.child = {
390
+ id: id,
391
+ pid: node.id,
392
+ type: 'approval',
393
+ name: '审批步骤',
394
+ executionListeners: [],
395
+ child: child,
396
+ // 属性
397
+ manualUsers: false,
398
+ hideUsers: false,
399
+ filterUsers: 'no',
400
+ assigneeType: 'user',
401
+ formUser: '',
402
+ formRole: '',
403
+ users: [],
404
+ roles: [],
405
+ leader: 1,
406
+ orgLeader: 1,
407
+ choice: false,
408
+ self: false,
409
+ multi: 'single',
410
+ multiPercent: 100,
411
+ nobody: 'pass',
412
+ nobodyUsers: [],
413
+ formProperties: [],
414
+ operations: {
415
+ complete: true,
416
+ refuse: false,
417
+ back: true,
418
+ transfer: false,
419
+ delegate: false,
420
+ addMulti: false,
421
+ minusMulti: false,
422
+ },
423
+ msgTypes: ['site'],
424
+ msgLevel: '50',
425
+ msgSubject: '',
426
+ msgContent: '',
427
+ nodeTag: '',
428
+ nodeParam: '',
429
+ backNodes: [],
430
+ sameUser: 'normal',
431
+ } as ApprovalNode
432
+ if (child) {
433
+ child.pid = id
434
+ }
435
+ }
436
+ const addNode = (type: NodeType, node: FlowNode) => {
437
+ const addMap: Recordable<(node: FlowNode) => void> = {
438
+ exclusive: addExclusive,
439
+ inclusive: addInclusive,
440
+ parallel: addParallel,
441
+ condition: addCondition,
442
+ concurrent: addConcurrent,
443
+ cc: addCc,
444
+ timer: addTimer,
445
+ jump: addJump,
446
+ notify: addNotify,
447
+ approval: addApproval,
448
+ }
449
+ const fun = addMap[type]
450
+ fun && fun(node)
451
+ }
452
+ const delNode = (del: FlowNode) => {
453
+ delete nodesError.value[del.id]
454
+ delNodeNext(props.process, del)
455
+ }
456
+ const delNodeNext = (next: FlowNode, del: FlowNode) => {
457
+ delete nodesError.value[del.id]
458
+ if (next.id === del.pid) {
459
+ if ('children' in next && next.child?.id !== del.id) {
460
+ const branchNode = next as BranchNode
461
+ const index = branchNode.children.findIndex((item) => item.id === del.id)
462
+ if (index !== -1) {
463
+ if (branchNode.children.length <= 2) {
464
+ delError(branchNode)
465
+ delNode(branchNode)
466
+ } else {
467
+ delError(del)
468
+ branchNode.children.splice(index, 1)
469
+ }
470
+ }
471
+ } else {
472
+ if (del.child && del.child.pid) {
473
+ del.child.pid = next.id
474
+ }
475
+ next.child = del.child
476
+ }
477
+ } else {
478
+ if (next.child) {
479
+ delNodeNext(next.child, del)
480
+ }
481
+ if ('children' in next) {
482
+ const nextBranch = next as BranchNode
483
+ if (nextBranch.children && nextBranch.children.length > 0) {
484
+ nextBranch.children.forEach((item) => {
485
+ delNodeNext(item, del)
486
+ })
487
+ }
488
+ }
489
+ }
490
+ }
491
+ const delError = (node: FlowNode) => {
492
+ delete nodesError.value[node.id]
493
+ if (node.child) {
494
+ delError(node.child)
495
+ }
496
+ if ('children' in node) {
497
+ const branchNode = node as BranchNode
498
+ if (branchNode.children && branchNode.children.length > 0) {
499
+ branchNode.children.forEach((item) => {
500
+ delError(item)
501
+ })
502
+ }
503
+ }
504
+ }
505
+ const validate = () => {
506
+ return new Promise((resolve, reject) => {
507
+ const errors = Object.values(nodesError.value).flat()
508
+ if (errors.length > 0) {
509
+ reject(errors)
510
+ } else {
511
+ resolve(true)
512
+ }
513
+ })
514
+ }
515
+
516
+ const getAllNodes = (node: BranchNode | FlowNode): FlowNode[] => {
517
+ const nodes = []
518
+ if (node) {
519
+ nodes.push(node)
520
+ if ('children' in node && Array.isArray(node.children) && node.children.length > 0) {
521
+ // 如果是数组,递归遍历每个子节点
522
+ node.children.forEach((childNode) => {
523
+ nodes.push(...getAllNodes(childNode))
524
+ })
525
+ }
526
+ if (node.child) {
527
+ // 如果是单个子节点
528
+ nodes.push(...getAllNodes(node.child))
529
+ }
530
+ }
531
+ return nodes
532
+ }
533
+
534
+ defineExpose({
535
+ validate,
536
+ })
537
+ </script>
538
+
539
+ <template>
540
+ <div class="designer-container cursor-default active:cursor-grabbing" ref="designerContainerRef">
541
+ <div class="tool">
542
+ <slot></slot>
543
+ </div>
544
+ <!-- <template v-if="props.bpmnView && props.bpmnXml">-->
545
+ <!-- <process-diagram :xml="bpmnXml"></process-diagram>-->
546
+ <!-- </template>-->
547
+ <!-- <template>-->
548
+ <el-flex
549
+ width="300px"
550
+ height="30px"
551
+ align="center"
552
+ v-if="processInstData?.hisTasks?.length || processInstData?.hisTasks?.length"
553
+ class="legend"
554
+ >
555
+ <div style="height: 15px; width: 15px; border-radius: 5px; background: #18ad43" />
556
+ <span>已完成</span>
557
+ <div
558
+ style="
559
+ height: 15px;
560
+ width: 15px;
561
+ border-radius: 5px;
562
+ background: #0b83de;
563
+ margin-left: 20px;
564
+ "
565
+ />
566
+ <span>进行中</span>
567
+ <div
568
+ style="
569
+ height: 15px;
570
+ width: 15px;
571
+ border-radius: 5px;
572
+ background: #9b9ea1;
573
+ margin-left: 20px;
574
+ "
575
+ />
576
+ <span>未开始</span>
577
+ </el-flex>
578
+ <!--放大/缩小-->
579
+ <div class="zoom">
580
+ <el-tooltip content="放大" placement="bottom-start">
581
+ <el-button icon="plus" @click="zoom += 10" :disabled="zoom >= 150" circle></el-button>
582
+ </el-tooltip>
583
+ <span>{{ zoom }}%</span>
584
+ <el-tooltip content="缩小" placement="bottom-start">
585
+ <el-button icon="minus" @click="zoom -= 10" circle :disabled="zoom <= 50"></el-button>
586
+ </el-tooltip>
587
+ </div>
588
+ <!--流程树-->
589
+ <el-scrollbar style="width: 100%">
590
+ <div class="node-container">
591
+ <TreeNode
592
+ ref="treeRoot"
593
+ :node="process"
594
+ @addNode="addNode"
595
+ @delNode="delNode"
596
+ @activeNode="openPenal"
597
+ />
598
+ </div>
599
+ </el-scrollbar>
600
+ <!--属性面板-->
601
+ <Panel v-model="penalVisible" :active-data="activeData" />
602
+ <!-- </template>-->
603
+ </div>
604
+ </template>
605
+
606
+ <style scoped lang="scss">
607
+ .designer-container {
608
+ --flow-bg-color: v-bind(bgColor);
609
+ position: relative;
610
+ display: flex;
611
+ flex-direction: row;
612
+ height: 100%;
613
+ width: 100%;
614
+ overflow: auto;
615
+ background-color: var(--flow-bg-color);
616
+
617
+ .legend {
618
+ position: absolute;
619
+ z-index: 999;
620
+ top: 10px;
621
+ left: 40px;
622
+ }
623
+
624
+ .zoom {
625
+ position: absolute;
626
+ z-index: 999;
627
+ top: 10px;
628
+ right: 40px;
629
+
630
+ span {
631
+ margin: 0 10px;
632
+ }
633
+ }
634
+
635
+ .tool {
636
+ position: absolute;
637
+ z-index: 999;
638
+ top: 10px;
639
+ left: 15px;
640
+ display: flex;
641
+ gap: 5px;
642
+ }
643
+
644
+ .node-container {
645
+ margin: 0 auto;
646
+ transform: scale(v-bind(getScale));
647
+ transform-origin: 50% 0 0;
648
+ display: flex;
649
+ align-items: center;
650
+ flex-direction: column;
651
+ }
652
+ }
653
+ </style>