workflow-editor 0.9.68-dw → 0.9.68

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 (120) hide show
  1. package/lib/workflow-editor.css +1 -1
  2. package/lib/workflow-editor.umd.min.js +10 -10
  3. package/package.json +2 -2
  4. package/packages/index.js +34 -0
  5. package/packages/plugins/formValidatorUtil.js +533 -0
  6. package/packages/plugins/index.js +8 -0
  7. package/packages/workflow-editor/index.js +14 -0
  8. package/packages/workflow-editor/src/api.js +7 -0
  9. package/packages/workflow-editor/src/assets/wf-editor-icons.js +2 -0
  10. package/packages/workflow-editor/src/constant.js +8 -0
  11. package/packages/workflow-editor/src/json-object-templates/auto-task.js +70 -0
  12. package/packages/workflow-editor/src/json-object-templates/copy-task.js +72 -0
  13. package/packages/workflow-editor/src/json-object-templates/decision.js +11 -0
  14. package/packages/workflow-editor/src/json-object-templates/end.js +14 -0
  15. package/packages/workflow-editor/src/json-object-templates/fork.js +10 -0
  16. package/packages/workflow-editor/src/json-object-templates/human-decision.js +9 -0
  17. package/packages/workflow-editor/src/json-object-templates/human-task.js +199 -0
  18. package/packages/workflow-editor/src/json-object-templates/join.js +10 -0
  19. package/packages/workflow-editor/src/json-object-templates/process.js +98 -0
  20. package/packages/workflow-editor/src/json-object-templates/start.js +13 -0
  21. package/packages/workflow-editor/src/json-object-templates/subprocess.js +31 -0
  22. package/packages/workflow-editor/src/json-object-templates/transition.js +26 -0
  23. package/packages/workflow-editor/src/main/admin-save-dialog.vue +66 -0
  24. package/packages/workflow-editor/src/main/canvas.vue +483 -0
  25. package/packages/workflow-editor/src/main/context-menu.vue +132 -0
  26. package/packages/workflow-editor/src/main/icon-svg.vue +32 -0
  27. package/packages/workflow-editor/src/main/selection-region.vue +66 -0
  28. package/packages/workflow-editor/src/main/tache-history-tooltip.vue +38 -0
  29. package/packages/workflow-editor/src/main/tache-name-input.vue +19 -0
  30. package/packages/workflow-editor/src/main/tache-subprocess-history-dialog.vue +35 -0
  31. package/packages/workflow-editor/src/main/toolbox.vue +60 -0
  32. package/packages/workflow-editor/src/main/wf-history-canvas.vue +304 -0
  33. package/packages/workflow-editor/src/process-json.js +623 -0
  34. package/packages/workflow-editor/src/process-service.js +31 -0
  35. package/packages/workflow-editor/src/properties-editors/auto-task/basic-properties.vue +81 -0
  36. package/packages/workflow-editor/src/properties-editors/auto-task/permission-settings.vue +155 -0
  37. package/packages/workflow-editor/src/properties-editors/auto-task.vue +73 -0
  38. package/packages/workflow-editor/src/properties-editors/common/additional-condition-utils.js +556 -0
  39. package/packages/workflow-editor/src/properties-editors/common/additional-condition.vue +276 -0
  40. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields-utils.js +34 -0
  41. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields.vue +239 -0
  42. package/packages/workflow-editor/src/properties-editors/common/common-notice-tool.vue +67 -0
  43. package/packages/workflow-editor/src/properties-editors/common/common-user-condition.vue +241 -0
  44. package/packages/workflow-editor/src/properties-editors/common/form-fields-utils.js +23 -0
  45. package/packages/workflow-editor/src/properties-editors/common/form-fields.vue +116 -0
  46. package/packages/workflow-editor/src/properties-editors/common/i18n-input.vue +75 -0
  47. package/packages/workflow-editor/src/properties-editors/common/i18n-set-dialog.vue +125 -0
  48. package/packages/workflow-editor/src/properties-editors/common/notice-reminder.vue +72 -0
  49. package/packages/workflow-editor/src/properties-editors/common/notice.vue +101 -0
  50. package/packages/workflow-editor/src/properties-editors/common/reminder.vue +185 -0
  51. package/packages/workflow-editor/src/properties-editors/common/select-mail-template.vue +83 -0
  52. package/packages/workflow-editor/src/properties-editors/common/standard-fields.vue +65 -0
  53. package/packages/workflow-editor/src/properties-editors/common/system-role-tree-inline.vue +355 -0
  54. package/packages/workflow-editor/src/properties-editors/common/system-role-tree.vue +63 -0
  55. package/packages/workflow-editor/src/properties-editors/common/task-title.vue +148 -0
  56. package/packages/workflow-editor/src/properties-editors/common/transactor-settings.vue +275 -0
  57. package/packages/workflow-editor/src/properties-editors/common/user-selection.vue +386 -0
  58. package/packages/workflow-editor/src/properties-editors/common/value-selection-dialog.vue +209 -0
  59. package/packages/workflow-editor/src/properties-editors/common/variables.vue +135 -0
  60. package/packages/workflow-editor/src/properties-editors/copy-task/basic-properties.vue +90 -0
  61. package/packages/workflow-editor/src/properties-editors/copy-task/permission-settings.vue +155 -0
  62. package/packages/workflow-editor/src/properties-editors/copy-task.vue +94 -0
  63. package/packages/workflow-editor/src/properties-editors/decision.vue +90 -0
  64. package/packages/workflow-editor/src/properties-editors/fork.vue +72 -0
  65. package/packages/workflow-editor/src/properties-editors/human-decision.vue +44 -0
  66. package/packages/workflow-editor/src/properties-editors/human-task/additional-condition-dialog.vue +60 -0
  67. package/packages/workflow-editor/src/properties-editors/human-task/basic-properties.vue +160 -0
  68. package/packages/workflow-editor/src/properties-editors/human-task/componentsConfigUtil.js +291 -0
  69. package/packages/workflow-editor/src/properties-editors/human-task/custom-actions.vue +249 -0
  70. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-field-setting.vue +392 -0
  71. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-fields.vue +241 -0
  72. package/packages/workflow-editor/src/properties-editors/human-task/editable-field-selection.vue +220 -0
  73. package/packages/workflow-editor/src/properties-editors/human-task/editable-fields.vue +204 -0
  74. package/packages/workflow-editor/src/properties-editors/human-task/events.vue +59 -0
  75. package/packages/workflow-editor/src/properties-editors/human-task/permission-settings.vue +207 -0
  76. package/packages/workflow-editor/src/properties-editors/human-task/selection-conditions.vue +390 -0
  77. package/packages/workflow-editor/src/properties-editors/human-task.vue +109 -0
  78. package/packages/workflow-editor/src/properties-editors/join.vue +44 -0
  79. package/packages/workflow-editor/src/properties-editors/process/basic-properties.vue +273 -0
  80. package/packages/workflow-editor/src/properties-editors/process/events.vue +76 -0
  81. package/packages/workflow-editor/src/properties-editors/process/notice-settings.vue +60 -0
  82. package/packages/workflow-editor/src/properties-editors/process/parameter-settings.vue +95 -0
  83. package/packages/workflow-editor/src/properties-editors/process/permission-settings.vue +28 -0
  84. package/packages/workflow-editor/src/properties-editors/process/selectPage.vue +81 -0
  85. package/packages/workflow-editor/src/properties-editors/process.vue +115 -0
  86. package/packages/workflow-editor/src/properties-editors/subprocess/basic-properties.vue +199 -0
  87. package/packages/workflow-editor/src/properties-editors/subprocess/events.vue +26 -0
  88. package/packages/workflow-editor/src/properties-editors/subprocess/field-mappings.vue +206 -0
  89. package/packages/workflow-editor/src/properties-editors/subprocess/transactor-settings.vue +64 -0
  90. package/packages/workflow-editor/src/properties-editors/subprocess.vue +79 -0
  91. package/packages/workflow-editor/src/properties-editors/transition/basic-properties.vue +53 -0
  92. package/packages/workflow-editor/src/properties-editors/transition.vue +74 -0
  93. package/packages/workflow-editor/src/properties-editors/user-condition.js +183 -0
  94. package/packages/workflow-editor/src/store/getters.js +27 -0
  95. package/packages/workflow-editor/src/store/workflow-editor.js +125 -0
  96. package/packages/workflow-editor/src/taches/auto-task.vue +99 -0
  97. package/packages/workflow-editor/src/taches/common-methods.js +21 -0
  98. package/packages/workflow-editor/src/taches/copy-task.vue +99 -0
  99. package/packages/workflow-editor/src/taches/custom-task.vue +88 -0
  100. package/packages/workflow-editor/src/taches/decision.vue +102 -0
  101. package/packages/workflow-editor/src/taches/end.vue +76 -0
  102. package/packages/workflow-editor/src/taches/fork.vue +102 -0
  103. package/packages/workflow-editor/src/taches/human-decision.vue +102 -0
  104. package/packages/workflow-editor/src/taches/human-task.vue +113 -0
  105. package/packages/workflow-editor/src/taches/join.vue +91 -0
  106. package/packages/workflow-editor/src/taches/joint.vue +177 -0
  107. package/packages/workflow-editor/src/taches/start.vue +76 -0
  108. package/packages/workflow-editor/src/taches/subprocess.vue +99 -0
  109. package/packages/workflow-editor/src/taches/tache-resizer.vue +80 -0
  110. package/packages/workflow-editor/src/transitions/broken-line.vue +91 -0
  111. package/packages/workflow-editor/src/transitions/curve-line.vue +91 -0
  112. package/packages/workflow-editor/src/transitions/straight-line.vue +26 -0
  113. package/packages/workflow-editor/src/transitions/transition.vue +212 -0
  114. package/packages/workflow-editor/src/transitions/virtual-transition.vue +43 -0
  115. package/packages/workflow-editor/src/util.js +489 -0
  116. package/packages/workflow-editor/src/workflow-editor.vue +607 -0
  117. package/packages/workflow-editor/src/workflow-history.vue +153 -0
  118. package/src/i18n/i18n.js +1 -1
  119. package/src/i18n/langs/cn.js +43 -24
  120. package/src/i18n/langs/en.js +23 -7
@@ -0,0 +1,489 @@
1
+
2
+ import { getLanguageWithLocale } from 'imatrix-ui/src/utils/util'
3
+ import i18n from '../../../src/i18n/i18n'
4
+ import newAutoTask from './json-object-templates/auto-task'
5
+ import newCopyTask from './json-object-templates/copy-task'
6
+ import newDecision from './json-object-templates/decision'
7
+ import newEnd from './json-object-templates/end'
8
+ import newFork from './json-object-templates/fork'
9
+ import newHumanDecision from './json-object-templates/human-decision'
10
+ import newHumanTask from './json-object-templates/human-task'
11
+ import newJoin from './json-object-templates/join'
12
+ import newProcess from './json-object-templates/process'
13
+ import newStart from './json-object-templates/start'
14
+ import newSubprocess from './json-object-templates/subprocess'
15
+ import newTransition from './json-object-templates/transition'
16
+ function getStore() {
17
+ return window.$store
18
+ }
19
+ function getI18n() {
20
+ if (!window.$locale) {
21
+ i18n.locale = 'cn'
22
+ } else {
23
+ i18n.locale = window.$locale
24
+ }
25
+ return i18n
26
+ }
27
+ // 组件的初始信息
28
+ export function getComponentList() {
29
+ return [
30
+ {
31
+ name: 'Start',
32
+ label: getI18n().t('workflowEditor.task.start'),
33
+ icon: 'start',
34
+ type: 'success',
35
+ round: true,
36
+ width: 48,
37
+ height: 48,
38
+ color: '#67C23A'
39
+ }, {
40
+ name: 'HumanTask',
41
+ label: getI18n().t('workflowEditor.task.humanTask'),
42
+ icon: 'human-task',
43
+ type: '',
44
+ round: false,
45
+ width: 80,
46
+ height: 40,
47
+ color: '#000'
48
+ }, {
49
+ name: 'Decision',
50
+ label: getI18n().t('workflowEditor.task.conditionJudgment'),
51
+ icon: 'decision',
52
+ type: '',
53
+ round: false,
54
+ width: 48,
55
+ height: 48,
56
+ color: '#999'
57
+ },
58
+ {
59
+ name: 'Fork',
60
+ label: getI18n().t('workflowEditor.task.branch'),
61
+ icon: 'fork',
62
+ type: '',
63
+ round: false,
64
+ width: 48,
65
+ height: 48,
66
+ color: '#999'
67
+ },
68
+ {
69
+ name: 'Join',
70
+ label: getI18n().t('workflowEditor.task.converge'),
71
+ icon: 'join',
72
+ type: '',
73
+ round: false,
74
+ width: 48,
75
+ height: 48,
76
+ color: '#999'
77
+ },
78
+ {
79
+ name: 'Subprocess',
80
+ label: getI18n().t('workflowEditor.task.subprocess'),
81
+ icon: 'subprocess',
82
+ type: 'warning',
83
+ round: false,
84
+ width: 80,
85
+ height: 40,
86
+ color: '#0777D4'
87
+ },
88
+ {
89
+ name: 'HumanDecision',
90
+ label: getI18n().t('workflowEditor.task.manualJudgment'),
91
+ icon: 'human-decision',
92
+ type: '',
93
+ round: false,
94
+ width: 48,
95
+ height: 48,
96
+ color: '#999'
97
+ },
98
+ {
99
+ name: 'CopyTask',
100
+ label: getI18n().t('workflowEditor.task.cCtask'),
101
+ icon: 'copy-task',
102
+ type: '',
103
+ round: false,
104
+ width: 80,
105
+ height: 40,
106
+ color: '#0777D4'
107
+ },
108
+ {
109
+ name: 'AutoTask',
110
+ label: getI18n().t('workflowEditor.task.autoTask'),
111
+ icon: 'human-task',
112
+ type: '',
113
+ round: false,
114
+ width: 80,
115
+ height: 40,
116
+ color: '#0777D4'
117
+ },
118
+ {
119
+ name: 'End',
120
+ label: getI18n().t('workflowEditor.task.end'),
121
+ icon: 'end',
122
+ type: 'danger',
123
+ round: true,
124
+ width: 48,
125
+ height: 48,
126
+ color: '#F56C6C'
127
+ }
128
+ ]
129
+ }
130
+ function getComponentInfo(name) {
131
+ const component = getComponentList().filter(item => {
132
+ return item.name === name
133
+ })
134
+ if (component.length > 0) {
135
+ return component[0]
136
+ } else {
137
+ return null
138
+ }
139
+ }
140
+ // 根据环节id找到环节对象
141
+ function getParent(parent) {
142
+ const taches = getStore().getters['wfEditor/taches']
143
+ const tache = taches.filter(tache => {
144
+ return tache.id === parent
145
+ })
146
+ return tache[0]
147
+ }
148
+ function getJoint(parent, position) {
149
+ // 如果parent只是一个名称的时候需要先找到环节对象
150
+ if (typeof (parent) === 'string') {
151
+ parent = getParent(parent)
152
+ }
153
+ switch (position) {
154
+ case 'up':
155
+ case 'top':
156
+ return { position: 'up', x: parent.x + parent.width / 2, y: parent.y }
157
+ case 'right':
158
+ return { position: 'right', x: parent.x + parent.width, y: parent.y + parent.height / 2 }
159
+ case 'down':
160
+ case 'bottom':
161
+ return { position: 'down', x: parent.x + parent.width / 2, y: parent.y + parent.height }
162
+ case 'left':
163
+ return { position: 'left', x: parent.x, y: parent.y + parent.height / 2 }
164
+ default:
165
+ return { position: '', x: parent.x, y: parent.y }
166
+ }
167
+ }
168
+ // 根据鼠标的位置clientX,clientY算出对应的SVG中的坐标
169
+ function getMousePosition(evt) {
170
+ const CTM = document.getElementById('svg').getScreenCTM()
171
+ return {
172
+ x: (evt.clientX - CTM.e) / CTM.a,
173
+ y: (evt.clientY - CTM.f) / CTM.d
174
+ }
175
+ }
176
+ // 根据svg中鼠标按下的位置算出对应在html中的鼠标位置
177
+ function getClientMousePosition() {
178
+ const CTM = document.getElementById('svg').getScreenCTM()
179
+ const mouseDownPosition = getStore().getters['wfEditor/mouseDownPosition']
180
+ return {
181
+ x: mouseDownPosition.x * CTM.a + CTM.e,
182
+ y: mouseDownPosition.y * CTM.d + CTM.f
183
+ }
184
+ }
185
+ function getMouseOffset(event, tache) {
186
+ if (event.target.classList.contains('draggable')) {
187
+ const offset = getMousePosition(event)
188
+ offset.x -= tache.x
189
+ offset.y -= tache.y
190
+ return offset
191
+ }
192
+ }
193
+ function getVirtualRegion(startPoint, endPoint) {
194
+ if (!startPoint || !endPoint) {
195
+ return {}
196
+ }
197
+ const { x: x1, y: y1 } = startPoint
198
+ const { x: x2, y: y2 } = endPoint
199
+ var area = {
200
+ x: 0,
201
+ y: 0,
202
+ width: Math.abs(x2 - x1),
203
+ height: Math.abs(y2 - y1)
204
+ }
205
+ if (x1 <= x2) {
206
+ if (y1 <= y2) { // p2在p1的右下方
207
+ area.x = x1
208
+ area.y = y1
209
+ } else { // p2在p1的右上方
210
+ area.x = x1
211
+ area.y = y2
212
+ }
213
+ } else {
214
+ if (y1 >= y2) { // p2在p1的左上方
215
+ area.x = x2
216
+ area.y = y2
217
+ } else {
218
+ area.x = x2
219
+ area.y = y1
220
+ }
221
+ }
222
+ return area
223
+ }
224
+ // 根据选中的环节裁剪选择区域
225
+ function getRealRegion(taches) {
226
+ let minX, minY
227
+ minX = minY = 10000
228
+ let maxX, maxY
229
+ maxX = maxY = 0
230
+ for (const tache of taches) {
231
+ if (minX > tache.x) {
232
+ minX = tache.x
233
+ }
234
+ if (minY > tache.y) {
235
+ minY = tache.y
236
+ }
237
+ if (maxX < (tache.x + tache.width)) {
238
+ maxX = tache.x + tache.width
239
+ }
240
+ if (maxY < (tache.y + tache.height)) {
241
+ maxY = tache.y + tache.height
242
+ }
243
+ }
244
+ return {
245
+ x: minX - 10,
246
+ y: minY - 10,
247
+ width: maxX - minX + 20,
248
+ height: maxY - minY + 20
249
+ }
250
+ }
251
+ function startDragTache(event, vm) {
252
+ // 清除选中的环节或者流向
253
+ clearAllSelectedComponents()
254
+ // 清除选择区域
255
+ vm.$parent.region = null
256
+ // 不是显示流转历史的时候,需要选中当前环节
257
+ if (!vm.$parent.showHistory) {
258
+ vm.model.isSelected = true
259
+ }
260
+
261
+ getStore().getters['wfEditor/selectedTaches'].push(vm.model)
262
+
263
+ const mouseDownPosition = getMousePosition(event)
264
+ getStore().commit('wfEditor/setMouseDownPosition', mouseDownPosition)
265
+ getStore().commit('wfEditor/setMovingTache', true)
266
+ }
267
+ function endDragTache() {
268
+ getStore().commit('wfEditor/setMovingTache', false)
269
+ getStore().commit('wfEditor/setMouseDownPosition', null)
270
+ }
271
+ function unselectTaches() {
272
+ for (const tache of getStore().getters['wfEditor/selectedTaches']) {
273
+ tache.isSelected = false
274
+ }
275
+ getStore().commit('wfEditor/setSelectedTaches', [])
276
+ }
277
+ /**
278
+ * 包括选中的环节(可能有多个)和流向(0个或1个)
279
+ */
280
+ function clearAllSelectedComponents() {
281
+ unselectTaches()
282
+ if (getStore().getters['wfEditor/selectedTransition']) {
283
+ getStore().getters['wfEditor/selectedTransition'].isSelected = false
284
+ }
285
+ getStore().commit('wfEditor/setSelectedTransition', null)
286
+ }
287
+
288
+ /**
289
+ * 通过xml-js库生成的js对象包含_text属性,需要把这个属性去掉,把值复制给父属性
290
+ * 如x:{_text:50}需要变成x:50
291
+ * @param {包含_text属性的对象} obj
292
+ */
293
+ function removeTextProperty(obj) {
294
+ const keys = Object.getOwnPropertyNames(obj)
295
+ keys.forEach(function (key) {
296
+ if (typeof obj[key] === 'object') {
297
+ if (obj[key]._text !== undefined) {
298
+ obj[key] = obj[key]._text
299
+ return
300
+ } else {
301
+ if (Object.keys(obj[key]).length > 0) {
302
+ removeTextProperty(obj[key])
303
+ } else {
304
+ // 如果是空对象就转换为字符串,js-xml库会把每个xml节点都转换为对象,对底层的空节点应该是字符串,其他类型应该给默认值,true,0等
305
+ // variables和events节点不是最底层节点,有时候也会为空,不能处理他们
306
+ const specialNodes = ['variables', 'events', 'autoFilledFields']
307
+ if (specialNodes.indexOf(key) < 0) {
308
+ obj[key] = ''
309
+ }
310
+ }
311
+ }
312
+ }
313
+ })
314
+ }
315
+ function generateTaches(type, arr) {
316
+ if (!arr) arr = []
317
+ if (!Array.isArray(arr)) {
318
+ arr = [arr]
319
+ }
320
+ const taches = getStore().getters['wfEditor/taches']
321
+ for (const task of arr) {
322
+ const tache = {
323
+ id: task.attr.id,
324
+ name: task.attr.name,
325
+ // +号是把文本转换成数字的快捷方式
326
+ x: task.g.x,
327
+ y: task.g.y,
328
+ width: task.g.width,
329
+ height: task.g.height,
330
+ type: type,
331
+ isSelected: false,
332
+ ref: task
333
+ }
334
+ taches.push(tache)
335
+ }
336
+ }
337
+ function generateTransitions(type, arr) {
338
+ if (!arr) arr = []
339
+ if (!Array.isArray(arr)) {
340
+ arr = [arr]
341
+ }
342
+ const transitions = getStore().getters['wfEditor/transitions']
343
+ for (const transition of arr) {
344
+ const remark = transition.basicProperties.remark || ''
345
+ const model = {
346
+ id: transition.attr.id,
347
+ startJoint: { parent: findTacheById(transition.attr.from), position: transition.g.fromJoint },
348
+ endJoint: { parent: findTacheById(transition.attr.to), position: transition.g.toJoint },
349
+ isSelected: false,
350
+ remark: remark,
351
+ lineInfo: {
352
+ type: transition.g.lineType,
353
+ controlPoint: null
354
+ },
355
+ ref: transition
356
+ }
357
+ // 曲线的话会有控制点,如果以后要存多个控制点,就以'x1,y1 x2,y2 x3,y3'的形式来保存,目前只有一个控制点
358
+ if (transition.g.lineType === 'CurveLine' && transition.g.coordinate) {
359
+ const point = transition.g.coordinate.split(',')
360
+ model.lineInfo.controlPoint = {
361
+ x: point[0],
362
+ y: point[1]
363
+ }
364
+ } else if (transition.g.lineType === 'BrokenLine' && transition.g.coordinate) {
365
+ const points = transition.g.coordinate.split(';')
366
+ const controlPoints = []
367
+ points.forEach(pointXY => {
368
+ if (pointXY !== '') {
369
+ const point = pointXY.split(',')
370
+ controlPoints.push({ x: point[0], y: point[1] })
371
+ }
372
+ })
373
+ model.lineInfo.controlPoint = controlPoints
374
+ }
375
+ transitions.push(model)
376
+ }
377
+ }
378
+ function initializeProcessData(process) {
379
+ if (!process) return
380
+ generateTaches('HumanTask', process.humanTask)
381
+ generateTaches('Decision', process.decision)
382
+ generateTaches('Fork', process.fork)
383
+ generateTaches('Join', process.join)
384
+ generateTaches('Subprocess', process.subprocess)
385
+ generateTaches('HumanDecision', process.humanDecision)
386
+ generateTaches('CopyTask', process.copyTask)
387
+ generateTaches('AutoTask', process.autoTask)
388
+ generateTaches('Start', process.start)
389
+ generateTaches('End', process.end)
390
+ generateTransitions('Transition', process.transition)
391
+ }
392
+ function findOutgoingTransitionsByTacheId(tacheId) {
393
+ const transitions = getStore().getters['wfEditor/transitions']
394
+ const result = transitions.filter(transition => {
395
+ return transition.startJoint.parent.id === tacheId || transition.ref.attr.from === tacheId
396
+ })
397
+ return result
398
+ }
399
+
400
+ function findIncomingTransitionsByTacheId(tacheId) {
401
+ const transitions = getStore().getters['wfEditor/transitions']
402
+ const result = transitions.filter(transition => {
403
+ return transition.endJoint.parent.id === tacheId || transition.ref.attr.to === tacheId
404
+ })
405
+ return result
406
+ }
407
+
408
+ function findTacheById(tacheId) {
409
+ const taches = getStore().getters['wfEditor/taches']
410
+ const tache = taches.filter(tache => {
411
+ return tache.ref.attr.id === tacheId
412
+ })
413
+ if (tache.length > 0) {
414
+ return tache[0]
415
+ } else {
416
+ return null
417
+ }
418
+ }
419
+ function deepCopy(source) {
420
+ return JSON.parse(JSON.stringify(source))
421
+ }
422
+
423
+ function updateTransitionsWhenTacheIdChanged(newId, oldId) {
424
+ const incomingTransitions = findIncomingTransitionsByTacheId(oldId)
425
+ incomingTransitions.map(item => {
426
+ item.ref.attr.to = newId
427
+ item.ref.attr.id = 'flow_' + item.ref.attr.from + '_to_' + item.ref.attr.to
428
+ item.id = item.ref.attr.id
429
+ })
430
+ const outgoingTransitions = findOutgoingTransitionsByTacheId(oldId)
431
+ outgoingTransitions.map(item => {
432
+ item.ref.attr.from = newId
433
+ item.ref.attr.id = 'flow_' + item.ref.attr.from + '_to_' + item.ref.attr.to
434
+ item.id = item.ref.attr.id
435
+ })
436
+ return true
437
+ }
438
+ function validateTacheCode(vm) {
439
+ const tache = findTacheById(vm.formModel.id)
440
+ if (tache && tache.id !== vm.id) {
441
+ vm.$alert(getI18n().t('workflowEditorMessage.itIsTheSameAsTheExistingLink', { name: tache.name }))
442
+ // 编码重复,立即还原id
443
+ vm.formModel.id = vm.id
444
+ return
445
+ }
446
+ // 环节编码不重复的时候,就需要更新流入流向的to和流出流向的from属性了,同时把编码值回传给父组件
447
+ updateTransitionsWhenTacheIdChanged(vm.formModel.id, vm.id)
448
+ // 支持.snyc修饰符的写法
449
+ vm.$emit('update:id', vm.formModel.id)
450
+ }
451
+
452
+ function watchShowName(vm, newVal) {
453
+ let showName = ''
454
+ if (vm.processI18n && vm.model.ref && vm.model.ref.basicProperties && vm.model.ref.basicProperties.i18nKey) {
455
+ const i18nKey = vm.model.ref.basicProperties.i18nKey
456
+ const language = getLanguageWithLocale()
457
+ if (vm.processI18n[i18nKey]) {
458
+ showName = vm.processI18n[i18nKey][language]
459
+ }
460
+ if (!showName) {
461
+ showName = newVal
462
+ }
463
+ } else {
464
+ showName = newVal
465
+ }
466
+ return showName
467
+ }
468
+ export {
469
+ clearAllSelectedComponents, deepCopy, endDragTache, findIncomingTransitionsByTacheId, findOutgoingTransitionsByTacheId, findTacheById, getClientMousePosition, getComponentInfo, getI18n, getJoint, getMouseOffset, getMousePosition, getRealRegion, getVirtualRegion, initializeProcessData, removeTextProperty, startDragTache, updateTransitionsWhenTacheIdChanged,
470
+ validateTacheCode, watchShowName
471
+ }
472
+
473
+ const processTemplate = {
474
+ newProcess,
475
+ newHumanTask,
476
+ newDecision,
477
+ newStart,
478
+ newEnd,
479
+ newTransition,
480
+ newSubprocess,
481
+ newFork,
482
+ newJoin,
483
+ newHumanDecision,
484
+ newCopyTask,
485
+ newAutoTask
486
+ }
487
+
488
+ export { processTemplate }
489
+