vue2-client 1.2.0 → 1.2.3
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/README.md +65 -65
- package/babel.config.js +1 -0
- package/docs/notice.md +22 -0
- package/index.js +28 -28
- package/package.json +1 -1
- package/src/App.vue +93 -93
- package/src/assets/img/SunClientDownload.png +0 -0
- package/src/assets/img/SunClientManual/1.png +0 -0
- package/src/assets/img/SunClientManual/2.png +0 -0
- package/src/assets/img/SunClientManual/3.png +0 -0
- package/src/assets/img/SunClientManual/4.png +0 -0
- package/src/assets/img/ToDeskDownload.png +0 -0
- package/src/assets/img/ToDeskManual/1.png +0 -0
- package/src/assets/img/ToDeskManual/2.png +0 -0
- package/src/assets/img/ToDeskManual/3.png +0 -0
- package/src/assets/img/ToDeskManual/4.png +0 -0
- package/src/assets/sound/newNote.mp3 +0 -0
- package/src/base-client/all.js +57 -57
- package/src/base-client/components/common/CreateQuery/CreateQuery.vue +1157 -1159
- package/src/base-client/components/common/CreateQuery/index.md +42 -42
- package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +540 -540
- package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
- package/src/base-client/components/common/CustomColumnsDrawer/index.md +46 -46
- package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +150 -150
- package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
- package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
- package/src/base-client/components/common/XAddForm/XAddForm.vue +323 -323
- package/src/base-client/components/common/XAddForm/index.md +60 -60
- package/src/base-client/components/common/XBadge/index.md +39 -39
- package/src/base-client/components/common/XCard/index.md +43 -43
- package/src/base-client/components/common/XForm/XForm.vue +275 -275
- package/src/base-client/components/common/XForm/XFormItem.vue +217 -217
- package/src/base-client/components/common/XForm/index.md +196 -196
- package/src/base-client/components/common/XFormCol/index.md +35 -35
- package/src/base-client/components/common/XFormTable/XFormTable.vue +407 -405
- package/src/base-client/components/common/XFormTable/index.md +89 -89
- package/src/base-client/components/common/XTable/XTable.vue +262 -262
- package/src/base-client/components/common/XTable/index.md +255 -255
- package/src/base-client/components/common/XTreeOne/XTreeOne.vue +105 -105
- package/src/base-client/components/iot/CustomerDetailsView/CustomerDetailsView.vue +226 -226
- package/src/base-client/components/iot/CustomerDetailsView/index.md +41 -41
- package/src/base-client/components/iot/DataAnalysisUser/DataAnalysisUser.vue +127 -127
- package/src/base-client/components/iot/DataAnalysisView/DataAnalysisView.vue +244 -250
- package/src/base-client/components/iot/DataAnalysisViewGD/DataAnalysisViewGD.vue +548 -548
- package/src/base-client/components/iot/DeviceBrandDetailsView/DeviceBrandDetailsView.vue +453 -453
- package/src/base-client/components/iot/DeviceDetailsView/DeviceDetailsView.vue +231 -231
- package/src/base-client/components/iot/DeviceDetailsView/index.md +43 -43
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsCount.vue +330 -330
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsException.vue +57 -57
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstruct.vue +122 -122
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsInstructOperate.vue +122 -122
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsMain.vue +225 -225
- package/src/base-client/components/iot/DeviceDetailsView/part/DeviceDetailsRead.vue +135 -135
- package/src/base-client/components/iot/DeviceTypeDetailsView/DeviceTypeDetailsView.vue +277 -277
- package/src/base-client/components/iot/InstructDetailsView/InstructDetailsView.vue +472 -472
- package/src/base-client/components/iot/InstructDetailsView/index.md +45 -45
- package/src/base-client/components/iot/LogDetailsView/LogDetailsView.vue +380 -380
- package/src/base-client/components/iot/LogDetailsView/index.md +43 -43
- package/src/base-client/components/iot/MeterDetailsView/MeterDetailsView.vue +360 -360
- package/src/base-client/components/iot/MeterDetailsView/index.md +43 -43
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsCount.vue +335 -335
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsException.vue +185 -185
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsHandPlan.vue +292 -292
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsInstruct.vue +237 -237
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsMain.vue +257 -257
- package/src/base-client/components/iot/MeterDetailsView/part/MeterDetailsSellGas.vue +190 -190
- package/src/base-client/components/iot/WebmeterAnalysisView/WebmeterAnalysisView.vue +723 -723
- package/src/base-client/components/iot/WebmeterAnalysisView/index.md +48 -48
- package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
- package/src/base-client/components/system/DictionaryDetailsView/index.md +41 -41
- package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +248 -248
- package/src/base-client/components/ticket/EmployeeDetailsView/EmployeeDetailsView.vue +371 -406
- package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +838 -486
- package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +261 -184
- package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +528 -303
- package/src/base-client/plugins/AppData.js +69 -69
- package/src/base-client/plugins/GetLoginInfoService.js +221 -221
- package/src/base-client/plugins/index.js +21 -21
- package/src/bootstrap.js +27 -27
- package/src/components/Ellipsis/Ellipsis.vue +64 -64
- package/src/components/Ellipsis/index.md +38 -38
- package/src/components/NumberInfo/index.md +43 -43
- package/src/components/STable/README.md +341 -341
- package/src/components/Trend/index.md +45 -45
- package/src/components/cache/AKeepAlive.js +172 -172
- package/src/components/checkbox/index.js +7 -7
- package/src/components/index.js +36 -36
- package/src/components/menu/menu.js +273 -273
- package/src/components/setting/Setting.vue +237 -237
- package/src/components/table/advance/AdvanceTable.vue +275 -275
- package/src/components/transition/PageToggleTransition.vue +97 -97
- package/src/layouts/CommonLayout.vue +42 -42
- package/src/layouts/PageLayout.vue +151 -151
- package/src/layouts/SinglePageView.vue +74 -74
- package/src/layouts/header/AdminHeader.vue +109 -109
- package/src/layouts/header/HeaderAvatar.vue +60 -60
- package/src/layouts/header/HeaderNotice.vue +97 -97
- package/src/layouts/tabs/TabsHead.vue +190 -190
- package/src/layouts/tabs/TabsView.vue +355 -355
- package/src/main.js +20 -20
- package/src/mock/goods/index.js +108 -108
- package/src/mock/index.js +12 -12
- package/src/mock/project/index.js +17 -17
- package/src/mock/user/current.js +13 -13
- package/src/mock/user/login.js +39 -39
- package/src/mock/workplace/index.js +15 -15
- package/src/pages/exception/403.vue +25 -25
- package/src/pages/exception/404.vue +25 -25
- package/src/pages/exception/500.vue +25 -25
- package/src/pages/login/Login.vue +194 -194
- package/src/pages/report/ReportTableHome.vue +28 -28
- package/src/pages/resourceManage/resourceManageMain.vue +55 -55
- package/src/pages/system/applyInstallView/Core.vue +570 -570
- package/src/pages/system/applyInstallView/index.vue +34 -34
- package/src/pages/system/dictionary/index.vue +41 -41
- package/src/pages/system/queryParams/index.vue +41 -41
- package/src/router/async/config.async.js +25 -25
- package/src/router/async/router.map.js +59 -59
- package/src/router/guards.js +104 -104
- package/src/router/index.js +27 -27
- package/src/services/api/EmployeeDetailsViewApi.js +3 -1
- package/src/services/api/TicketDetailsViewApi.js +9 -1
- package/src/services/api/common.js +37 -39
- package/src/services/api/restTools.js +23 -23
- package/src/services/dataSource.js +12 -12
- package/src/services/user.js +34 -34
- package/src/store/modules/setting.js +114 -114
- package/src/utils/i18n.js +80 -80
- package/src/utils/indexedDB.js +146 -146
- package/src/utils/request.js +197 -197
- package/src/utils/routerUtil.js +15 -2
- package/tests/unit/ReportTable.spec.js +15 -15
- package/vue.config.js +153 -153
- package/webpack.config.js +12 -12
|
@@ -1,570 +1,570 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="logic-flow-view">
|
|
3
|
-
<!-- 辅助工具栏 -->
|
|
4
|
-
<Control
|
|
5
|
-
class="demo-control"
|
|
6
|
-
v-if="lf"
|
|
7
|
-
:lf="lf"
|
|
8
|
-
@catData="$_catData"
|
|
9
|
-
@catRealData="$_catRealData"
|
|
10
|
-
></Control>
|
|
11
|
-
<a-card
|
|
12
|
-
class="demo-card"
|
|
13
|
-
title="属性预览"
|
|
14
|
-
size="small"
|
|
15
|
-
v-if="Object.keys(selectNodeProperties).length > 0"
|
|
16
|
-
>
|
|
17
|
-
<a-descriptions :column="1" :title="'节点:' + selectNodeProperties.text" >
|
|
18
|
-
<a-descriptions-item v-if="key !== 'formData'" v-for="key of Object.keys(selectNodeProperties)" :key="key" :label="key">
|
|
19
|
-
{{ selectNodeProperties[key] }}
|
|
20
|
-
</a-descriptions-item>
|
|
21
|
-
</a-descriptions>
|
|
22
|
-
|
|
23
|
-
</a-card>
|
|
24
|
-
<!-- 节点面板 -->
|
|
25
|
-
<NodePanel v-if="lf" :lf="lf" :nodeList="nodeList"></NodePanel>
|
|
26
|
-
<!-- 画布 -->
|
|
27
|
-
<div id="LF-view"></div>
|
|
28
|
-
<!-- 步骤节点自定义操作面板 -->
|
|
29
|
-
<AddPanel
|
|
30
|
-
v-if="showAddPanel"
|
|
31
|
-
class="add-panel"
|
|
32
|
-
:style="addPanelStyle"
|
|
33
|
-
:lf="lf"
|
|
34
|
-
:nodeData="addClickNode"
|
|
35
|
-
:node-list="addNodeList"
|
|
36
|
-
@addNodeFinish="hideAddPanel"
|
|
37
|
-
>
|
|
38
|
-
</AddPanel>
|
|
39
|
-
<!-- 属性面板 -->
|
|
40
|
-
<a-drawer
|
|
41
|
-
title="设置节点属性"
|
|
42
|
-
:visible="dialogVisible"
|
|
43
|
-
width="40%"
|
|
44
|
-
@close="closeDialog">
|
|
45
|
-
<PropertyDialog
|
|
46
|
-
v-if="dialogVisible"
|
|
47
|
-
:nodeData="clickNode"
|
|
48
|
-
:lf="lf"
|
|
49
|
-
@setPropertiesFinish="closeDialog"
|
|
50
|
-
></PropertyDialog>
|
|
51
|
-
</a-drawer>
|
|
52
|
-
<!-- 表单构建面板 -->
|
|
53
|
-
<create-simple-form-query
|
|
54
|
-
:visible.sync="createSimpleFormVisible"
|
|
55
|
-
:to-edit-json="createFormNodeJson"
|
|
56
|
-
@saveSimpleFormQueryParams="saveSimpleFormQueryParams"
|
|
57
|
-
/>
|
|
58
|
-
<!-- 数据查看面板 -->
|
|
59
|
-
<a-modal
|
|
60
|
-
title="原始数据"
|
|
61
|
-
v-model="dataVisible"
|
|
62
|
-
width="50%">
|
|
63
|
-
<DataDialog :graphData="graphData"></DataDialog>
|
|
64
|
-
</a-modal>
|
|
65
|
-
<!-- 实际数据查看面板 -->
|
|
66
|
-
<a-modal
|
|
67
|
-
title="实际数据"
|
|
68
|
-
v-model="realDataVisible"
|
|
69
|
-
width="50%"
|
|
70
|
-
@ok="saveData"
|
|
71
|
-
>
|
|
72
|
-
<a-tabs default-active-key="99999">
|
|
73
|
-
<a-tab-pane key="99999" tab="报装流程配置">
|
|
74
|
-
<pre>{{ graphRealData }}</pre>
|
|
75
|
-
</a-tab-pane>
|
|
76
|
-
<a-tab-pane v-for="item of hasFormNodeList" :key="item.id" :tab="'表单:' + item.properties.formData.describe">
|
|
77
|
-
<json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :value="item.properties.formData" :expand-depth="parseInt('100')" style="overflow: auto;max-height: 440px"></json-viewer>
|
|
78
|
-
</a-tab-pane>
|
|
79
|
-
</a-tabs>
|
|
80
|
-
</a-modal>
|
|
81
|
-
</div>
|
|
82
|
-
</template>
|
|
83
|
-
<script>
|
|
84
|
-
import LogicFlow from '@logicflow/core'
|
|
85
|
-
// const LogicFlow = window.LogicFlow
|
|
86
|
-
import { Menu, SelectionSelect, Snapshot } from '@logicflow/extension'
|
|
87
|
-
import '@logicflow/core/dist/style/index.css'
|
|
88
|
-
import '@logicflow/extension/lib/style/index.css'
|
|
89
|
-
import NodePanel from './LFComponents/NodePanel'
|
|
90
|
-
import AddPanel from './LFComponents/AddPanel'
|
|
91
|
-
import Control from './LFComponents/Control'
|
|
92
|
-
import PropertyDialog from './PropertySetting/PropertyDialog'
|
|
93
|
-
import DataDialog from './LFComponents/DataDialog'
|
|
94
|
-
import { nodeList } from './config'
|
|
95
|
-
import { showXml } from '@vue2-client/utils/util'
|
|
96
|
-
import FileSaver from 'file-saver'
|
|
97
|
-
import JsonViewer from 'vue-json-viewer'
|
|
98
|
-
|
|
99
|
-
import {
|
|
100
|
-
registerBackEdge,
|
|
101
|
-
registerConnect,
|
|
102
|
-
registerDownload,
|
|
103
|
-
registerEnd,
|
|
104
|
-
registerPolyline,
|
|
105
|
-
registerPush,
|
|
106
|
-
registerStart,
|
|
107
|
-
registerStep,
|
|
108
|
-
registerTask,
|
|
109
|
-
registerBase
|
|
110
|
-
} from './registerNode'
|
|
111
|
-
|
|
112
|
-
const demoData = require('./data.json')
|
|
113
|
-
|
|
114
|
-
export default {
|
|
115
|
-
name: 'LF',
|
|
116
|
-
components: { NodePanel, AddPanel, Control, PropertyDialog, DataDialog, JsonViewer },
|
|
117
|
-
computed: {
|
|
118
|
-
hasFormNodeList () {
|
|
119
|
-
return this.allNodeList.filter(item => item.type === 'step' && item.properties.formData)
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
data () {
|
|
123
|
-
return {
|
|
124
|
-
lf: null,
|
|
125
|
-
showAddPanel: false,
|
|
126
|
-
addPanelStyle: {
|
|
127
|
-
top: 0,
|
|
128
|
-
left: 0
|
|
129
|
-
},
|
|
130
|
-
nodeData: null,
|
|
131
|
-
addClickNode: null,
|
|
132
|
-
clickNode: null,
|
|
133
|
-
dialogVisible: false,
|
|
134
|
-
graphData: null,
|
|
135
|
-
graphRealData: null,
|
|
136
|
-
dataVisible: false,
|
|
137
|
-
realDataVisible: false,
|
|
138
|
-
config: {
|
|
139
|
-
background: {
|
|
140
|
-
backgroundColor: '#f7f9ff'
|
|
141
|
-
},
|
|
142
|
-
grid: {
|
|
143
|
-
size: 10,
|
|
144
|
-
visible: false
|
|
145
|
-
},
|
|
146
|
-
keyboard: {
|
|
147
|
-
enabled: true
|
|
148
|
-
},
|
|
149
|
-
style: {
|
|
150
|
-
rect: {
|
|
151
|
-
radius: 6
|
|
152
|
-
},
|
|
153
|
-
edgeText: { // 边文本样式
|
|
154
|
-
background: {
|
|
155
|
-
fill: '#fff'
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
edgeTextDraggable: true,
|
|
160
|
-
hoverOutline: false,
|
|
161
|
-
guards: {
|
|
162
|
-
beforeClone (data) {
|
|
163
|
-
console.log('beforeClone', data)
|
|
164
|
-
return true
|
|
165
|
-
},
|
|
166
|
-
beforeDelete (data) {
|
|
167
|
-
// 可以根据data数据判断是否允许删除,允许返回true,不允许返回false
|
|
168
|
-
// 文档: http://logic-flow.org/guide/basic/keyboard.html#%E5%A6%82%E4%BD%95%E9%98%BB%E6%AD%A2%E5%88%A0%E9%99%A4%E6%88%96%E8%80%85%E6%8B%B7%E8%B4%9D%E8%A1%8C%E4%B8%BA
|
|
169
|
-
console.log('beforeDelete', data)
|
|
170
|
-
// _this.$message('不允许删除', 'error')
|
|
171
|
-
return true
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
moveData: {},
|
|
176
|
-
nodeList,
|
|
177
|
-
addNodeList: [],
|
|
178
|
-
baseNodeName: '',
|
|
179
|
-
createSimpleFormVisible: false,
|
|
180
|
-
createFormNodeJson: {},
|
|
181
|
-
nodeFormJsonArray: [],
|
|
182
|
-
allNodeList: [],
|
|
183
|
-
selectNodeProperties: {}
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
mounted () {
|
|
187
|
-
this.$_initLf()
|
|
188
|
-
},
|
|
189
|
-
methods: {
|
|
190
|
-
$_initLf () {
|
|
191
|
-
// 画布配置
|
|
192
|
-
|
|
193
|
-
// 使用插件
|
|
194
|
-
LogicFlow.use(Menu)
|
|
195
|
-
LogicFlow.use(Snapshot)
|
|
196
|
-
LogicFlow.use(SelectionSelect)
|
|
197
|
-
const lf = new LogicFlow({
|
|
198
|
-
...this.config,
|
|
199
|
-
container: document.querySelector('#LF-view'),
|
|
200
|
-
stopMoveGraph: true
|
|
201
|
-
})
|
|
202
|
-
this.lf = lf
|
|
203
|
-
// 1.1.0新增用法
|
|
204
|
-
lf.extension.selectionSelect.openSelectionSelect()
|
|
205
|
-
lf.zoom(false)
|
|
206
|
-
lf.zoom(false)
|
|
207
|
-
lf.zoom(false)
|
|
208
|
-
lf.zoom(false)
|
|
209
|
-
lf.zoom(false)
|
|
210
|
-
// 菜单配置文档:http://logic-flow.org/guide/extension/extension-components.html#%E8%8F%9C%E5%8D%95
|
|
211
|
-
// 重置,增加,节点自由配置(以base节点为示例)
|
|
212
|
-
// lf.setMenuConfig({
|
|
213
|
-
// nodeMenu: [],
|
|
214
|
-
// edgeMenu: []
|
|
215
|
-
// })
|
|
216
|
-
// lf.addMenuConfig({
|
|
217
|
-
// nodeMenu: [
|
|
218
|
-
// {
|
|
219
|
-
// text: '分享',
|
|
220
|
-
// callback () {
|
|
221
|
-
// alert('分享成功!')
|
|
222
|
-
// }
|
|
223
|
-
// },
|
|
224
|
-
// {
|
|
225
|
-
// text: '属性',
|
|
226
|
-
// callback (node) {
|
|
227
|
-
// alert(`
|
|
228
|
-
// 节点id:${node.id}
|
|
229
|
-
// 节点类型:${node.type}
|
|
230
|
-
// 节点坐标:(x: ${node.x}, y: ${node.y})`
|
|
231
|
-
// )
|
|
232
|
-
// }
|
|
233
|
-
// }
|
|
234
|
-
// ],
|
|
235
|
-
// edgeMenu: [
|
|
236
|
-
// {
|
|
237
|
-
// text: '属性',
|
|
238
|
-
// callback (edge) {
|
|
239
|
-
// alert(`
|
|
240
|
-
// 边id:${edge.id}
|
|
241
|
-
// 边类型:${edge.type}
|
|
242
|
-
// 边坐标:(x: ${edge.x}, y: ${edge.y})
|
|
243
|
-
// 源节点id:${edge.sourceNodeId}
|
|
244
|
-
// 目标节点id:${edge.targetNodeId}`
|
|
245
|
-
// )
|
|
246
|
-
// }
|
|
247
|
-
// }
|
|
248
|
-
// ]
|
|
249
|
-
// })
|
|
250
|
-
// 设置主题
|
|
251
|
-
lf.setTheme({
|
|
252
|
-
circle: {
|
|
253
|
-
stroke: '#000000',
|
|
254
|
-
strokeWidth: 1,
|
|
255
|
-
outlineColor: '#88f'
|
|
256
|
-
},
|
|
257
|
-
rect: {
|
|
258
|
-
outlineColor: '#88f',
|
|
259
|
-
strokeWidth: 1
|
|
260
|
-
},
|
|
261
|
-
polygon: {
|
|
262
|
-
strokeWidth: 1
|
|
263
|
-
},
|
|
264
|
-
polyline: {
|
|
265
|
-
stroke: '#000000',
|
|
266
|
-
hoverStroke: '#000000',
|
|
267
|
-
selectedStroke: '#000000',
|
|
268
|
-
outlineColor: '#88f',
|
|
269
|
-
strokeWidth: 1
|
|
270
|
-
},
|
|
271
|
-
nodeText: {
|
|
272
|
-
fontSize: 16,
|
|
273
|
-
color: '#000000'
|
|
274
|
-
},
|
|
275
|
-
baseEdge: {
|
|
276
|
-
stroke: '#999',
|
|
277
|
-
strokeWidth: 2
|
|
278
|
-
},
|
|
279
|
-
edgeText: {
|
|
280
|
-
fontSize: 14,
|
|
281
|
-
color: '#000000',
|
|
282
|
-
background: {
|
|
283
|
-
fill: '#f7f9ff'
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
})
|
|
287
|
-
this.$_registerNode()
|
|
288
|
-
},
|
|
289
|
-
// 自定义
|
|
290
|
-
$_registerNode () {
|
|
291
|
-
registerStart(this.lf)
|
|
292
|
-
registerBase(this.lf, this.clickPlus, this.mouseDownPlus, this.showPropView)
|
|
293
|
-
registerEnd(this.lf)
|
|
294
|
-
registerStep(this.lf, this.clickPlus, this.mouseDownPlus, this.showPropView, this.showSimpleFormView)
|
|
295
|
-
registerPush(this.lf, this.clickPlus, this.mouseDownPlus)
|
|
296
|
-
registerDownload(this.lf)
|
|
297
|
-
registerPolyline(this.lf)
|
|
298
|
-
registerTask(this.lf)
|
|
299
|
-
registerConnect(this.lf)
|
|
300
|
-
|
|
301
|
-
registerBackEdge(this.lf)
|
|
302
|
-
this.$_render()
|
|
303
|
-
},
|
|
304
|
-
$_render () {
|
|
305
|
-
this.lf.render(demoData)
|
|
306
|
-
this.$_LfEvent()
|
|
307
|
-
},
|
|
308
|
-
$_getData () {
|
|
309
|
-
const data = this.lf.getGraphData()
|
|
310
|
-
console.log(JSON.stringify(data))
|
|
311
|
-
},
|
|
312
|
-
showPropView (node) {
|
|
313
|
-
this.$data.clickNode = node
|
|
314
|
-
this.$data.dialogVisible = true
|
|
315
|
-
},
|
|
316
|
-
showSimpleFormView (node) {
|
|
317
|
-
this.$data.clickNode = node
|
|
318
|
-
if (node.properties.formData) {
|
|
319
|
-
this.createFormNodeJson = node.properties.formData
|
|
320
|
-
} else {
|
|
321
|
-
this.createFormNodeJson = {
|
|
322
|
-
group: this.baseNodeName ? this.baseNodeName : '',
|
|
323
|
-
describe: node.text ? node.text.value : ''
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
this.$data.createSimpleFormVisible = true
|
|
327
|
-
},
|
|
328
|
-
$_LfEvent () {
|
|
329
|
-
this.lf.on('node:click', ({ data }) => {
|
|
330
|
-
this.selectNodeProperties = data.properties
|
|
331
|
-
})
|
|
332
|
-
this.lf.on('node:dbclick', ({ data }) => {})
|
|
333
|
-
this.lf.on('edge:dbclick', ({ data }) => {})
|
|
334
|
-
this.lf.on('element:click', () => {
|
|
335
|
-
this.hideAddPanel()
|
|
336
|
-
})
|
|
337
|
-
this.lf.on('edge:add', ({ data }) => {
|
|
338
|
-
console.log('edge:add', data)
|
|
339
|
-
})
|
|
340
|
-
this.lf.on('node:mousemove', ({ data }) => {
|
|
341
|
-
console.log('node:mousemove')
|
|
342
|
-
this.moveData = data
|
|
343
|
-
})
|
|
344
|
-
this.lf.on('blank:click', () => {
|
|
345
|
-
this.hideAddPanel()
|
|
346
|
-
})
|
|
347
|
-
this.lf.on('connection:not-allowed', (data) => {
|
|
348
|
-
this.$message.error(data.msg)
|
|
349
|
-
})
|
|
350
|
-
this.lf.on('node:mousemove', () => {
|
|
351
|
-
console.log('on mousemove')
|
|
352
|
-
})
|
|
353
|
-
},
|
|
354
|
-
clickPlus (e, attributes, addNodeList) {
|
|
355
|
-
e.stopPropagation()
|
|
356
|
-
const { clientX, clientY } = e
|
|
357
|
-
console.log(clientX, clientY)
|
|
358
|
-
this.$data.addPanelStyle.top = (clientY - 180) + 'px'
|
|
359
|
-
this.$data.addPanelStyle.left = (clientX - 260) + 'px'
|
|
360
|
-
this.$data.addNodeList = addNodeList
|
|
361
|
-
this.$data.showAddPanel = true
|
|
362
|
-
this.$data.addClickNode = attributes
|
|
363
|
-
},
|
|
364
|
-
mouseDownPlus (e, attributes) {
|
|
365
|
-
e.stopPropagation()
|
|
366
|
-
console.log('mouseDownPlus', e, attributes)
|
|
367
|
-
},
|
|
368
|
-
hideAddPanel () {
|
|
369
|
-
this.$data.showAddPanel = false
|
|
370
|
-
this.$data.addPanelStyle.top = 0
|
|
371
|
-
this.$data.addPanelStyle.left = 0
|
|
372
|
-
// this.$data.addClickNode = null
|
|
373
|
-
console.warn(this.$data)
|
|
374
|
-
},
|
|
375
|
-
closeDialog () {
|
|
376
|
-
this.$data.dialogVisible = false
|
|
377
|
-
},
|
|
378
|
-
$_catData () {
|
|
379
|
-
this.$data.graphData = this.$data.lf.getGraphData()
|
|
380
|
-
this.$data.dataVisible = true
|
|
381
|
-
},
|
|
382
|
-
$_catRealData () {
|
|
383
|
-
const data = this.$data.lf.getGraphData()
|
|
384
|
-
const nodeMap = {}
|
|
385
|
-
this.allNodeList = []
|
|
386
|
-
let baseNode = null
|
|
387
|
-
for (const node of data.nodes) {
|
|
388
|
-
if (node.type === 'step' && !node.properties.id) {
|
|
389
|
-
if (node.text) {
|
|
390
|
-
this.$message.error('节点[' + node.text.value + ']没有设置ID')
|
|
391
|
-
} else {
|
|
392
|
-
this.$message.error('节点需要设置名称')
|
|
393
|
-
}
|
|
394
|
-
return
|
|
395
|
-
}
|
|
396
|
-
const item = {
|
|
397
|
-
id: node.properties.id,
|
|
398
|
-
type: node.type,
|
|
399
|
-
properties: node.properties,
|
|
400
|
-
name: node.text ? node.text.value : ''
|
|
401
|
-
}
|
|
402
|
-
if (item.type === 'base') {
|
|
403
|
-
baseNode = item
|
|
404
|
-
continue
|
|
405
|
-
}
|
|
406
|
-
nodeMap[node.id] = item
|
|
407
|
-
if (node.properties.id) {
|
|
408
|
-
this.allNodeList[node.properties.id] = item
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
if (!baseNode) {
|
|
412
|
-
this.$message.error('请设置流程根节点[基础]')
|
|
413
|
-
return
|
|
414
|
-
}
|
|
415
|
-
this.allNodeList.shift()
|
|
416
|
-
const submitList = []
|
|
417
|
-
const backList = []
|
|
418
|
-
const skipList = []
|
|
419
|
-
for (const edge of data.edges) {
|
|
420
|
-
const id = nodeMap[edge.sourceNodeId].properties.id
|
|
421
|
-
const toId = nodeMap[edge.targetNodeId].properties.id
|
|
422
|
-
let type
|
|
423
|
-
if (id && toId) {
|
|
424
|
-
if (toId - id === 1) {
|
|
425
|
-
type = 'submit'
|
|
426
|
-
} else if (id - toId === 1) {
|
|
427
|
-
type = 'back'
|
|
428
|
-
} else if (toId - id > 1) {
|
|
429
|
-
type = 'skip'
|
|
430
|
-
} else if (id - toId > 1) {
|
|
431
|
-
this.$message.error('错误的流程连接[id:' + id + ', to_id:' + toId + '],每次只能退回一个步骤')
|
|
432
|
-
return
|
|
433
|
-
} else {
|
|
434
|
-
this.$message.error('错误的流程连接[id:' + id + ', to_id:' + toId + ']')
|
|
435
|
-
return
|
|
436
|
-
}
|
|
437
|
-
const item = {
|
|
438
|
-
id: id,
|
|
439
|
-
to: toId
|
|
440
|
-
}
|
|
441
|
-
if (type === 'submit') {
|
|
442
|
-
submitList.push(item)
|
|
443
|
-
} else if (type === 'back') {
|
|
444
|
-
backList.push(item)
|
|
445
|
-
} else {
|
|
446
|
-
skipList.push(item)
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
this.baseNodeName = baseNode.properties.text
|
|
452
|
-
|
|
453
|
-
let xml = '<?xml version="1.0" encoding="utf-8"?>'
|
|
454
|
-
xml += '<WorkflowDiagram id="' + baseNode.properties.id + '" name="' + baseNode.properties.text + '">'
|
|
455
|
-
|
|
456
|
-
for (const item of baseNode.properties.propArray) {
|
|
457
|
-
xml += '<Var name="' + item.name + '" id="' + item.id + '" description="' + item.description + '" />'
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
xml += '<Actor id="' + baseNode.properties.personId + '" name="' + baseNode.properties.personName + '">'
|
|
461
|
-
|
|
462
|
-
for (const node of this.allNodeList) {
|
|
463
|
-
let personexpression
|
|
464
|
-
if (node.properties.name.length === 1) {
|
|
465
|
-
personexpression = 'R(' + node.properties.name[0] + ')'
|
|
466
|
-
} else if (node.properties.name.length > 1) {
|
|
467
|
-
personexpression = 'RS('
|
|
468
|
-
for (const nameItem of node.properties.name) {
|
|
469
|
-
personexpression += (nameItem + ',')
|
|
470
|
-
}
|
|
471
|
-
personexpression = personexpression.substring(0, personexpression.length - 1)
|
|
472
|
-
personexpression += ')'
|
|
473
|
-
} else {
|
|
474
|
-
personexpression = ''
|
|
475
|
-
}
|
|
476
|
-
let timeoutExp
|
|
477
|
-
if (node.properties.timeout) {
|
|
478
|
-
timeoutExp = 'timeout="HH(' + node.properties.timeout + ')" '
|
|
479
|
-
} else {
|
|
480
|
-
timeoutExp = ''
|
|
481
|
-
}
|
|
482
|
-
const activity = '<Activity id="' + node.id + '" name="' + node.name + '" personexpression="' + personexpression + '" ' + timeoutExp + '/>'
|
|
483
|
-
xml += activity
|
|
484
|
-
}
|
|
485
|
-
xml += '</Actor>'
|
|
486
|
-
xml += '<!-- 报建流程 -->'
|
|
487
|
-
for (const id in submitList) {
|
|
488
|
-
const edge = submitList[id]
|
|
489
|
-
const diversion = '<Diversion id="' + edge.id + '" head="' + edge.id + '" tail="' + edge.to + '" expression="subedp == $提交$" />'
|
|
490
|
-
xml += diversion
|
|
491
|
-
}
|
|
492
|
-
for (const id in skipList) {
|
|
493
|
-
const edge = skipList[id]
|
|
494
|
-
const diversion = '<Diversion id="' + edge.id + '" head="' + edge.id + '" tail="' + edge.to + '" expression="subedp == $跳过$" />'
|
|
495
|
-
xml += diversion
|
|
496
|
-
}
|
|
497
|
-
for (const id in backList) {
|
|
498
|
-
const edge = backList[id]
|
|
499
|
-
const diversion = '<Diversion id="' + edge.to + '" head="' + edge.id + '" tail="' + edge.to + '" expression="subedp == $退回$" />'
|
|
500
|
-
xml += diversion
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
xml += '</WorkflowDiagram>'
|
|
504
|
-
this.$data.graphRealData = showXml(xml)
|
|
505
|
-
this.$data.realDataVisible = true
|
|
506
|
-
},
|
|
507
|
-
saveData () {
|
|
508
|
-
// 存储流程
|
|
509
|
-
const blob = new Blob([this.graphRealData], { type: 'application/xml' })
|
|
510
|
-
FileSaver.saveAs(blob, this.baseNodeName + `.xml`)
|
|
511
|
-
},
|
|
512
|
-
// 存储基础表单配置信息
|
|
513
|
-
saveSimpleFormQueryParams (source) {
|
|
514
|
-
const properties = Object.assign(this.lf.getProperties(this.clickNode.id), {
|
|
515
|
-
formData: source
|
|
516
|
-
})
|
|
517
|
-
this.lf.setProperties(this.clickNode.id, properties)
|
|
518
|
-
this.$message.success('保存表单成功!')
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
</script>
|
|
523
|
-
<style>
|
|
524
|
-
.logic-flow-view {
|
|
525
|
-
height: 100vh;
|
|
526
|
-
position: relative;
|
|
527
|
-
}
|
|
528
|
-
.demo-title{
|
|
529
|
-
text-align: center;
|
|
530
|
-
margin: 20px;
|
|
531
|
-
}
|
|
532
|
-
.demo-control{
|
|
533
|
-
position: absolute;
|
|
534
|
-
top: 50px;
|
|
535
|
-
right: 0;
|
|
536
|
-
z-index: 2;
|
|
537
|
-
}
|
|
538
|
-
.demo-card{
|
|
539
|
-
background-color: rgba(255,255,255,0.2);
|
|
540
|
-
position: absolute;
|
|
541
|
-
width: 250px;
|
|
542
|
-
top: 85px;
|
|
543
|
-
right: 10px;
|
|
544
|
-
z-index: 2;
|
|
545
|
-
}
|
|
546
|
-
#LF-view{
|
|
547
|
-
width: calc(100%);
|
|
548
|
-
height: 100%;
|
|
549
|
-
outline: none;
|
|
550
|
-
}
|
|
551
|
-
.time-plus{
|
|
552
|
-
cursor: pointer;
|
|
553
|
-
}
|
|
554
|
-
.add-panel {
|
|
555
|
-
position: absolute;
|
|
556
|
-
z-index: 11;
|
|
557
|
-
background-color: white;
|
|
558
|
-
padding: 10px 5px;
|
|
559
|
-
}
|
|
560
|
-
.el-drawer__body {
|
|
561
|
-
height: 80%;
|
|
562
|
-
overflow: auto;
|
|
563
|
-
margin-top: -30px;
|
|
564
|
-
z-index: 3;
|
|
565
|
-
}
|
|
566
|
-
.lf-element-text {
|
|
567
|
-
font-weight: bold;
|
|
568
|
-
z-index: 99999;
|
|
569
|
-
}
|
|
570
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="logic-flow-view">
|
|
3
|
+
<!-- 辅助工具栏 -->
|
|
4
|
+
<Control
|
|
5
|
+
class="demo-control"
|
|
6
|
+
v-if="lf"
|
|
7
|
+
:lf="lf"
|
|
8
|
+
@catData="$_catData"
|
|
9
|
+
@catRealData="$_catRealData"
|
|
10
|
+
></Control>
|
|
11
|
+
<a-card
|
|
12
|
+
class="demo-card"
|
|
13
|
+
title="属性预览"
|
|
14
|
+
size="small"
|
|
15
|
+
v-if="Object.keys(selectNodeProperties).length > 0"
|
|
16
|
+
>
|
|
17
|
+
<a-descriptions :column="1" :title="'节点:' + selectNodeProperties.text" >
|
|
18
|
+
<a-descriptions-item v-if="key !== 'formData'" v-for="key of Object.keys(selectNodeProperties)" :key="key" :label="key">
|
|
19
|
+
{{ selectNodeProperties[key] }}
|
|
20
|
+
</a-descriptions-item>
|
|
21
|
+
</a-descriptions>
|
|
22
|
+
|
|
23
|
+
</a-card>
|
|
24
|
+
<!-- 节点面板 -->
|
|
25
|
+
<NodePanel v-if="lf" :lf="lf" :nodeList="nodeList"></NodePanel>
|
|
26
|
+
<!-- 画布 -->
|
|
27
|
+
<div id="LF-view"></div>
|
|
28
|
+
<!-- 步骤节点自定义操作面板 -->
|
|
29
|
+
<AddPanel
|
|
30
|
+
v-if="showAddPanel"
|
|
31
|
+
class="add-panel"
|
|
32
|
+
:style="addPanelStyle"
|
|
33
|
+
:lf="lf"
|
|
34
|
+
:nodeData="addClickNode"
|
|
35
|
+
:node-list="addNodeList"
|
|
36
|
+
@addNodeFinish="hideAddPanel"
|
|
37
|
+
>
|
|
38
|
+
</AddPanel>
|
|
39
|
+
<!-- 属性面板 -->
|
|
40
|
+
<a-drawer
|
|
41
|
+
title="设置节点属性"
|
|
42
|
+
:visible="dialogVisible"
|
|
43
|
+
width="40%"
|
|
44
|
+
@close="closeDialog">
|
|
45
|
+
<PropertyDialog
|
|
46
|
+
v-if="dialogVisible"
|
|
47
|
+
:nodeData="clickNode"
|
|
48
|
+
:lf="lf"
|
|
49
|
+
@setPropertiesFinish="closeDialog"
|
|
50
|
+
></PropertyDialog>
|
|
51
|
+
</a-drawer>
|
|
52
|
+
<!-- 表单构建面板 -->
|
|
53
|
+
<create-simple-form-query
|
|
54
|
+
:visible.sync="createSimpleFormVisible"
|
|
55
|
+
:to-edit-json="createFormNodeJson"
|
|
56
|
+
@saveSimpleFormQueryParams="saveSimpleFormQueryParams"
|
|
57
|
+
/>
|
|
58
|
+
<!-- 数据查看面板 -->
|
|
59
|
+
<a-modal
|
|
60
|
+
title="原始数据"
|
|
61
|
+
v-model="dataVisible"
|
|
62
|
+
width="50%">
|
|
63
|
+
<DataDialog :graphData="graphData"></DataDialog>
|
|
64
|
+
</a-modal>
|
|
65
|
+
<!-- 实际数据查看面板 -->
|
|
66
|
+
<a-modal
|
|
67
|
+
title="实际数据"
|
|
68
|
+
v-model="realDataVisible"
|
|
69
|
+
width="50%"
|
|
70
|
+
@ok="saveData"
|
|
71
|
+
>
|
|
72
|
+
<a-tabs default-active-key="99999">
|
|
73
|
+
<a-tab-pane key="99999" tab="报装流程配置">
|
|
74
|
+
<pre>{{ graphRealData }}</pre>
|
|
75
|
+
</a-tab-pane>
|
|
76
|
+
<a-tab-pane v-for="item of hasFormNodeList" :key="item.id" :tab="'表单:' + item.properties.formData.describe">
|
|
77
|
+
<json-viewer :copyable="{copyText: '复制', copiedText: '已复制'}" :value="item.properties.formData" :expand-depth="parseInt('100')" style="overflow: auto;max-height: 440px"></json-viewer>
|
|
78
|
+
</a-tab-pane>
|
|
79
|
+
</a-tabs>
|
|
80
|
+
</a-modal>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
83
|
+
<script>
|
|
84
|
+
import LogicFlow from '@logicflow/core'
|
|
85
|
+
// const LogicFlow = window.LogicFlow
|
|
86
|
+
import { Menu, SelectionSelect, Snapshot } from '@logicflow/extension'
|
|
87
|
+
import '@logicflow/core/dist/style/index.css'
|
|
88
|
+
import '@logicflow/extension/lib/style/index.css'
|
|
89
|
+
import NodePanel from './LFComponents/NodePanel'
|
|
90
|
+
import AddPanel from './LFComponents/AddPanel'
|
|
91
|
+
import Control from './LFComponents/Control'
|
|
92
|
+
import PropertyDialog from './PropertySetting/PropertyDialog'
|
|
93
|
+
import DataDialog from './LFComponents/DataDialog'
|
|
94
|
+
import { nodeList } from './config'
|
|
95
|
+
import { showXml } from '@vue2-client/utils/util'
|
|
96
|
+
import FileSaver from 'file-saver'
|
|
97
|
+
import JsonViewer from 'vue-json-viewer'
|
|
98
|
+
|
|
99
|
+
import {
|
|
100
|
+
registerBackEdge,
|
|
101
|
+
registerConnect,
|
|
102
|
+
registerDownload,
|
|
103
|
+
registerEnd,
|
|
104
|
+
registerPolyline,
|
|
105
|
+
registerPush,
|
|
106
|
+
registerStart,
|
|
107
|
+
registerStep,
|
|
108
|
+
registerTask,
|
|
109
|
+
registerBase
|
|
110
|
+
} from './registerNode'
|
|
111
|
+
|
|
112
|
+
const demoData = require('./data.json')
|
|
113
|
+
|
|
114
|
+
export default {
|
|
115
|
+
name: 'LF',
|
|
116
|
+
components: { NodePanel, AddPanel, Control, PropertyDialog, DataDialog, JsonViewer },
|
|
117
|
+
computed: {
|
|
118
|
+
hasFormNodeList () {
|
|
119
|
+
return this.allNodeList.filter(item => item.type === 'step' && item.properties.formData)
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
data () {
|
|
123
|
+
return {
|
|
124
|
+
lf: null,
|
|
125
|
+
showAddPanel: false,
|
|
126
|
+
addPanelStyle: {
|
|
127
|
+
top: 0,
|
|
128
|
+
left: 0
|
|
129
|
+
},
|
|
130
|
+
nodeData: null,
|
|
131
|
+
addClickNode: null,
|
|
132
|
+
clickNode: null,
|
|
133
|
+
dialogVisible: false,
|
|
134
|
+
graphData: null,
|
|
135
|
+
graphRealData: null,
|
|
136
|
+
dataVisible: false,
|
|
137
|
+
realDataVisible: false,
|
|
138
|
+
config: {
|
|
139
|
+
background: {
|
|
140
|
+
backgroundColor: '#f7f9ff'
|
|
141
|
+
},
|
|
142
|
+
grid: {
|
|
143
|
+
size: 10,
|
|
144
|
+
visible: false
|
|
145
|
+
},
|
|
146
|
+
keyboard: {
|
|
147
|
+
enabled: true
|
|
148
|
+
},
|
|
149
|
+
style: {
|
|
150
|
+
rect: {
|
|
151
|
+
radius: 6
|
|
152
|
+
},
|
|
153
|
+
edgeText: { // 边文本样式
|
|
154
|
+
background: {
|
|
155
|
+
fill: '#fff'
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
edgeTextDraggable: true,
|
|
160
|
+
hoverOutline: false,
|
|
161
|
+
guards: {
|
|
162
|
+
beforeClone (data) {
|
|
163
|
+
console.log('beforeClone', data)
|
|
164
|
+
return true
|
|
165
|
+
},
|
|
166
|
+
beforeDelete (data) {
|
|
167
|
+
// 可以根据data数据判断是否允许删除,允许返回true,不允许返回false
|
|
168
|
+
// 文档: http://logic-flow.org/guide/basic/keyboard.html#%E5%A6%82%E4%BD%95%E9%98%BB%E6%AD%A2%E5%88%A0%E9%99%A4%E6%88%96%E8%80%85%E6%8B%B7%E8%B4%9D%E8%A1%8C%E4%B8%BA
|
|
169
|
+
console.log('beforeDelete', data)
|
|
170
|
+
// _this.$message('不允许删除', 'error')
|
|
171
|
+
return true
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
moveData: {},
|
|
176
|
+
nodeList,
|
|
177
|
+
addNodeList: [],
|
|
178
|
+
baseNodeName: '',
|
|
179
|
+
createSimpleFormVisible: false,
|
|
180
|
+
createFormNodeJson: {},
|
|
181
|
+
nodeFormJsonArray: [],
|
|
182
|
+
allNodeList: [],
|
|
183
|
+
selectNodeProperties: {}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
mounted () {
|
|
187
|
+
this.$_initLf()
|
|
188
|
+
},
|
|
189
|
+
methods: {
|
|
190
|
+
$_initLf () {
|
|
191
|
+
// 画布配置
|
|
192
|
+
|
|
193
|
+
// 使用插件
|
|
194
|
+
LogicFlow.use(Menu)
|
|
195
|
+
LogicFlow.use(Snapshot)
|
|
196
|
+
LogicFlow.use(SelectionSelect)
|
|
197
|
+
const lf = new LogicFlow({
|
|
198
|
+
...this.config,
|
|
199
|
+
container: document.querySelector('#LF-view'),
|
|
200
|
+
stopMoveGraph: true
|
|
201
|
+
})
|
|
202
|
+
this.lf = lf
|
|
203
|
+
// 1.1.0新增用法
|
|
204
|
+
lf.extension.selectionSelect.openSelectionSelect()
|
|
205
|
+
lf.zoom(false)
|
|
206
|
+
lf.zoom(false)
|
|
207
|
+
lf.zoom(false)
|
|
208
|
+
lf.zoom(false)
|
|
209
|
+
lf.zoom(false)
|
|
210
|
+
// 菜单配置文档:http://logic-flow.org/guide/extension/extension-components.html#%E8%8F%9C%E5%8D%95
|
|
211
|
+
// 重置,增加,节点自由配置(以base节点为示例)
|
|
212
|
+
// lf.setMenuConfig({
|
|
213
|
+
// nodeMenu: [],
|
|
214
|
+
// edgeMenu: []
|
|
215
|
+
// })
|
|
216
|
+
// lf.addMenuConfig({
|
|
217
|
+
// nodeMenu: [
|
|
218
|
+
// {
|
|
219
|
+
// text: '分享',
|
|
220
|
+
// callback () {
|
|
221
|
+
// alert('分享成功!')
|
|
222
|
+
// }
|
|
223
|
+
// },
|
|
224
|
+
// {
|
|
225
|
+
// text: '属性',
|
|
226
|
+
// callback (node) {
|
|
227
|
+
// alert(`
|
|
228
|
+
// 节点id:${node.id}
|
|
229
|
+
// 节点类型:${node.type}
|
|
230
|
+
// 节点坐标:(x: ${node.x}, y: ${node.y})`
|
|
231
|
+
// )
|
|
232
|
+
// }
|
|
233
|
+
// }
|
|
234
|
+
// ],
|
|
235
|
+
// edgeMenu: [
|
|
236
|
+
// {
|
|
237
|
+
// text: '属性',
|
|
238
|
+
// callback (edge) {
|
|
239
|
+
// alert(`
|
|
240
|
+
// 边id:${edge.id}
|
|
241
|
+
// 边类型:${edge.type}
|
|
242
|
+
// 边坐标:(x: ${edge.x}, y: ${edge.y})
|
|
243
|
+
// 源节点id:${edge.sourceNodeId}
|
|
244
|
+
// 目标节点id:${edge.targetNodeId}`
|
|
245
|
+
// )
|
|
246
|
+
// }
|
|
247
|
+
// }
|
|
248
|
+
// ]
|
|
249
|
+
// })
|
|
250
|
+
// 设置主题
|
|
251
|
+
lf.setTheme({
|
|
252
|
+
circle: {
|
|
253
|
+
stroke: '#000000',
|
|
254
|
+
strokeWidth: 1,
|
|
255
|
+
outlineColor: '#88f'
|
|
256
|
+
},
|
|
257
|
+
rect: {
|
|
258
|
+
outlineColor: '#88f',
|
|
259
|
+
strokeWidth: 1
|
|
260
|
+
},
|
|
261
|
+
polygon: {
|
|
262
|
+
strokeWidth: 1
|
|
263
|
+
},
|
|
264
|
+
polyline: {
|
|
265
|
+
stroke: '#000000',
|
|
266
|
+
hoverStroke: '#000000',
|
|
267
|
+
selectedStroke: '#000000',
|
|
268
|
+
outlineColor: '#88f',
|
|
269
|
+
strokeWidth: 1
|
|
270
|
+
},
|
|
271
|
+
nodeText: {
|
|
272
|
+
fontSize: 16,
|
|
273
|
+
color: '#000000'
|
|
274
|
+
},
|
|
275
|
+
baseEdge: {
|
|
276
|
+
stroke: '#999',
|
|
277
|
+
strokeWidth: 2
|
|
278
|
+
},
|
|
279
|
+
edgeText: {
|
|
280
|
+
fontSize: 14,
|
|
281
|
+
color: '#000000',
|
|
282
|
+
background: {
|
|
283
|
+
fill: '#f7f9ff'
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
this.$_registerNode()
|
|
288
|
+
},
|
|
289
|
+
// 自定义
|
|
290
|
+
$_registerNode () {
|
|
291
|
+
registerStart(this.lf)
|
|
292
|
+
registerBase(this.lf, this.clickPlus, this.mouseDownPlus, this.showPropView)
|
|
293
|
+
registerEnd(this.lf)
|
|
294
|
+
registerStep(this.lf, this.clickPlus, this.mouseDownPlus, this.showPropView, this.showSimpleFormView)
|
|
295
|
+
registerPush(this.lf, this.clickPlus, this.mouseDownPlus)
|
|
296
|
+
registerDownload(this.lf)
|
|
297
|
+
registerPolyline(this.lf)
|
|
298
|
+
registerTask(this.lf)
|
|
299
|
+
registerConnect(this.lf)
|
|
300
|
+
|
|
301
|
+
registerBackEdge(this.lf)
|
|
302
|
+
this.$_render()
|
|
303
|
+
},
|
|
304
|
+
$_render () {
|
|
305
|
+
this.lf.render(demoData)
|
|
306
|
+
this.$_LfEvent()
|
|
307
|
+
},
|
|
308
|
+
$_getData () {
|
|
309
|
+
const data = this.lf.getGraphData()
|
|
310
|
+
console.log(JSON.stringify(data))
|
|
311
|
+
},
|
|
312
|
+
showPropView (node) {
|
|
313
|
+
this.$data.clickNode = node
|
|
314
|
+
this.$data.dialogVisible = true
|
|
315
|
+
},
|
|
316
|
+
showSimpleFormView (node) {
|
|
317
|
+
this.$data.clickNode = node
|
|
318
|
+
if (node.properties.formData) {
|
|
319
|
+
this.createFormNodeJson = node.properties.formData
|
|
320
|
+
} else {
|
|
321
|
+
this.createFormNodeJson = {
|
|
322
|
+
group: this.baseNodeName ? this.baseNodeName : '',
|
|
323
|
+
describe: node.text ? node.text.value : ''
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
this.$data.createSimpleFormVisible = true
|
|
327
|
+
},
|
|
328
|
+
$_LfEvent () {
|
|
329
|
+
this.lf.on('node:click', ({ data }) => {
|
|
330
|
+
this.selectNodeProperties = data.properties
|
|
331
|
+
})
|
|
332
|
+
this.lf.on('node:dbclick', ({ data }) => {})
|
|
333
|
+
this.lf.on('edge:dbclick', ({ data }) => {})
|
|
334
|
+
this.lf.on('element:click', () => {
|
|
335
|
+
this.hideAddPanel()
|
|
336
|
+
})
|
|
337
|
+
this.lf.on('edge:add', ({ data }) => {
|
|
338
|
+
console.log('edge:add', data)
|
|
339
|
+
})
|
|
340
|
+
this.lf.on('node:mousemove', ({ data }) => {
|
|
341
|
+
console.log('node:mousemove')
|
|
342
|
+
this.moveData = data
|
|
343
|
+
})
|
|
344
|
+
this.lf.on('blank:click', () => {
|
|
345
|
+
this.hideAddPanel()
|
|
346
|
+
})
|
|
347
|
+
this.lf.on('connection:not-allowed', (data) => {
|
|
348
|
+
this.$message.error(data.msg)
|
|
349
|
+
})
|
|
350
|
+
this.lf.on('node:mousemove', () => {
|
|
351
|
+
console.log('on mousemove')
|
|
352
|
+
})
|
|
353
|
+
},
|
|
354
|
+
clickPlus (e, attributes, addNodeList) {
|
|
355
|
+
e.stopPropagation()
|
|
356
|
+
const { clientX, clientY } = e
|
|
357
|
+
console.log(clientX, clientY)
|
|
358
|
+
this.$data.addPanelStyle.top = (clientY - 180) + 'px'
|
|
359
|
+
this.$data.addPanelStyle.left = (clientX - 260) + 'px'
|
|
360
|
+
this.$data.addNodeList = addNodeList
|
|
361
|
+
this.$data.showAddPanel = true
|
|
362
|
+
this.$data.addClickNode = attributes
|
|
363
|
+
},
|
|
364
|
+
mouseDownPlus (e, attributes) {
|
|
365
|
+
e.stopPropagation()
|
|
366
|
+
console.log('mouseDownPlus', e, attributes)
|
|
367
|
+
},
|
|
368
|
+
hideAddPanel () {
|
|
369
|
+
this.$data.showAddPanel = false
|
|
370
|
+
this.$data.addPanelStyle.top = 0
|
|
371
|
+
this.$data.addPanelStyle.left = 0
|
|
372
|
+
// this.$data.addClickNode = null
|
|
373
|
+
console.warn(this.$data)
|
|
374
|
+
},
|
|
375
|
+
closeDialog () {
|
|
376
|
+
this.$data.dialogVisible = false
|
|
377
|
+
},
|
|
378
|
+
$_catData () {
|
|
379
|
+
this.$data.graphData = this.$data.lf.getGraphData()
|
|
380
|
+
this.$data.dataVisible = true
|
|
381
|
+
},
|
|
382
|
+
$_catRealData () {
|
|
383
|
+
const data = this.$data.lf.getGraphData()
|
|
384
|
+
const nodeMap = {}
|
|
385
|
+
this.allNodeList = []
|
|
386
|
+
let baseNode = null
|
|
387
|
+
for (const node of data.nodes) {
|
|
388
|
+
if (node.type === 'step' && !node.properties.id) {
|
|
389
|
+
if (node.text) {
|
|
390
|
+
this.$message.error('节点[' + node.text.value + ']没有设置ID')
|
|
391
|
+
} else {
|
|
392
|
+
this.$message.error('节点需要设置名称')
|
|
393
|
+
}
|
|
394
|
+
return
|
|
395
|
+
}
|
|
396
|
+
const item = {
|
|
397
|
+
id: node.properties.id,
|
|
398
|
+
type: node.type,
|
|
399
|
+
properties: node.properties,
|
|
400
|
+
name: node.text ? node.text.value : ''
|
|
401
|
+
}
|
|
402
|
+
if (item.type === 'base') {
|
|
403
|
+
baseNode = item
|
|
404
|
+
continue
|
|
405
|
+
}
|
|
406
|
+
nodeMap[node.id] = item
|
|
407
|
+
if (node.properties.id) {
|
|
408
|
+
this.allNodeList[node.properties.id] = item
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (!baseNode) {
|
|
412
|
+
this.$message.error('请设置流程根节点[基础]')
|
|
413
|
+
return
|
|
414
|
+
}
|
|
415
|
+
this.allNodeList.shift()
|
|
416
|
+
const submitList = []
|
|
417
|
+
const backList = []
|
|
418
|
+
const skipList = []
|
|
419
|
+
for (const edge of data.edges) {
|
|
420
|
+
const id = nodeMap[edge.sourceNodeId].properties.id
|
|
421
|
+
const toId = nodeMap[edge.targetNodeId].properties.id
|
|
422
|
+
let type
|
|
423
|
+
if (id && toId) {
|
|
424
|
+
if (toId - id === 1) {
|
|
425
|
+
type = 'submit'
|
|
426
|
+
} else if (id - toId === 1) {
|
|
427
|
+
type = 'back'
|
|
428
|
+
} else if (toId - id > 1) {
|
|
429
|
+
type = 'skip'
|
|
430
|
+
} else if (id - toId > 1) {
|
|
431
|
+
this.$message.error('错误的流程连接[id:' + id + ', to_id:' + toId + '],每次只能退回一个步骤')
|
|
432
|
+
return
|
|
433
|
+
} else {
|
|
434
|
+
this.$message.error('错误的流程连接[id:' + id + ', to_id:' + toId + ']')
|
|
435
|
+
return
|
|
436
|
+
}
|
|
437
|
+
const item = {
|
|
438
|
+
id: id,
|
|
439
|
+
to: toId
|
|
440
|
+
}
|
|
441
|
+
if (type === 'submit') {
|
|
442
|
+
submitList.push(item)
|
|
443
|
+
} else if (type === 'back') {
|
|
444
|
+
backList.push(item)
|
|
445
|
+
} else {
|
|
446
|
+
skipList.push(item)
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
this.baseNodeName = baseNode.properties.text
|
|
452
|
+
|
|
453
|
+
let xml = '<?xml version="1.0" encoding="utf-8"?>'
|
|
454
|
+
xml += '<WorkflowDiagram id="' + baseNode.properties.id + '" name="' + baseNode.properties.text + '">'
|
|
455
|
+
|
|
456
|
+
for (const item of baseNode.properties.propArray) {
|
|
457
|
+
xml += '<Var name="' + item.name + '" id="' + item.id + '" description="' + item.description + '" />'
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
xml += '<Actor id="' + baseNode.properties.personId + '" name="' + baseNode.properties.personName + '">'
|
|
461
|
+
|
|
462
|
+
for (const node of this.allNodeList) {
|
|
463
|
+
let personexpression
|
|
464
|
+
if (node.properties.name.length === 1) {
|
|
465
|
+
personexpression = 'R(' + node.properties.name[0] + ')'
|
|
466
|
+
} else if (node.properties.name.length > 1) {
|
|
467
|
+
personexpression = 'RS('
|
|
468
|
+
for (const nameItem of node.properties.name) {
|
|
469
|
+
personexpression += (nameItem + ',')
|
|
470
|
+
}
|
|
471
|
+
personexpression = personexpression.substring(0, personexpression.length - 1)
|
|
472
|
+
personexpression += ')'
|
|
473
|
+
} else {
|
|
474
|
+
personexpression = ''
|
|
475
|
+
}
|
|
476
|
+
let timeoutExp
|
|
477
|
+
if (node.properties.timeout) {
|
|
478
|
+
timeoutExp = 'timeout="HH(' + node.properties.timeout + ')" '
|
|
479
|
+
} else {
|
|
480
|
+
timeoutExp = ''
|
|
481
|
+
}
|
|
482
|
+
const activity = '<Activity id="' + node.id + '" name="' + node.name + '" personexpression="' + personexpression + '" ' + timeoutExp + '/>'
|
|
483
|
+
xml += activity
|
|
484
|
+
}
|
|
485
|
+
xml += '</Actor>'
|
|
486
|
+
xml += '<!-- 报建流程 -->'
|
|
487
|
+
for (const id in submitList) {
|
|
488
|
+
const edge = submitList[id]
|
|
489
|
+
const diversion = '<Diversion id="' + edge.id + '" head="' + edge.id + '" tail="' + edge.to + '" expression="subedp == $提交$" />'
|
|
490
|
+
xml += diversion
|
|
491
|
+
}
|
|
492
|
+
for (const id in skipList) {
|
|
493
|
+
const edge = skipList[id]
|
|
494
|
+
const diversion = '<Diversion id="' + edge.id + '" head="' + edge.id + '" tail="' + edge.to + '" expression="subedp == $跳过$" />'
|
|
495
|
+
xml += diversion
|
|
496
|
+
}
|
|
497
|
+
for (const id in backList) {
|
|
498
|
+
const edge = backList[id]
|
|
499
|
+
const diversion = '<Diversion id="' + edge.to + '" head="' + edge.id + '" tail="' + edge.to + '" expression="subedp == $退回$" />'
|
|
500
|
+
xml += diversion
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
xml += '</WorkflowDiagram>'
|
|
504
|
+
this.$data.graphRealData = showXml(xml)
|
|
505
|
+
this.$data.realDataVisible = true
|
|
506
|
+
},
|
|
507
|
+
saveData () {
|
|
508
|
+
// 存储流程
|
|
509
|
+
const blob = new Blob([this.graphRealData], { type: 'application/xml' })
|
|
510
|
+
FileSaver.saveAs(blob, this.baseNodeName + `.xml`)
|
|
511
|
+
},
|
|
512
|
+
// 存储基础表单配置信息
|
|
513
|
+
saveSimpleFormQueryParams (source) {
|
|
514
|
+
const properties = Object.assign(this.lf.getProperties(this.clickNode.id), {
|
|
515
|
+
formData: source
|
|
516
|
+
})
|
|
517
|
+
this.lf.setProperties(this.clickNode.id, properties)
|
|
518
|
+
this.$message.success('保存表单成功!')
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
</script>
|
|
523
|
+
<style>
|
|
524
|
+
.logic-flow-view {
|
|
525
|
+
height: 100vh;
|
|
526
|
+
position: relative;
|
|
527
|
+
}
|
|
528
|
+
.demo-title{
|
|
529
|
+
text-align: center;
|
|
530
|
+
margin: 20px;
|
|
531
|
+
}
|
|
532
|
+
.demo-control{
|
|
533
|
+
position: absolute;
|
|
534
|
+
top: 50px;
|
|
535
|
+
right: 0;
|
|
536
|
+
z-index: 2;
|
|
537
|
+
}
|
|
538
|
+
.demo-card{
|
|
539
|
+
background-color: rgba(255,255,255,0.2);
|
|
540
|
+
position: absolute;
|
|
541
|
+
width: 250px;
|
|
542
|
+
top: 85px;
|
|
543
|
+
right: 10px;
|
|
544
|
+
z-index: 2;
|
|
545
|
+
}
|
|
546
|
+
#LF-view{
|
|
547
|
+
width: calc(100%);
|
|
548
|
+
height: 100%;
|
|
549
|
+
outline: none;
|
|
550
|
+
}
|
|
551
|
+
.time-plus{
|
|
552
|
+
cursor: pointer;
|
|
553
|
+
}
|
|
554
|
+
.add-panel {
|
|
555
|
+
position: absolute;
|
|
556
|
+
z-index: 11;
|
|
557
|
+
background-color: white;
|
|
558
|
+
padding: 10px 5px;
|
|
559
|
+
}
|
|
560
|
+
.el-drawer__body {
|
|
561
|
+
height: 80%;
|
|
562
|
+
overflow: auto;
|
|
563
|
+
margin-top: -30px;
|
|
564
|
+
z-index: 3;
|
|
565
|
+
}
|
|
566
|
+
.lf-element-text {
|
|
567
|
+
font-weight: bold;
|
|
568
|
+
z-index: 99999;
|
|
569
|
+
}
|
|
570
|
+
</style>
|