workflow-editor 0.0.7-up → 0.0.8-up

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 (121) hide show
  1. package/package.json +12 -2
  2. package/index.html +0 -13
  3. package/packages/index.js +0 -34
  4. package/packages/plugins/formValidatorUtil.js +0 -533
  5. package/packages/plugins/index.js +0 -8
  6. package/packages/workflow-editor/index.js +0 -14
  7. package/packages/workflow-editor/src/api.js +0 -7
  8. package/packages/workflow-editor/src/assets/wf-editor-icons.js +0 -2
  9. package/packages/workflow-editor/src/constant.js +0 -8
  10. package/packages/workflow-editor/src/json-object-templates/auto-task.js +0 -70
  11. package/packages/workflow-editor/src/json-object-templates/copy-task.js +0 -72
  12. package/packages/workflow-editor/src/json-object-templates/decision.js +0 -11
  13. package/packages/workflow-editor/src/json-object-templates/end.js +0 -14
  14. package/packages/workflow-editor/src/json-object-templates/fork.js +0 -10
  15. package/packages/workflow-editor/src/json-object-templates/human-decision.js +0 -9
  16. package/packages/workflow-editor/src/json-object-templates/human-task.js +0 -199
  17. package/packages/workflow-editor/src/json-object-templates/join.js +0 -10
  18. package/packages/workflow-editor/src/json-object-templates/process.js +0 -98
  19. package/packages/workflow-editor/src/json-object-templates/start.js +0 -13
  20. package/packages/workflow-editor/src/json-object-templates/subprocess.js +0 -31
  21. package/packages/workflow-editor/src/json-object-templates/transition.js +0 -26
  22. package/packages/workflow-editor/src/main/admin-save-dialog.vue +0 -66
  23. package/packages/workflow-editor/src/main/canvas.vue +0 -483
  24. package/packages/workflow-editor/src/main/context-menu.vue +0 -132
  25. package/packages/workflow-editor/src/main/icon-svg.vue +0 -32
  26. package/packages/workflow-editor/src/main/selection-region.vue +0 -66
  27. package/packages/workflow-editor/src/main/tache-history-tooltip.vue +0 -38
  28. package/packages/workflow-editor/src/main/tache-name-input.vue +0 -19
  29. package/packages/workflow-editor/src/main/tache-subprocess-history-dialog.vue +0 -35
  30. package/packages/workflow-editor/src/main/toolbox.vue +0 -60
  31. package/packages/workflow-editor/src/main/wf-history-canvas.vue +0 -304
  32. package/packages/workflow-editor/src/process-json.js +0 -623
  33. package/packages/workflow-editor/src/process-service.js +0 -31
  34. package/packages/workflow-editor/src/properties-editors/auto-task/basic-properties.vue +0 -81
  35. package/packages/workflow-editor/src/properties-editors/auto-task/permission-settings.vue +0 -155
  36. package/packages/workflow-editor/src/properties-editors/auto-task.vue +0 -73
  37. package/packages/workflow-editor/src/properties-editors/common/additional-condition-utils.js +0 -531
  38. package/packages/workflow-editor/src/properties-editors/common/additional-condition.vue +0 -276
  39. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields-utils.js +0 -34
  40. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields.vue +0 -239
  41. package/packages/workflow-editor/src/properties-editors/common/common-notice-tool.vue +0 -67
  42. package/packages/workflow-editor/src/properties-editors/common/common-user-condition.vue +0 -241
  43. package/packages/workflow-editor/src/properties-editors/common/form-fields-utils.js +0 -23
  44. package/packages/workflow-editor/src/properties-editors/common/form-fields.vue +0 -116
  45. package/packages/workflow-editor/src/properties-editors/common/i18n-input.vue +0 -75
  46. package/packages/workflow-editor/src/properties-editors/common/i18n-set-dialog.vue +0 -125
  47. package/packages/workflow-editor/src/properties-editors/common/notice-reminder.vue +0 -72
  48. package/packages/workflow-editor/src/properties-editors/common/notice.vue +0 -101
  49. package/packages/workflow-editor/src/properties-editors/common/reminder.vue +0 -185
  50. package/packages/workflow-editor/src/properties-editors/common/select-mail-template.vue +0 -83
  51. package/packages/workflow-editor/src/properties-editors/common/standard-fields.vue +0 -65
  52. package/packages/workflow-editor/src/properties-editors/common/system-role-tree-inline.vue +0 -347
  53. package/packages/workflow-editor/src/properties-editors/common/system-role-tree.vue +0 -63
  54. package/packages/workflow-editor/src/properties-editors/common/task-title.vue +0 -148
  55. package/packages/workflow-editor/src/properties-editors/common/transactor-settings.vue +0 -233
  56. package/packages/workflow-editor/src/properties-editors/common/user-selection.vue +0 -386
  57. package/packages/workflow-editor/src/properties-editors/common/value-selection-dialog.vue +0 -209
  58. package/packages/workflow-editor/src/properties-editors/common/variables.vue +0 -135
  59. package/packages/workflow-editor/src/properties-editors/copy-task/basic-properties.vue +0 -90
  60. package/packages/workflow-editor/src/properties-editors/copy-task/permission-settings.vue +0 -155
  61. package/packages/workflow-editor/src/properties-editors/copy-task.vue +0 -94
  62. package/packages/workflow-editor/src/properties-editors/decision.vue +0 -90
  63. package/packages/workflow-editor/src/properties-editors/fork.vue +0 -72
  64. package/packages/workflow-editor/src/properties-editors/human-decision.vue +0 -44
  65. package/packages/workflow-editor/src/properties-editors/human-task/additional-condition-dialog.vue +0 -60
  66. package/packages/workflow-editor/src/properties-editors/human-task/basic-properties.vue +0 -160
  67. package/packages/workflow-editor/src/properties-editors/human-task/componentsConfigUtil.js +0 -291
  68. package/packages/workflow-editor/src/properties-editors/human-task/custom-actions.vue +0 -249
  69. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-field-setting.vue +0 -392
  70. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-fields.vue +0 -241
  71. package/packages/workflow-editor/src/properties-editors/human-task/editable-field-selection.vue +0 -220
  72. package/packages/workflow-editor/src/properties-editors/human-task/editable-fields.vue +0 -204
  73. package/packages/workflow-editor/src/properties-editors/human-task/events.vue +0 -59
  74. package/packages/workflow-editor/src/properties-editors/human-task/permission-settings.vue +0 -207
  75. package/packages/workflow-editor/src/properties-editors/human-task/selection-conditions.vue +0 -390
  76. package/packages/workflow-editor/src/properties-editors/human-task.vue +0 -109
  77. package/packages/workflow-editor/src/properties-editors/join.vue +0 -44
  78. package/packages/workflow-editor/src/properties-editors/process/basic-properties.vue +0 -273
  79. package/packages/workflow-editor/src/properties-editors/process/events.vue +0 -76
  80. package/packages/workflow-editor/src/properties-editors/process/notice-settings.vue +0 -60
  81. package/packages/workflow-editor/src/properties-editors/process/parameter-settings.vue +0 -95
  82. package/packages/workflow-editor/src/properties-editors/process/permission-settings.vue +0 -28
  83. package/packages/workflow-editor/src/properties-editors/process/selectPage.vue +0 -81
  84. package/packages/workflow-editor/src/properties-editors/process.vue +0 -115
  85. package/packages/workflow-editor/src/properties-editors/subprocess/basic-properties.vue +0 -199
  86. package/packages/workflow-editor/src/properties-editors/subprocess/events.vue +0 -26
  87. package/packages/workflow-editor/src/properties-editors/subprocess/field-mappings.vue +0 -206
  88. package/packages/workflow-editor/src/properties-editors/subprocess/transactor-settings.vue +0 -64
  89. package/packages/workflow-editor/src/properties-editors/subprocess.vue +0 -79
  90. package/packages/workflow-editor/src/properties-editors/transition/basic-properties.vue +0 -53
  91. package/packages/workflow-editor/src/properties-editors/transition.vue +0 -74
  92. package/packages/workflow-editor/src/properties-editors/user-condition.js +0 -177
  93. package/packages/workflow-editor/src/store/getters.js +0 -27
  94. package/packages/workflow-editor/src/store/workflow-editor.js +0 -125
  95. package/packages/workflow-editor/src/taches/auto-task.vue +0 -99
  96. package/packages/workflow-editor/src/taches/common-methods.js +0 -21
  97. package/packages/workflow-editor/src/taches/copy-task.vue +0 -99
  98. package/packages/workflow-editor/src/taches/custom-task.vue +0 -88
  99. package/packages/workflow-editor/src/taches/decision.vue +0 -102
  100. package/packages/workflow-editor/src/taches/end.vue +0 -76
  101. package/packages/workflow-editor/src/taches/fork.vue +0 -102
  102. package/packages/workflow-editor/src/taches/human-decision.vue +0 -102
  103. package/packages/workflow-editor/src/taches/human-task.vue +0 -113
  104. package/packages/workflow-editor/src/taches/join.vue +0 -91
  105. package/packages/workflow-editor/src/taches/joint.vue +0 -177
  106. package/packages/workflow-editor/src/taches/start.vue +0 -76
  107. package/packages/workflow-editor/src/taches/subprocess.vue +0 -99
  108. package/packages/workflow-editor/src/taches/tache-resizer.vue +0 -80
  109. package/packages/workflow-editor/src/transitions/broken-line.vue +0 -91
  110. package/packages/workflow-editor/src/transitions/curve-line.vue +0 -91
  111. package/packages/workflow-editor/src/transitions/straight-line.vue +0 -26
  112. package/packages/workflow-editor/src/transitions/transition.vue +0 -212
  113. package/packages/workflow-editor/src/transitions/virtual-transition.vue +0 -43
  114. package/packages/workflow-editor/src/util.js +0 -489
  115. package/packages/workflow-editor/src/workflow-editor.vue +0 -606
  116. package/packages/workflow-editor/src/workflow-history.vue +0 -153
  117. package/public/vite.svg +0 -1
  118. package/src/i18n/i18n.js +0 -16
  119. package/src/i18n/langs/cn.js +0 -509
  120. package/src/i18n/langs/en.js +0 -551
  121. package/vite.config.js +0 -36
@@ -1,606 +0,0 @@
1
- <template>
2
- <div
3
- ref="wfEditor"
4
- style="position:relative;height:100%;"
5
- @mousedown="setContextMenuVisible(false)"
6
- @mousewheel="setContextMenuVisible(false)"
7
- >
8
- <el-row class="button-area">
9
- <el-button v-if="!readonly" type="primary" size="small" @click="saveXml">
10
- {{ $t('workflowEditorPublicModel.save') }}
11
- </el-button>
12
- <el-button v-if="!readonly" v-permission="'wf.workflowDefinition.adminSave'" type="primary" size="small" @click="adminSave">
13
- {{ $t('workflowEditorPublicModel.adminSave') }}
14
- </el-button>
15
- <el-button type="primary" size="small" @click="exportProcessFromClient">
16
- {{ $t('workflowEditorPublicModel.export') }}
17
- </el-button>
18
- <el-button
19
- v-if="!readonly"
20
- size="small"
21
- type="primary"
22
- @click="selectProcessFile"
23
- >
24
- {{ $t('workflowEditorPublicModel.open') }}
25
- <input
26
- ref="processFile"
27
- type="file"
28
- name="processFile"
29
- accept=".xml"
30
- style="display:none"
31
- @change="openXmlFromClient"
32
- >
33
- </el-button>
34
-
35
- <el-button type="primary" size="small" @click="$emit('back')">
36
- {{ $t('workflowEditorPublicModel.return') }}
37
- </el-button>
38
- </el-row>
39
- <div
40
- class="main"
41
- @mousedown="startDrag"
42
- @mousemove="drag"
43
- @mouseup="endDrag"
44
- @mouseleave="clearStatus"
45
- >
46
- <toolbox
47
- v-if="!readonly"
48
- class="toolbox"
49
- onselectstart="return false"
50
- oncontextmenu="return false"
51
- />
52
- <section>
53
- <el-tabs v-model="activeTab" type="border-card" class="tabs">
54
- <el-tab-pane :label="$t('workflowEditorPublicModel.flowChart')" name="canvas" class="tab-pane">
55
- <workflow-canvas
56
- onselectstart="return false"
57
- :process="process"
58
- class="canvas"
59
- @mouseup.native="addTache"
60
- @contextmenu.native.prevent="showContextMenu"
61
- />
62
- </el-tab-pane>
63
- <el-tab-pane
64
- label="XML"
65
- name="xml"
66
- class="tab-pane"
67
- >
68
- <pre v-if="activeTab==='xml'" class="xml line-numbers"><code ref="xml" class="language-xml">{{ xml }}</code></pre>
69
- </el-tab-pane>
70
- </el-tabs>
71
- </section>
72
- </div>
73
- <icon-svg
74
- v-if="componentToDraw"
75
- :style="{
76
- height:componentInfo.height,
77
- width:componentInfo.width,
78
- color:componentInfo.color,
79
- left: currentPosition.x+'px',
80
- top:currentPosition.y+'px',
81
- }"
82
- :icon="componentInfo.icon"
83
- class="component-icon"
84
- />
85
- <context-menu v-if="contextMenuVisible" :style="{position:'absolute',left: contextMenuPosition.x+ 'px',top:contextMenuPosition.y+'px'}" />
86
- <admin-save-dialog v-if="isAdminSave" @close="isAdminSave = false" @update="updateWfVersion" @add="addWfVersion" />
87
- </div>
88
- </template>
89
- <script>
90
- import './assets/wf-editor-icons.js'
91
- import { mapGetters, mapMutations } from 'vuex'
92
- import { getMousePosition, removeTextProperty, getComponentInfo, initializeProcessData, processTemplate } from './util'
93
- import Toolbox from './main/toolbox'
94
- import WorkflowCanvas from './main/canvas'
95
- import IconSvg from './main/icon-svg'
96
- import ContextMenu from './main/context-menu'
97
- import convert from 'xml-js'
98
- import processService from './process-service'
99
- import FileSaver from 'file-saver'
100
- import Prism from 'prismjs'
101
- import AdminSaveDialog from './main/admin-save-dialog'
102
- export default {
103
- name: 'WorkflowEditor',
104
- components: {
105
- WorkflowCanvas,
106
- Toolbox,
107
- IconSvg,
108
- ContextMenu,
109
- AdminSaveDialog
110
- },
111
- props: {
112
- // 流程编码
113
- code: {
114
- type: String,
115
- default: null
116
- },
117
- // 流程版本
118
- version: {
119
- type: Number,
120
- default: null
121
- },
122
- // 流程id
123
- id: {
124
- type: Number,
125
- default: null
126
- },
127
- readonly: {
128
- type: Boolean,
129
- default: false
130
- }
131
- },
132
- data: function() {
133
- return {
134
- activeTab: 'canvas',
135
- count: 1,
136
- currentPosition: { x: 0, y: 0 },
137
- process: null,
138
- definitionId: null,
139
- xml: '',
140
- contextMenuPosition: null,
141
- isAdminSave: false // 是否点击了管理员保存按钮
142
- }
143
- },
144
- computed: {
145
- ...mapGetters(
146
- 'wfEditor', ['componentToDraw', 'taches', 'transitions', 'contextMenuVisible']
147
- ),
148
- ...mapGetters([
149
- 'sidebar'
150
- ]),
151
- componentInfo() {
152
- return getComponentInfo(this.componentToDraw)
153
- }
154
- },
155
- watch: {
156
- activeTab(name) {
157
- if (name === 'xml') {
158
- this.xml = this.getProcessXml()
159
- this.$nextTick(function() {
160
- Prism.highlightElement(this.$refs.xml)
161
- })
162
- }
163
- }
164
- },
165
- created: function() {
166
- // 打开或新建流程图时先清空画布,开发过程中代码热更新的时候可以避免节点重复
167
- this.clearCanvas()
168
- if (this.id) {
169
- this.definitionId = this.id
170
- }
171
- console.log('canvas-created=', this.code, this.id)
172
- if (this.code || this.id) {
173
- let url = this.baseAPI + '/wf-editor/open-xmls/with-definitions'
174
- url = this.packageUrlParam(url)
175
- this.$http.get(url).then(xml => {
176
- this.initProcessByXml(xml)
177
- })
178
- } else {
179
- this.process = processTemplate.newProcess()
180
- initializeProcessData(this.process)
181
- }
182
- },
183
- mounted: function() {
184
-
185
- },
186
- methods: {
187
- ...mapMutations('wfEditor', [
188
- 'setComponentToDraw',
189
- 'clearCanvas',
190
- 'setContextMenuVisible',
191
- 'setSystemCode',
192
- 'setProcessCode'
193
- ]),
194
- showContextMenu(event) {
195
- console.log(event)
196
- this.setContextMenuVisible(true)
197
- // 得到元素在页面上的位置信息,用来计算鼠标位置的偏移量
198
- const offset = this.$refs.wfEditor.getBoundingClientRect()
199
- this.contextMenuPosition = {
200
- x: event.clientX - offset.x,
201
- y: event.clientY - offset.y
202
- }
203
- },
204
- initProcessByXml(xml) {
205
- const options = { nativeType: true, attributesKey: 'attr', compact: true, ignoreComment: true, spaces: 4 }
206
- const processObj = convert.xml2js(xml, options)
207
- removeTextProperty(processObj.process)
208
- this.process = processObj.process
209
- if (this.process && this.process.properties && this.process.properties.basicProperties) {
210
- this.setSystemCode(this.process.properties.basicProperties.systemCode)
211
- }
212
- if (this.process && this.process.attr) {
213
- this.setProcessCode(this.process.attr.code)
214
- }
215
- // 得到表单字段放到vuex
216
- this.fetchFormFields()
217
- initializeProcessData(this.process)
218
- this.count = this.getMaxCount() + 1
219
- },
220
- fetchFormFields() {
221
- const processProperties = this.process.properties.basicProperties
222
- const formCode = processProperties.formCode
223
- const formVersion = processProperties.formVersion
224
- if (formCode && formCode !== '' && formVersion) {
225
- // 取出formFields放到vuex中
226
- processService.fetchFormFields(processProperties.formCode, processProperties.formVersion)
227
- }
228
- },
229
- packageUrlParam(url) {
230
- if (this.id) {
231
- url = url + '?id=' + this.id
232
- } else if (this.code) {
233
- url = url + '?code=' + this.code + '&version=' + this.version
234
- }
235
- return url
236
- },
237
- // 获得流程定义xml
238
- getProcessXml() {
239
- const process = {
240
- start: [],
241
- humanTask: [],
242
- decision: [],
243
- transition: [],
244
- fork: [],
245
- join: [],
246
- subprocess: [],
247
- humanDecision: [],
248
- copyTask: [],
249
- autoTask: [],
250
- end: []
251
- }
252
- process.attr = this.process.attr
253
- process.properties = this.process.properties
254
- this.taches.map(tache => {
255
- const type = tache.type
256
- // type的首字母小写形式就是process中各个数组的名字,ref才是真正的环节信息
257
- process[type.charAt(0).toLowerCase() + type.substring(1)].push(tache.ref)
258
- // 补充完整图形位置信息
259
- tache.ref.g = {
260
- x: tache.x,
261
- y: tache.y,
262
- width: tache.width,
263
- height: tache.height
264
- }
265
- })
266
- this.transitions.map(transition => {
267
- // ref才是真正的流向信息
268
- process.transition.push(transition.ref)
269
- // 补充完整图形位置信息
270
- transition.ref.g = {
271
- fromJoint: transition.startJoint.position,
272
- toJoint: transition.endJoint.position,
273
- coordinate: '',
274
- lineType: transition.lineInfo.type
275
- }
276
- if (transition.lineInfo.type === 'CurveLine' && transition.lineInfo.controlPoint) {
277
- transition.ref.g.coordinate = transition.lineInfo.controlPoint.x + ',' + transition.lineInfo.controlPoint.y
278
- } else if (transition.lineInfo.type === 'BrokenLine' && transition.lineInfo.controlPoint) {
279
- let coordinate = ''
280
- transition.lineInfo.controlPoint.forEach(point => {
281
- coordinate += point.x + ',' + point.y + ';'
282
- })
283
- transition.ref.g.coordinate = coordinate
284
- }
285
- })
286
- const options = { attributesKey: 'attr', compact: true, ignoreComment: true, spaces: 4 }
287
- let result = convert.json2xml({ process }, options)
288
- result = '<?xml version="1.0" encoding="utf-8"?>\n' + result
289
- return result
290
- },
291
- // 保存xml
292
- saveXml() {
293
- const xml = this.getProcessXml()
294
- // console.log(xml)
295
- // 保存流程定义xml
296
- if (this.code || this.id || this.definitionId) {
297
- // 表示修改
298
- this.saveWf(xml, this.baseAPI + '/wf-editor/workflow-definitions/updates')
299
- .then(() => {
300
- this.$alert(this.$t('workflowEditorMessage.updateSuccessful'))
301
- })
302
- } else {
303
- // 表示新建
304
- const param = {
305
- xml: xml
306
- }
307
- this.$http.post(this.baseAPI + '/wf-editor/workflow-definitions', param).then(definition => {
308
- this.definitionId = definition.id
309
- this.$alert(this.$t('workflowEditorMessage.savedSuccessfully'))
310
- // console.log('新建成功' + this.definitionId)
311
- })
312
- }
313
- },
314
- saveWf(xml, url, message) {
315
- return new Promise((resolve, reject) => {
316
- const param = this.packageSaveXmlParam(xml)
317
-
318
- this.$http.post(url, param).then(definition => {
319
- this.definitionId = definition.id
320
- // console.log('更新成功' + this.definitionId)
321
- resolve()
322
- })
323
- })
324
- },
325
- packageSaveXmlParam(xml) {
326
- const param = {
327
- xml: xml
328
- }
329
- if (this.definitionId) {
330
- // 表示已保存过,新流程定义的id
331
- param.id = this.definitionId
332
- } else {
333
- if (this.id) {
334
- param.id = this.id
335
- } else if (this.code) {
336
- param.code = this.code
337
- param.version = this.version
338
- }
339
- }
340
- return param
341
- },
342
- adminSave() {
343
- const xml = this.getProcessXml()
344
- // console.log(xml)
345
- // 保存流程定义xml
346
- if (this.code || this.id || this.definitionId) {
347
- // 表示修改
348
- const url = this.baseAPI + '/wf-editor/workflow-definitions/states'
349
- const param = {}
350
- if (this.definitionId) {
351
- // 表示已保存过,新流程定义的id
352
- param.id = this.definitionId
353
- } else {
354
- if (this.id) {
355
- param.id = this.id
356
- } else if (this.code) {
357
- param.code = this.code
358
- param.version = this.version
359
- }
360
- }
361
- this.$http.post(url, param).then(state => {
362
- if (state === 'DRAFT') {
363
- // 如果是草稿状态直接保存
364
- this.saveWf(xml, this.baseAPI + '/wf-editor/workflow-definitions/updates')
365
- .then(() => {
366
- this.$alert(this.$t('workflowEditorMessage.updateSuccessful'))
367
- })
368
- } else {
369
- // 如果是禁用或启用状态,让用户选择是增加版本还是更新版本
370
- this.isAdminSave = true
371
- }
372
- })
373
- } else {
374
- // 表示新建
375
- const param = {
376
- xml: xml
377
- }
378
- this.$http.post(this.baseAPI + '/wf-editor/workflow-definitions', param).then(definition => {
379
- this.definitionId = definition.id
380
- this.$alert(this.$t('workflowEditorMessage.savedSuccessfully'))
381
- // console.log('新建成功' + this.definitionId)
382
- })
383
- }
384
- },
385
- updateWfVersion() {
386
- const xml = this.getProcessXml()
387
- this.saveWf(xml, this.baseAPI + '/wf-editor/workflow-definitions/update-version')
388
- .then(() => {
389
- this.isAdminSave = false
390
- this.$alert(this.$t('workflowEditorMessage.updateVersionSuccessful'))
391
- })
392
- },
393
- addWfVersion() {
394
- const xml = this.getProcessXml()
395
- this.saveWf(xml, this.baseAPI + '/wf-editor/workflow-definitions/updates')
396
- .then(() => {
397
- this.isAdminSave = false
398
- this.$alert(this.$t('workflowEditorMessage.addVersionSuccessful'))
399
- })
400
- },
401
- exportProcessFromClient() {
402
- const blob = new Blob([this.getProcessXml()], { type: 'text/xml;charset=utf-8' })
403
- FileSaver.saveAs(blob, this.process.attr.name + '.xml')
404
- },
405
- // 导出xml
406
- exportProcess() {
407
- const xml = this.getProcessXml()
408
- this.$http({
409
- method: 'post',
410
- url: this.baseAPI + '/wf-editor/save-as-xmls',
411
- data: {
412
- xmlContent: xml
413
- }
414
- }).then((response) => {
415
- this.download(response)
416
- console.log(this.$t('workflowEditorMessage.exportSucceeded'))
417
- })
418
- },
419
- // 下载文件
420
- download(data) {
421
- if (!data) {
422
- return
423
- }
424
- const url = window.URL.createObjectURL(new Blob([data]))
425
- const link = document.createElement('a')
426
- link.style.display = 'none'
427
- link.href = url
428
- link.setAttribute('download', 'myXml.xml')
429
-
430
- document.body.appendChild(link)
431
- link.click()
432
- },
433
- // 打开xml文件成功后
434
- uploadSuccess(response, file, fileList) {
435
- const xml = response
436
- // console.log('xml=', xml)
437
- // 打开或新建流程图时先清空画布,开发过程中代码热更新的时候可以避免节点重复
438
- this.clearCanvas()
439
- this.initProcessByXml(xml)
440
- this.$refs.upload.clearFiles()
441
- },
442
- getCurrentPosition(event) {
443
- if (this.componentToDraw) {
444
- const offset = this.$refs.wfEditor.getBoundingClientRect()
445
-
446
- this.currentPosition = { x: event.clientX - offset.x - 22, y: event.clientY - offset.y - 22 }
447
- }
448
- },
449
- startDrag(event) {
450
- this.getCurrentPosition(event)
451
- },
452
- drag(event) {
453
- this.getCurrentPosition(event)
454
- },
455
- endDrag() {
456
- if (this.componentToDraw) {
457
- this.setComponentToDraw('')
458
- }
459
- },
460
-
461
- addTache(event) {
462
- if (this.componentToDraw) {
463
- const positionInSVG = getMousePosition(event)
464
- const ref = processTemplate['new' + this.componentToDraw]()
465
- // 组件类型转换为首字母小写形式
466
- ref.attr.id = this.componentToDraw.charAt(0).toLowerCase() + this.componentToDraw.substring(1) + '_' + this.count
467
- const tache = {
468
- // 默认id是组件类型加上下划线和数字序号,每次打开流程图的时候都需要动态计算最大的序号,然后加1作为count的的初始值
469
- id: ref.attr.id,
470
- name: ref.attr.name,
471
- x: positionInSVG.x - this.componentInfo.width / 2,
472
- y: positionInSVG.y - this.componentInfo.height / 2,
473
- width: this.componentInfo.width,
474
- height: this.componentInfo.height,
475
- type: this.componentToDraw,
476
- isSelected: false
477
- }
478
- tache.ref = ref
479
- this.taches.push(tache)
480
- this.count++
481
- }
482
- },
483
- clearStatus() {
484
- if (this.componentToDraw) {
485
- this.setComponentToDraw('')
486
- }
487
- },
488
- getMaxCount() {
489
- let max = 0
490
- this.taches.map(item => {
491
- // 自动生成的id以下划线加数字编号结尾
492
- let index = item.id.substring(item.id.lastIndexOf('_') + 1)
493
- index = +index
494
- if (max < index) {
495
- max = index
496
- }
497
- })
498
- return max
499
- },
500
- selectProcessFile() {
501
- this.$refs.processFile.click()
502
- },
503
- openXmlFromClient() {
504
- if (this.$refs.processFile.value === '') return
505
- const file = this.$refs.processFile.files[0]
506
- const reader = new FileReader()
507
- // 本地直接读取文件
508
- reader.readAsText(file)
509
- const vm = this
510
- reader.onload = function() {
511
- // 打开或新建流程图时先清空画布,开发过程中代码热更新的时候可以避免节点重复
512
- vm.clearCanvas()
513
- vm.initProcessByXml(reader.result)
514
- vm.$refs.processFile.value = ''
515
- }
516
- }
517
- }
518
- }
519
- </script>
520
- <style lang="scss" scoped>
521
- $toolboxWidth:150px;
522
- $buttonAreaHeight:50px;
523
- $tabsHeaderHeight:41px;
524
- .button-area{
525
- padding:5px 0 5px 5px;
526
- height: $buttonAreaHeight;
527
- }
528
- .el-row{
529
- border: 1px solid #f1f1f1;
530
- border-radius: 5px;
531
- }
532
- .el-col{
533
- padding-left:5px;
534
- }
535
- .main{
536
- position: relative;
537
- display:flex;
538
- height: calc(100% - #{$buttonAreaHeight});
539
- width:100%;
540
- }
541
- .canvas-container{
542
- position: relative;
543
- // display:flex;
544
- height: calc(100% - #{$buttonAreaHeight});
545
- width:100%;
546
- }
547
- .toolbox{
548
- width:$toolboxWidth;
549
- overflow-y:auto;
550
- height: 100%;
551
- // border:1px solid black;
552
- background: #f7f7f7;
553
- padding: 10px;
554
- // min-height: 500px;
555
- text-align: center;
556
- flex:none;
557
- // min-width: 140px;
558
- // max-width:180px;
559
- }
560
- section{
561
- overflow: hidden;
562
- flex:1 1 auto;
563
- height:100%;
564
- padding: 0;
565
- // min-height: 500px;
566
- }
567
- .tabs{
568
- height:100%;
569
- width:100%;
570
- }
571
-
572
- .tab-pane{
573
- height:100%;
574
- width:100%;
575
- }
576
- // 在scss中需要使用/deep/这个别名来代替 '>>>'
577
- .tabs :deep(.el-tabs__content){
578
- height: calc(100% - #{$tabsHeaderHeight});
579
- padding:10px;
580
- width:100%;
581
- }
582
-
583
- .canvas,.xml{
584
- overflow: auto;
585
- height:100%;
586
- width:100%;
587
- // border:1px solid red;
588
- // background: #ffffff;
589
- padding: 0;
590
- min-height: 500px;
591
-
592
- }
593
- pre{
594
- margin:0;
595
- font-size:16px;
596
- }
597
- .component-icon {
598
- position: absolute;
599
- pointer-events: none;
600
- // border: 1px solid red;
601
- }
602
- .canvas :deep(.draggable){
603
- cursor: move;
604
- }
605
-
606
- </style>