workflow-editor 0.9.84-dw-tmp7 → 0.9.84-dw-tmp9

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