workflow-editor 0.9.68-dw → 0.9.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +533 -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/auto-task.js +70 -0
- package/packages/workflow-editor/src/json-object-templates/copy-task.js +72 -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 +31 -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 +483 -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 +304 -0
- package/packages/workflow-editor/src/process-json.js +623 -0
- package/packages/workflow-editor/src/process-service.js +31 -0
- package/packages/workflow-editor/src/properties-editors/auto-task/basic-properties.vue +81 -0
- package/packages/workflow-editor/src/properties-editors/auto-task/permission-settings.vue +155 -0
- package/packages/workflow-editor/src/properties-editors/auto-task.vue +73 -0
- package/packages/workflow-editor/src/properties-editors/common/additional-condition-utils.js +556 -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 +67 -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-reminder.vue +72 -0
- package/packages/workflow-editor/src/properties-editors/common/notice.vue +101 -0
- package/packages/workflow-editor/src/properties-editors/common/reminder.vue +185 -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 +275 -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 +94 -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 +160 -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 +109 -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 +115 -0
- package/packages/workflow-editor/src/properties-editors/subprocess/basic-properties.vue +199 -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 +183 -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/auto-task.vue +99 -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 +489 -0
- package/packages/workflow-editor/src/workflow-editor.vue +607 -0
- package/packages/workflow-editor/src/workflow-history.vue +153 -0
- package/src/i18n/i18n.js +1 -1
- package/src/i18n/langs/cn.js +43 -24
- package/src/i18n/langs/en.js +23 -7
|
@@ -0,0 +1,607 @@
|
|
|
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
|
+
box-sizing: border-box;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.canvas,.xml{
|
|
585
|
+
overflow: auto;
|
|
586
|
+
height:100%;
|
|
587
|
+
width:100%;
|
|
588
|
+
// border:1px solid red;
|
|
589
|
+
// background: #ffffff;
|
|
590
|
+
padding: 0;
|
|
591
|
+
min-height: 500px;
|
|
592
|
+
|
|
593
|
+
}
|
|
594
|
+
pre{
|
|
595
|
+
margin:0;
|
|
596
|
+
font-size:16px;
|
|
597
|
+
}
|
|
598
|
+
.component-icon {
|
|
599
|
+
position: absolute;
|
|
600
|
+
pointer-events: none;
|
|
601
|
+
// border: 1px solid red;
|
|
602
|
+
}
|
|
603
|
+
.canvas /deep/ .draggable{
|
|
604
|
+
cursor: move;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
</style>
|