workflow-editor 0.9.67-dw → 0.9.67

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 (114) 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 +528 -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/copy-task.js +67 -0
  12. package/packages/workflow-editor/src/json-object-templates/decision.js +11 -0
  13. package/packages/workflow-editor/src/json-object-templates/end.js +14 -0
  14. package/packages/workflow-editor/src/json-object-templates/fork.js +10 -0
  15. package/packages/workflow-editor/src/json-object-templates/human-decision.js +9 -0
  16. package/packages/workflow-editor/src/json-object-templates/human-task.js +199 -0
  17. package/packages/workflow-editor/src/json-object-templates/join.js +10 -0
  18. package/packages/workflow-editor/src/json-object-templates/process.js +98 -0
  19. package/packages/workflow-editor/src/json-object-templates/start.js +13 -0
  20. package/packages/workflow-editor/src/json-object-templates/subprocess.js +30 -0
  21. package/packages/workflow-editor/src/json-object-templates/transition.js +26 -0
  22. package/packages/workflow-editor/src/main/admin-save-dialog.vue +66 -0
  23. package/packages/workflow-editor/src/main/canvas.vue +479 -0
  24. package/packages/workflow-editor/src/main/context-menu.vue +132 -0
  25. package/packages/workflow-editor/src/main/icon-svg.vue +32 -0
  26. package/packages/workflow-editor/src/main/selection-region.vue +66 -0
  27. package/packages/workflow-editor/src/main/tache-history-tooltip.vue +38 -0
  28. package/packages/workflow-editor/src/main/tache-name-input.vue +19 -0
  29. package/packages/workflow-editor/src/main/tache-subprocess-history-dialog.vue +35 -0
  30. package/packages/workflow-editor/src/main/toolbox.vue +60 -0
  31. package/packages/workflow-editor/src/main/wf-history-canvas.vue +302 -0
  32. package/packages/workflow-editor/src/process-json.js +622 -0
  33. package/packages/workflow-editor/src/process-service.js +31 -0
  34. package/packages/workflow-editor/src/properties-editors/common/additional-condition-utils.js +531 -0
  35. package/packages/workflow-editor/src/properties-editors/common/additional-condition.vue +276 -0
  36. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields-utils.js +34 -0
  37. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields.vue +239 -0
  38. package/packages/workflow-editor/src/properties-editors/common/common-notice-tool.vue +47 -0
  39. package/packages/workflow-editor/src/properties-editors/common/common-user-condition.vue +241 -0
  40. package/packages/workflow-editor/src/properties-editors/common/form-fields-utils.js +23 -0
  41. package/packages/workflow-editor/src/properties-editors/common/form-fields.vue +116 -0
  42. package/packages/workflow-editor/src/properties-editors/common/i18n-input.vue +75 -0
  43. package/packages/workflow-editor/src/properties-editors/common/i18n-set-dialog.vue +125 -0
  44. package/packages/workflow-editor/src/properties-editors/common/notice.vue +98 -0
  45. package/packages/workflow-editor/src/properties-editors/common/reminder.vue +179 -0
  46. package/packages/workflow-editor/src/properties-editors/common/select-mail-template.vue +83 -0
  47. package/packages/workflow-editor/src/properties-editors/common/standard-fields.vue +65 -0
  48. package/packages/workflow-editor/src/properties-editors/common/system-role-tree-inline.vue +355 -0
  49. package/packages/workflow-editor/src/properties-editors/common/system-role-tree.vue +63 -0
  50. package/packages/workflow-editor/src/properties-editors/common/task-title.vue +148 -0
  51. package/packages/workflow-editor/src/properties-editors/common/transactor-settings.vue +233 -0
  52. package/packages/workflow-editor/src/properties-editors/common/user-selection.vue +386 -0
  53. package/packages/workflow-editor/src/properties-editors/common/value-selection-dialog.vue +209 -0
  54. package/packages/workflow-editor/src/properties-editors/common/variables.vue +135 -0
  55. package/packages/workflow-editor/src/properties-editors/copy-task/basic-properties.vue +90 -0
  56. package/packages/workflow-editor/src/properties-editors/copy-task/permission-settings.vue +155 -0
  57. package/packages/workflow-editor/src/properties-editors/copy-task.vue +80 -0
  58. package/packages/workflow-editor/src/properties-editors/decision.vue +90 -0
  59. package/packages/workflow-editor/src/properties-editors/fork.vue +72 -0
  60. package/packages/workflow-editor/src/properties-editors/human-decision.vue +44 -0
  61. package/packages/workflow-editor/src/properties-editors/human-task/additional-condition-dialog.vue +60 -0
  62. package/packages/workflow-editor/src/properties-editors/human-task/basic-properties.vue +156 -0
  63. package/packages/workflow-editor/src/properties-editors/human-task/componentsConfigUtil.js +291 -0
  64. package/packages/workflow-editor/src/properties-editors/human-task/custom-actions.vue +249 -0
  65. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-field-setting.vue +392 -0
  66. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-fields.vue +241 -0
  67. package/packages/workflow-editor/src/properties-editors/human-task/editable-field-selection.vue +220 -0
  68. package/packages/workflow-editor/src/properties-editors/human-task/editable-fields.vue +204 -0
  69. package/packages/workflow-editor/src/properties-editors/human-task/events.vue +59 -0
  70. package/packages/workflow-editor/src/properties-editors/human-task/permission-settings.vue +207 -0
  71. package/packages/workflow-editor/src/properties-editors/human-task/selection-conditions.vue +390 -0
  72. package/packages/workflow-editor/src/properties-editors/human-task.vue +103 -0
  73. package/packages/workflow-editor/src/properties-editors/join.vue +44 -0
  74. package/packages/workflow-editor/src/properties-editors/process/basic-properties.vue +273 -0
  75. package/packages/workflow-editor/src/properties-editors/process/events.vue +76 -0
  76. package/packages/workflow-editor/src/properties-editors/process/notice-settings.vue +60 -0
  77. package/packages/workflow-editor/src/properties-editors/process/parameter-settings.vue +95 -0
  78. package/packages/workflow-editor/src/properties-editors/process/permission-settings.vue +28 -0
  79. package/packages/workflow-editor/src/properties-editors/process/selectPage.vue +81 -0
  80. package/packages/workflow-editor/src/properties-editors/process.vue +109 -0
  81. package/packages/workflow-editor/src/properties-editors/subprocess/basic-properties.vue +187 -0
  82. package/packages/workflow-editor/src/properties-editors/subprocess/events.vue +26 -0
  83. package/packages/workflow-editor/src/properties-editors/subprocess/field-mappings.vue +206 -0
  84. package/packages/workflow-editor/src/properties-editors/subprocess/transactor-settings.vue +64 -0
  85. package/packages/workflow-editor/src/properties-editors/subprocess.vue +79 -0
  86. package/packages/workflow-editor/src/properties-editors/transition/basic-properties.vue +53 -0
  87. package/packages/workflow-editor/src/properties-editors/transition.vue +74 -0
  88. package/packages/workflow-editor/src/properties-editors/user-condition.js +177 -0
  89. package/packages/workflow-editor/src/store/getters.js +27 -0
  90. package/packages/workflow-editor/src/store/workflow-editor.js +125 -0
  91. package/packages/workflow-editor/src/taches/common-methods.js +21 -0
  92. package/packages/workflow-editor/src/taches/copy-task.vue +99 -0
  93. package/packages/workflow-editor/src/taches/custom-task.vue +88 -0
  94. package/packages/workflow-editor/src/taches/decision.vue +102 -0
  95. package/packages/workflow-editor/src/taches/end.vue +76 -0
  96. package/packages/workflow-editor/src/taches/fork.vue +102 -0
  97. package/packages/workflow-editor/src/taches/human-decision.vue +102 -0
  98. package/packages/workflow-editor/src/taches/human-task.vue +113 -0
  99. package/packages/workflow-editor/src/taches/join.vue +91 -0
  100. package/packages/workflow-editor/src/taches/joint.vue +177 -0
  101. package/packages/workflow-editor/src/taches/start.vue +76 -0
  102. package/packages/workflow-editor/src/taches/subprocess.vue +99 -0
  103. package/packages/workflow-editor/src/taches/tache-resizer.vue +80 -0
  104. package/packages/workflow-editor/src/transitions/broken-line.vue +91 -0
  105. package/packages/workflow-editor/src/transitions/curve-line.vue +91 -0
  106. package/packages/workflow-editor/src/transitions/straight-line.vue +26 -0
  107. package/packages/workflow-editor/src/transitions/transition.vue +212 -0
  108. package/packages/workflow-editor/src/transitions/virtual-transition.vue +43 -0
  109. package/packages/workflow-editor/src/util.js +493 -0
  110. package/packages/workflow-editor/src/workflow-editor.vue +605 -0
  111. package/packages/workflow-editor/src/workflow-history.vue +153 -0
  112. package/src/i18n/i18n.js +1 -1
  113. package/src/i18n/langs/cn.js +6 -1
  114. package/src/i18n/langs/en.js +6 -1
@@ -0,0 +1,479 @@
1
+ <template>
2
+ <div ref="svgContainer" style="position:relative">
3
+ <svg
4
+ id="svg"
5
+ width="2000"
6
+ height="2000"
7
+ @mousedown="mousedown"
8
+ @mousemove="mousemove"
9
+ @mouseup="mouseup"
10
+ @mouseleave="mouseleave"
11
+ @dblclick="setPropertiesEditorFor('Process')"
12
+ >
13
+ <defs>
14
+ <marker id="arrow" markerWidth="10" markerHeight="10" refX="6" refY="2" orient="auto" markerUnits="strokeWidth">
15
+ <path d="M0,0 L0,4 L6,2 z" fill="#666" />
16
+ </marker>
17
+ </defs>
18
+ <component
19
+ :is="tache.type"
20
+ v-for="tache in taches"
21
+ :key="tache.id"
22
+ :model="tache"
23
+ @mouseenter.native="showTacheHistoryTooltip"
24
+ @mouseleave.native="hideTacheHistoryTooltip"
25
+ @mousemove.native="updateTacheHistoryTooltipPosition"
26
+ />
27
+ <transition
28
+ v-for="transition in transitions"
29
+ :key="transition.id"
30
+ :model="transition"
31
+ />
32
+ <virtual-transition :toPosition="currentPosition" />
33
+ <selection-region :region="region" />
34
+ </svg>
35
+ <component
36
+ :is="propertiesEditorFor+'PropertiesEditor'"
37
+ v-if="!showHistory&&propertiesEditorFor"
38
+ :model="selectedTaches[0]||selectedTransition||process"
39
+ @close="setPropertiesEditorFor('')"
40
+ />
41
+ <tache-history-tooltip v-if="showHistory&&showTacheHistory" :style="tooltipPosition" />
42
+ </div>
43
+ </template>
44
+
45
+ <script>
46
+ import Start from '../taches/start'
47
+ import End from '../taches/end'
48
+ import HumanTask from '../taches/human-task'
49
+ import Decision from '../taches/decision'
50
+ import Subprocess from '../taches/subprocess'
51
+ import CustomTask from '../taches/custom-task'
52
+ import Fork from '../taches/fork'
53
+ import Join from '../taches/join'
54
+ import HumanDecision from '../taches/human-decision'
55
+ import CopyTask from '../taches/copy-task'
56
+ import Transition from '../transitions/transition'
57
+ import VirtualTransition from '../transitions/virtual-transition'
58
+ import SelectionRegion from './selection-region'
59
+ import HumanTaskPropertiesEditor from '../properties-editors/human-task'
60
+ import ProcessPropertiesEditor from '../properties-editors/process'
61
+ import DecisionPropertiesEditor from '../properties-editors/decision'
62
+ import TransitionPropertiesEditor from '../properties-editors/transition'
63
+ import ForkPropertiesEditor from '../properties-editors/fork'
64
+ import JoinPropertiesEditor from '../properties-editors/join'
65
+ import HumanDecisionPropertiesEditor from '../properties-editors/human-decision'
66
+ import CopyTaskPropertiesEditor from '../properties-editors/copy-task'
67
+ import SubprocessPropertiesEditor from '../properties-editors/subprocess'
68
+ import TacheHistoryTooltip from './tache-history-tooltip'
69
+ import { mapGetters, mapMutations } from 'vuex'
70
+ import { getMousePosition, getVirtualRegion, getRealRegion, clearAllSelectedComponents } from '../util'
71
+
72
+ export default {
73
+ name: 'Canvas',
74
+ components: {
75
+ Start,
76
+ End,
77
+ HumanTask,
78
+ Decision,
79
+ Subprocess,
80
+ CustomTask,
81
+ Fork,
82
+ Join,
83
+ HumanDecision,
84
+ CopyTask,
85
+ Transition,
86
+ VirtualTransition,
87
+ SelectionRegion,
88
+ HumanTaskPropertiesEditor,
89
+ ProcessPropertiesEditor,
90
+ DecisionPropertiesEditor,
91
+ TransitionPropertiesEditor,
92
+ ForkPropertiesEditor,
93
+ JoinPropertiesEditor,
94
+ HumanDecisionPropertiesEditor,
95
+ CopyTaskPropertiesEditor,
96
+ SubprocessPropertiesEditor,
97
+ TacheHistoryTooltip
98
+ },
99
+ props: {
100
+ process: {
101
+ type: Object,
102
+ default: null
103
+ },
104
+ showHistory: {
105
+ type: Boolean,
106
+ default: false
107
+ }
108
+ },
109
+ data: function() {
110
+ return {
111
+ inputArea: null,
112
+ currentPosition: null,
113
+ originPosition: null,
114
+ offset: null,
115
+ startPoint: null,
116
+ region: null,
117
+ endPoint: null,
118
+ transitionsInRegion: [],
119
+ showTacheHistory: false,
120
+ tooltipPosition: null
121
+ }
122
+ },
123
+ computed: {
124
+ ...mapGetters('wfEditor', [
125
+ 'taches',
126
+ 'transitions',
127
+ 'isMovingTache',
128
+ 'mouseDownPosition',
129
+ 'startJoint',
130
+ 'endJoint',
131
+ 'isDrawingRegion',
132
+ 'isMovingRegion',
133
+ 'selectedTransition',
134
+ 'selectedTaches',
135
+ 'resizerToMove',
136
+ 'draggerToMove',
137
+ 'controlPointToMove',
138
+ 'propertiesEditorFor',
139
+ 'contextMenuVisible'
140
+ ])
141
+ },
142
+ mounted: function() {
143
+
144
+ },
145
+ methods: {
146
+ ...mapMutations('wfEditor', [
147
+ 'setTaches',
148
+ 'setTransitions',
149
+ 'resetState',
150
+ 'setMovingTache',
151
+ 'stopDrawingLine',
152
+ 'setSelectedTaches',
153
+ 'setDrawingRegion',
154
+ 'setResizerToMove',
155
+ 'setDraggerToMove',
156
+ 'setControlPointToMove',
157
+ 'setPropertiesEditorFor'
158
+ ]),
159
+ forbidSelection() {
160
+ return false
161
+ },
162
+ add: function() {
163
+ // const tache = new TacheUI(this.snap, 50, 50)
164
+ // tache.draw()
165
+ },
166
+ // 各个组件上的mousedown,组件会自行处理,不会传播到canvas上来,这里发生的mousedown表示点击了canvas的空白区域
167
+ mousedown(event) {
168
+ console.log('mousedown')
169
+ // 鼠标按下时先清除上次选中的环节
170
+ this.unselectAll()
171
+
172
+ // 准备画新的选择区域
173
+ // isDrawingRegion标识是否可以开始画选择区域了,当mouseup时会重置
174
+ this.setDrawingRegion(true)
175
+ // startPoint和endPoint记录选择区域的起点和终点,当mouseup的时候如果有选中的tache则保留值,没有选中则清空值
176
+ this.startPoint = getMousePosition(event)
177
+ },
178
+ mousemove(event) {
179
+ // console.log('mousemove')
180
+ // 显示流转历史的时候不需要拖动环节
181
+ if (this.showHistory) return
182
+ // 给起始位置附上初始值,这个起始位置是个相对概念,每次mousemove后,这个值就变成最新的鼠标位置,作为下一次mousemove的起点
183
+ if (!this.originPosition && this.mouseDownPosition) {
184
+ this.originPosition = this.mouseDownPosition
185
+ }
186
+ this.currentPosition = getMousePosition(event)
187
+ if (this.isMovingTache) {
188
+ this.moveTache(this.selectedTaches[0])
189
+ }
190
+ this.drawVirtualSelectionRegion()
191
+
192
+ this.moveSelectionRegion()
193
+
194
+ this.resizeSelectedTache()
195
+
196
+ this.moveTransition()
197
+
198
+ this.adjustCurveLine()
199
+
200
+ this.originPosition = this.currentPosition
201
+ },
202
+ // 有些组件上的mouseup,会传播到canvas上来
203
+ mouseup(event) {
204
+ console.log('mouseup')
205
+ if (this.isMovingTache) {
206
+ this.setMovingTache(false)
207
+ }
208
+ // 在画布的空白地方mouseup时,停止画虚拟的流向,此时没有找到任何endJoint(在joint上mouseup才会设置endJoint)
209
+ if (this.startJoint) {
210
+ this.stopDrawingLine()
211
+ }
212
+ // 鼠标起来时,需要判断是否选中了tache,并显示选择区域
213
+ this.drawRegionWhenNeeded()
214
+
215
+ // tache变到最小时,继续移动鼠标会从resizer上移出去,如果此时松开鼠标就不会触发resizer的mouseup
216
+ if (this.resizerToMove) {
217
+ this.setResizerToMove(null)
218
+ }
219
+
220
+ this.resetMovedTransition()
221
+ },
222
+ mouseleave(event) {
223
+ this.drawRegionWhenNeeded()
224
+
225
+ this.resetMovedTransition()
226
+
227
+ this.resetState()
228
+ },
229
+ drawRegionWhenNeeded() {
230
+ if (this.isDrawingRegion) {
231
+ this.selectComponents()
232
+ this.drawRealSelectionRegion()
233
+ this.setDrawingRegion(false)
234
+ }
235
+ },
236
+ resetMovedTransition() {
237
+ // 如果正在移动transition,那么要清除掉状态,并还原transition的位置
238
+ if (this.draggerToMove) {
239
+ this.draggerToMove.owner.startJoint = this.draggerToMove.originStartJoint
240
+ this.draggerToMove.owner.endJoint = this.draggerToMove.originEndJoint
241
+ this.setDraggerToMove(null)
242
+ }
243
+ },
244
+ unselectAll() {
245
+ clearAllSelectedComponents()
246
+ // 选中的线也清除掉,此时线的状态并不是selected,这个只是为了移动控制点而增加的组件变量
247
+ this.transitionsInRegion = []
248
+ this.startPoint = null
249
+ this.region = null
250
+ },
251
+ selectComponents() {
252
+ // 如果选择区域缺少起点或终点,那么不需要选中任何东西,同时清除已有起点或者终点信息
253
+ if (!this.startPoint || !this.region) {
254
+ this.startPoint = null
255
+ this.region = null
256
+ return
257
+ }
258
+ // 判断环节是否在选择区域里面,如果在就选中
259
+ for (const tache of this.taches) {
260
+ if (this.isInsideSelectionRegion(tache)) {
261
+ tache.isSelected = true
262
+ this.selectedTaches.push(tache)
263
+ }
264
+ }
265
+
266
+ for (const transition of this.transitions) {
267
+ if (transition.startJoint.parent.isSelected && transition.endJoint.parent.isSelected) {
268
+ this.transitionsInRegion.push(transition)
269
+ }
270
+ }
271
+ },
272
+ isInsideSelectionRegion(tache) {
273
+ const isLeftTopCornerInside = (tache.x >= this.region.x && tache.y >= this.region.y)
274
+ const isRightDownCornerInside = ((tache.x + tache.width) <= (this.region.x + this.region.width) && (tache.y + tache.height) <= (this.region.y + this.region.height))
275
+ return isLeftTopCornerInside && isRightDownCornerInside
276
+ },
277
+ moveTache(tache) {
278
+ const x = this.currentPosition.x - this.originPosition.x
279
+ const y = this.currentPosition.y - this.originPosition.y
280
+ tache.x += x
281
+ tache.y += y
282
+ if (tache.x < 0) {
283
+ tache.x = 2
284
+ }
285
+ if (tache.y < 0) {
286
+ tache.y = 2
287
+ }
288
+ },
289
+
290
+ drawVirtualSelectionRegion() {
291
+ if (this.isDrawingRegion && this.startPoint) {
292
+ this.region = getVirtualRegion(this.startPoint, this.currentPosition)
293
+ }
294
+ },
295
+ drawRealSelectionRegion() {
296
+ // 如果只选中了一个环节,那么选择区域也不需要显示了,这时把起点和region也重置了
297
+ if (this.selectedTaches.length <= 1) {
298
+ this.startPoint = null
299
+ this.region = null
300
+ return
301
+ }
302
+
303
+ this.region = getRealRegion(this.selectedTaches)
304
+ // this.startPoint = area.startPoint
305
+ },
306
+ moveSelectionRegion() {
307
+ if (!this.isMovingRegion) {
308
+ return
309
+ }
310
+ // 移动选择区域
311
+ let dx = this.currentPosition.x - this.originPosition.x
312
+ let dy = this.currentPosition.y - this.originPosition.y
313
+ // 控制不能移出canvas的边界,保留2像素的间距
314
+ if (this.region.x + dx < 0) {
315
+ dx = 2 - this.region.x
316
+ }
317
+ if (this.region.y + dy < 0) {
318
+ dy = 2 - this.region.y
319
+ }
320
+ this.region.x = this.region.x + dx
321
+ this.region.y = this.region.y + dy
322
+
323
+ this.moveTachesInRegion(dx, dy)
324
+ this.moveTransitionControlPoints(dx, dy)
325
+ },
326
+ moveTachesInRegion(dx, dy) {
327
+ for (const tache of this.selectedTaches) {
328
+ tache.x += dx
329
+ tache.y += dy
330
+ }
331
+ },
332
+ moveTransitionControlPoints(dx, dy) {
333
+ for (const transition of this.transitionsInRegion) {
334
+ if (transition.lineInfo.type === 'CurveLine') {
335
+ transition.lineInfo.controlPoint.x += dx
336
+ transition.lineInfo.controlPoint.y += dy
337
+ } else if (transition.lineInfo.type === 'BrokenLine') {
338
+ transition.lineInfo.controlPoint.forEach(point => {
339
+ point.x += dx
340
+ point.y += dy
341
+ })
342
+ }
343
+ }
344
+ },
345
+ resizeSelectedTache() {
346
+ if (!this.resizerToMove) {
347
+ return
348
+ }
349
+ let dx = this.currentPosition.x - this.originPosition.x
350
+ let dy = this.currentPosition.y - this.originPosition.y
351
+ const tache = this.resizerToMove.owner
352
+ /**
353
+ * 1.拖动某个resizer时,对角线上的另一个resizer是不动的
354
+ * 2.拖动不同的resizer时,dx,dy即使出现负数时也可能是变大,这个时候就得做减法了
355
+ */
356
+ switch (this.resizerToMove.position) {
357
+ case 'NW':
358
+ if (tache.width - dx < 80) {
359
+ dx = tache.width - 80
360
+ }
361
+ if (tache.height - dy < 40) {
362
+ dy = tache.height - 40
363
+ }
364
+ tache.width -= dx
365
+ tache.height -= dy
366
+ tache.x += dx
367
+ tache.y += dy
368
+ break
369
+ case 'NE':
370
+ if (tache.width + dx < 80) {
371
+ dx = 80 - tache.width
372
+ }
373
+ if (tache.height - dy < 40) {
374
+ dy = tache.height - 40
375
+ }
376
+ tache.width += dx
377
+ tache.height -= dy
378
+ tache.y += dy
379
+ break
380
+ case 'SW':
381
+ if (tache.width - dx < 80) {
382
+ dx = tache.width - 80
383
+ }
384
+ if (tache.height + dy < 40) {
385
+ dy = 40 - tache.height
386
+ }
387
+ tache.width -= dx
388
+ tache.height += dy
389
+ tache.x += dx
390
+ break
391
+ case 'SE':
392
+ if (tache.width + dx < 80) {
393
+ dx = 80 - tache.width
394
+ }
395
+ if (tache.height + dy < 40) {
396
+ dy = 40 - tache.height
397
+ }
398
+ tache.width += dx
399
+ tache.height += dy
400
+ break
401
+ }
402
+ },
403
+ moveTransition() {
404
+ if (!this.draggerToMove) {
405
+ return
406
+ }
407
+ const transition = this.draggerToMove.owner
408
+ const position = this.draggerToMove.position
409
+ const virtualJoint = { parent: this.currentPosition, position: '' }
410
+ if (position === 'start') {
411
+ transition.startJoint = virtualJoint
412
+ } else {
413
+ transition.endJoint = virtualJoint
414
+ }
415
+ },
416
+ adjustCurveLine() {
417
+ if (!this.controlPointToMove) {
418
+ return
419
+ }
420
+ const transition = this.controlPointToMove.owner
421
+ if (transition.lineInfo && transition.lineInfo.type === 'CurveLine') {
422
+ transition.lineInfo.controlPoint = this.currentPosition
423
+ } else if (transition.lineInfo && transition.lineInfo.type === 'BrokenLine') {
424
+ const pointIndex = this.controlPointToMove.pointIndex
425
+ const controlPoints = transition.lineInfo.controlPoint
426
+ this.$set(controlPoints, pointIndex, this.currentPosition)
427
+ }
428
+ },
429
+ endDrag(event) {
430
+
431
+ },
432
+ showTacheHistoryTooltip(event) {
433
+ this.showTacheHistory = true
434
+ },
435
+ hideTacheHistoryTooltip() {
436
+ this.showTacheHistory = false
437
+ },
438
+ updateTacheHistoryTooltipPosition(event) {
439
+ const position = getMousePosition(event)
440
+ this.tooltipPosition = {
441
+ left: position.x + 'px',
442
+ top: position.y + 'px'
443
+ }
444
+ }
445
+ }
446
+ }
447
+ </script>
448
+ <style>
449
+ #svg{
450
+ /* border:1px solid red; */
451
+ background: white;
452
+ background-image:
453
+ linear-gradient(rgba(242,242,242,.7) 1px, transparent 0),
454
+ linear-gradient(90deg, rgba(242,242,242,.7) 1px, transparent 0),
455
+ linear-gradient(#e5e5e5 1px, transparent 0),
456
+ linear-gradient(90deg,#e5e5e5 1px, transparent 0);
457
+ background-size:
458
+ 15px 15px,
459
+ 15px 15px,
460
+ 75px 75px,
461
+ 75px 75px;
462
+ }
463
+ g{
464
+ font-size: 16px;
465
+ }
466
+ g text{
467
+ dominant-baseline: middle;
468
+ }
469
+ .selected{
470
+ fill: #fff;
471
+ stroke: #f00;
472
+ stroke-width: 2;
473
+ }
474
+ .task-tache{
475
+ fill: #fff;
476
+ stroke: #666;
477
+ stroke-width: 2;
478
+ }
479
+ </style>
@@ -0,0 +1,132 @@
1
+ <template>
2
+ <ul class="context-menu">
3
+ <li v-for="menu in menus" :key="menu.name" @mousedown.stop="execute(menu.name)">
4
+ <icon-svg :icon="menu.icon" /><span>{{ menu.label }}</span>
5
+ </li>
6
+ </ul>
7
+ </template>
8
+
9
+ <script>
10
+ import { mapGetters, mapMutations } from 'vuex'
11
+ import IconSvg from './icon-svg'
12
+ export default {
13
+ name: 'ContextMenu',
14
+ components: {
15
+ IconSvg
16
+ },
17
+ data() {
18
+ return {
19
+ menusForTransition: [
20
+ { name: 'switch-line-type-StraightLine', label: this.$t('workflowEditor.main.straightLine'), icon: 'switch' },
21
+ { name: 'switch-line-type-CurveLine', label: this.$t('workflowEditor.main.curveLine'), icon: 'switch' },
22
+ { name: 'switch-line-type-BrokenLine', label: this.$t('workflowEditor.main.brokenLine'), icon: 'switch' },
23
+ { name: 'remove', label: this.$t('workflowEditor.common.remove'), icon: 'delete' },
24
+ { name: 'properties', label: this.$t('workflowEditor.common.attribute'), icon: 'properties' }
25
+ ],
26
+ menusForTache: [
27
+ { name: 'remove', label: this.$t('workflowEditor.common.remove'), icon: 'delete' },
28
+ { name: 'properties', label: this.$t('workflowEditor.common.attribute'), icon: 'properties' }
29
+ ],
30
+ menusForProcess: [
31
+ { name: 'properties', label: this.$t('workflowEditor.common.attribute'), icon: 'properties' }
32
+ ]
33
+ }
34
+ },
35
+ computed: {
36
+ ...mapGetters('wfEditor', [
37
+ 'taches',
38
+ 'transitions',
39
+ 'selectedTransition',
40
+ 'selectedTaches'
41
+ ]),
42
+ menuType() {
43
+ let type = ''
44
+ if (this.selectedTransition) {
45
+ type = 'Transition'
46
+ } else if (this.selectedTaches.length === 1) {
47
+ type = 'Tache'
48
+ }
49
+ if (this.selectedTransition === null && this.selectedTaches.length === 0) {
50
+ type = 'Process'
51
+ }
52
+ return type
53
+ },
54
+ menus() {
55
+ if (this.menuType) {
56
+ return this['menusFor' + this.menuType]
57
+ } else {
58
+ return []
59
+ }
60
+ }
61
+ },
62
+ methods: {
63
+ ...mapMutations('wfEditor', [
64
+ 'setPropertiesEditorFor',
65
+ 'setContextMenuVisible'
66
+ ]),
67
+ switchLineType(lineType) {
68
+ this.selectedTransition.lineInfo.controlPoint = null
69
+ this.selectedTransition.lineInfo.type = lineType
70
+ },
71
+ execute(menu) {
72
+ console.log('menu:' + menu)
73
+ if (menu.indexOf('switch-line-type-') >= 0) {
74
+ const lineType = menu.substring(menu.lastIndexOf('-') + 1)
75
+ this.switchLineType(lineType)
76
+ }
77
+ if (menu === 'remove') {
78
+ if (this.menuType === 'Tache') {
79
+ this.taches.splice(this.taches.indexOf(this.selectedTaches[0]), 1)
80
+ } else if (this.menuType === 'Transition') {
81
+ this.transitions.splice(this.transitions.indexOf(this.selectedTransition), 1)
82
+ }
83
+ }
84
+
85
+ const componentsWithoutPropertiesEditor = ['Start', 'End']
86
+ if (menu === 'properties') {
87
+ if (this.menuType === 'Tache') {
88
+ this.setPropertiesEditorFor(
89
+ componentsWithoutPropertiesEditor.indexOf(this.selectedTaches[0].type) >= 0 ? '' : this.selectedTaches[0].type
90
+ )
91
+ } else if (this.menuType === 'Transition') {
92
+ this.setPropertiesEditorFor('Transition')
93
+ } else {
94
+ this.setPropertiesEditorFor('Process')
95
+ }
96
+ }
97
+ this.setContextMenuVisible(false)
98
+ }
99
+ }
100
+ }
101
+ </script>
102
+ <style lang="scss" scoped>
103
+ li {
104
+ color: #333;
105
+ }
106
+ .context-menu {
107
+ position: fixed;
108
+ background: #fff;
109
+ z-index: 999;
110
+ padding:5px;
111
+ margin:0
112
+ }
113
+ .context-menu li {
114
+ min-width: 75px;
115
+ height: 28px;
116
+ line-height: 28px;
117
+ text-align: left;
118
+ color: #1a1a1a;
119
+ }
120
+ .context-menu li:hover {
121
+ background: #42b983;
122
+ color: #fff;
123
+ }
124
+ .context-menu {
125
+ border: 1px solid #eee;
126
+ box-shadow: 0 0.5em 1em 0 rgba(0,0,0,.1);
127
+ border-radius: 5px;
128
+ }
129
+ li {
130
+ list-style-type:none;
131
+ }
132
+ </style>
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <svg class="svg-icon" aria-hidden="true">
3
+ <use :xlink:href="iconName" />
4
+ </svg>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ name: 'IconSvg',
10
+ props: {
11
+ icon: {
12
+ type: String,
13
+ required: true
14
+ }
15
+ },
16
+ computed: {
17
+ iconName() {
18
+ return `#icon-${this.icon}`
19
+ }
20
+ }
21
+ }
22
+ </script>
23
+
24
+ <style>
25
+ .svg-icon {
26
+ width: 1em;
27
+ height: 1em;
28
+ vertical-align: -0.15em;
29
+ fill: currentColor;
30
+ overflow: hidden;
31
+ }
32
+ </style>
@@ -0,0 +1,66 @@
1
+ <template>
2
+ <g>
3
+ <rect
4
+ v-if="region"
5
+ :x="region.x"
6
+ :y="region.y"
7
+ :width="region.width"
8
+ :height="region.height"
9
+ :class="{'draggable':true,'selection-region':true,'dashed':selectedTaches.length<1}"
10
+ @mousedown.stop="startDrag"
11
+ @mouseup.stop="endDrag"
12
+ />
13
+ </g>
14
+ </template>
15
+ <script>
16
+ import { mapGetters, mapMutations } from 'vuex'
17
+ import { getMousePosition } from '../util'
18
+ export default {
19
+ name: 'SelectionRegion',
20
+ props: {
21
+ region: {
22
+ type: Object,
23
+ default: null
24
+ }
25
+ },
26
+ computed: {
27
+ ...mapGetters('wfEditor', [
28
+ 'selectedTaches'
29
+ ])
30
+ },
31
+ methods: {
32
+ ...mapMutations('wfEditor', [
33
+ 'setDrawingRegion',
34
+ 'setMovingRegion',
35
+ 'setMouseDownPosition'
36
+ ]),
37
+ startDrag(event) {
38
+ console.log('region mousedown')
39
+ const mouseDownPosition = getMousePosition(event)
40
+ this.setMouseDownPosition(mouseDownPosition)
41
+ this.setMovingRegion(true)
42
+ },
43
+ endDrag(event) {
44
+ console.log('region mouseup')
45
+
46
+ this.setMovingRegion(false)
47
+ this.setMouseDownPosition(null)
48
+ }
49
+ }
50
+ }
51
+ </script>
52
+ <style>
53
+ .selection-region{
54
+ stroke: blue;
55
+ stroke-width: 1;
56
+ fill: white;
57
+ fill-opacity: 0;
58
+ opacity: 1;
59
+ cursor: move;
60
+ }
61
+ .dashed{
62
+ stroke-dasharray: 10 2;
63
+ /* 控制region在画的过程中不响应任何事件,只有画完后才能响应 */
64
+ pointer-events:none;
65
+ }
66
+ </style>