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