NodePropertyPanel.vue
11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<template>
<div>
<!-- 流程属性 -->
<el-collapse v-model="activeNames" accordion>
<el-collapse-item name="1">
<template slot="title">
<div class="title">
<i class="header-icon el-icon-setting"></i>
<span>基本设置</span>
</div>
</template>
<div>
<el-form label-position="right" label-width="70px">
<el-form-item label="节点类型">
<el-input v-model="localFormData.type" disabled></el-input>
</el-form-item>
<el-form-item label="ID">
<el-input v-model="localFormData.id" @input="updateId"></el-input>
</el-form-item>
<el-form-item label="名称">
<el-input v-model="localFormData.name " @input="updateName"></el-input>
</el-form-item>
<el-form-item v-if="localFormData.type==='bpmn:SequenceFlow'" label="分支条件">
<el-input v-model="localFormData.sequenceFlow" @input="updateSequenceFlow"></el-input>
</el-form-item>
</el-form>
</div>
</el-collapse-item>
<el-collapse-item name="2">
<template slot="title">
<div class="title">
<i class="header-icon el-icon-setting"></i>
<span>执行监听</span>
</div>
</template>
<div>
<div style="margin: 10px 3%;float: right">
<el-button size="mini" plain @click="showEventDialogMethod">添加</el-button>
</div>
<el-table
border :data="listenerTable"
style="width: 93%;margin: 0 auto">
<el-table-column align="center" prop="event"
label="事件">
</el-table-column>
<el-table-column align="center" prop="type" :show-overflow-tooltip="true"
label="类型">
</el-table-column>
<el-table-column align="center" prop="class" :show-overflow-tooltip="true"
label="实现">
</el-table-column>
<el-table-column align="center"
label="操作">
<template slot-scope="scope">
<div>
<i class="el-icon-delete" @click="deleteEvent(scope.$index)"></i>
</div>
</template>
</el-table-column>
</el-table>
</div>
</el-collapse-item>
<el-collapse-item name="3" v-if="localFormData.type=='bpmn:UserTask'" >
<template slot="title">
<div class="title">
<i class="header-icon el-icon-setting"></i>
<span>权限设置</span>
</div>
</template>
<div>
<el-form style="margin-top: 25px" label-position="right" label-width="90px">
<el-form-item label="用户类型:">
<el-select v-model="localFormData.userType" placeholder="请选择" @change="changeUserType" style="width: 90%">
<el-option value="assignee" label="指定人员"></el-option>
<el-option value="candidateUsers" label="候选人员"></el-option>
<el-option value="candidateGroups" label="角色/岗位"></el-option>
</el-select>
</el-form-item>
<el-form-item label="指定人员" v-if="localFormData.userType === 'assignee'">
<el-input placeholder="请输入内容" v-model="localFormData.assignee" @input="(value) => addUser({assignee: value})" style="width: 90%">
<template slot="append">
<div class="icon-div">
<i class="el-icon-user" @click="showUserDialogMethod" />
<!-- <div role="separator" class="ant-divider ant-divider-vertical"></div>-->
<!-- <i class="el-icon-c-scale-to-original" />-->
</div>
</template>
</el-input>
</el-form-item>
<el-form-item label="候选人员" v-else-if="localFormData.userType === 'candidateUsers'">
<el-input placeholder="请输入内容" v-model="localFormData.candidateUsers" @input="(value) => addUser({candidateUsers: value})" style="width: 90%">
<template slot="append">
<div class="icon-div">
<i class="el-icon-user" @click="showUserDialogMethod" />
<!-- <div role="separator" class="ant-divider ant-divider-vertical"></div>-->
<!-- <i class="el-icon-c-scale-to-original" />-->
</div>
</template>
</el-input>
</el-form-item>
<el-form-item label="角色/岗位" v-else-if="localFormData.userType === 'candidateGroups'">
<el-input placeholder="请输入内容" v-model="localFormData.candidateGroups" @input="(value) => addUser({candidateGroups: value})" style="width: 90%">
<template slot="append">
<div class="icon-div">
<i class="el-icon-user" @click="showUserDialogMethod" />
<!-- <div role="separator" class="ant-divider ant-divider-vertical"></div>-->
<!-- <i class="el-icon-c-scale-to-original" />-->
</div>
</template>
</el-input>
</el-form-item>
</el-form>
</div>
</el-collapse-item>
</el-collapse>
<EventListenerDialog @commitEventForm="commitEventForm"
:dialogFormVisibleBool="showEventDialog"
:formData="eventFormData" :nodeElement="nodeElement" :modeler="modeler" :listenerTable="listenerTable"></EventListenerDialog>
<UserSelectDialog @commitUserForm="commitUserForm"
:type="localFormData.userType"
:dialogFormVisibleBool="showUserDialog"
:formData="userFormData"
:nodeElement="nodeElement"
:modeler="modeler"></UserSelectDialog>
</div>
</template>
<script>
import EventListenerDialog from "./dialog/EventListenerDialog"
import UserSelectDialog from "./dialog/UserSelectDialog"
export default {
name: "NodePropertyPanel",
data() {
return {
activeNames: ['1'],
listenerTable: [],
showEventDialog: false,
showUserDialog: false,
eventFormData: {},
userFormData: {}
}
},
components: {
EventListenerDialog,UserSelectDialog
},
props: {
modeler: {
type: Object,
required: true
},
nodeElement: {
type: Object,
required: true
},
formData:{
type: Object,
required: true
}
},
computed:{
localFormData:{
get(){
return this.formData
}
}
},
mounted() {
const that = this
if (this.nodeElement.businessObject
&& this.nodeElement.businessObject.extensionElements
&& this.nodeElement.businessObject.extensionElements.values) {
// 根据xml 组合当前节点的监听数据
that.listenerTable = this.nodeElement.businessObject.extensionElements.values.filter(
(item) => {
if (item.$type === 'activiti:ExecutionListener') {
item.type = Object.keys(item)[1]
item.class = item[Object.keys(item)[1]]
return true;
}
}
)
}
},
watch:{
nodeElement:{
handler(){
if(this.nodeElement.type==="bpmn:StartEvent"){
this.updateName("开始");
}
if(this.nodeElement.type==="bpmn:EndEvent"){
this.updateName("结束");
}
}
}
},
methods: {
updateProperties(properties){
this.modeler.get("modeling").updateProperties(this.nodeElement, properties);
},
updateId(name) {
this.updateProperties({id: name});
},
updateName(name) {
this.updateProperties({name: name});
},
changeUserType() {
},
updateSequenceFlow(val){
let newCondition = this.modeler.get("moddle").create('bpmn:FormalExpression', {
body: val
});
this.updateProperties({conditionExpression:newCondition});
},
addUser(properties){
this.updateProperties(properties);
Object.assign(properties, {
userType: Object.keys(properties)[0]
});
console.log(properties)
this.$emit('modifyFormData',properties);
},
showEventDialogMethod(){
this.showEventDialog = true;
this.eventFormData= {
event:"start",
type:"class"
}
},
showUserDialogMethod(){
this.showUserDialog = true;
this.eventFormData= {
event:"start",
type:"class"
}
},
deleteEvent(index){
const data = this.listenerTable[index]
if (this.nodeElement.businessObject
&& this.nodeElement.businessObject.extensionElements
&& this.nodeElement.businessObject.extensionElements.values) {
// 排除全局监听类型 并且class为删除的class的数据。
const filterArr = this.nodeElement.businessObject.extensionElements.values.filter(
(item) => !(item.$type === 'activiti:ExecutionListener' && item.event === data.event && data.class === item[data.type])
)
// 刷新数据
let extensionElements = this.modeler.get("bpmnFactory").create("bpmn:ExtensionElements", {values: filterArr});
this.modeler.get("modeling").updateProperties(this.nodeElement, {extensionElements});
}
this.listenerTable.splice(index, 1);
},
commitEventForm(from){
this.showEventDialog = false
if (from != null) {
// 筛选原来数组里是不是有跟刚提交的数据一模一样的数据
this.listenerTable.push(from)
}
},
commitUserForm(from){
this.showUserDialog = false
if (from != null) {
console.log(from)
// 筛选原来数组里是不是有跟刚提交的数据一模一样的数据
// this.listenerTable.push(from)
}
}
}
}
</script>
<style scoped>
.bpmnclass .title span{
font-weight: bold;
margin-left: 5px;
}
.bpmnclass .el-select .el-input .el-select__caret{
margin-top: 5px;
}
.bpmnclass .el-input__icon{
height: 20px !important;
line-height: 20px !important;
}
.bpmnclass .el-input-group__append{
padding: 0 5px !important;
}
.bpmnclass .icon-div{
font-size: 1.2em;
font-weight: bold !important;
width: 100%;
}
.bpmnclass .icon-div i{
padding: 5px;
}
.bpmnclass .icon-div i:hover{
cursor:pointer;
}
.bpmnclass .ant-divider-vertical {
position: relative;
top: -0.08em;
display: inline-block;
width: 2px;
height: 0.9em;
/*margin: 0 8px;*/
vertical-align: middle;
}
.bpmnclass .ant-divider {
box-sizing: border-box;
margin: 0;
padding: 0;
color: rgba(0, 0, 0, 0.65);
font-size: 14px;
font-variant: tabular-nums;
line-height: 1.5;
list-style: none;
/*font-feature-settings: "tnum";*/
background: #e8e8e8;
}
</style>