ConditionScriptEdit.vue
14.5 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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<template>
<el-container>
<el-dialog
width="70%"
:title="title"
:visible.sync="dialogVisible"
:before-close="handleClose"
append-to-body
top="8vh"
:close-on-click-modal="false"
>
<el-form
:model="formData"
data-vv-scope="templateForm"
label-position="left"
>
<el-row>
<el-col :span="24">
<ht-form-item label="脚本类型" label-width="120px">
<!-- <el-radio
v-model="formData.type"
:label="2"
>人员脚本</el-radio
> -->
<el-link :underline="false">人员脚本</el-link>
<el-tooltip class="item" effect="dark" placement="top-end">
<div slot="content">
<span
>人员脚本用于流程设计中节点人员设置,需要新增后端方法则<br />实现IUserScript接口或者在已实现的接口下进行添加</span
>
</div>
<i class="icon-my-todo-comment" style="margin-left:3px"></i>
</el-tooltip>
</ht-form-item>
</el-col>
<el-col :span="24">
<ht-form-item label="脚本所在类" label-width="120px">
<ht-select
v-if="status !== 'notEdit'"
v-model="formData.className"
:options="className"
:props="{key: 'value', value: 'value'}"
:validate="{required: true}"
@change="classNameChange()"
style="width: 70%"
/>
<ht-input
v-else
disabled
v-model="formData.className"
:validate="{required: true}"
/>
</ht-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<ht-form-item label="类实例名" label-width="120px">
<ht-input
disabled
v-model="formData.classInsName"
style="width: 70%"
/>
</ht-form-item>
</el-col>
<el-col :span="24">
<ht-form-item label="方法名称" label-width="120px">
<ht-select
v-if="status !== 'notEdit'"
v-model="formData.methodName"
:options="methodName"
:props="{key: 'value', value: 'value'}"
:validate="{required: true}"
style="width: 70%"
placeholder="请选择"
@change="methodNameChange"
/>
<ht-input v-else disabled v-model="formData.methodName" />
</ht-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<ht-form-item label="返回值类型" label-width="120px">
<ht-input
disabled
v-model="formData.returnType"
style="width: 70%"
/>
</ht-form-item>
</el-col>
<el-col :span="24">
<ht-form-item label="是否有效" label-width="120px">
<ht-select
v-if="status != 'notEdit'"
:options="isEnable"
v-model="formData.enable"
/>
<span v-else-if="formData.enable == 0">无效</span>
<span v-else-if="formData.enable == 1">有效</span>
</ht-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<ht-form-item label="方法描述" label-width="120px">
<ht-input
type="textarea"
v-if="status != 'notEdit'"
v-model="formData.methodDesc"
:rows="3"
:maxlength="200"
:showWordLimit="true"
style="width: 100%"
resize="none"
/>
<ht-input v-else disabled v-model="formData.methodDesc" />
</ht-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<ht-form-item label="参数信息" label-width="120px">
<table
v-if="status != 'notEdit'"
class="form-table"
cellspacing="0"
cellpadding="0"
border="0.5"
>
<tbody>
<tr class="tr_header">
<th width="100px" style="text-align: center">参数信息:</th>
<th width="120px" style="text-align: center">参数类型:</th>
<th width="200px" style="text-align: center">参数说明:</th>
<th width="120px" style="text-align: center">选择器:</th>
<th width="100px" style="text-align: center">绑定字段:</th>
</tr>
<tr v-for="(item, index) in argument" :key="index">
<td>
<span>{{ item.paraName }}</span>
</td>
<td>
<span>{{ item.paraType }}</span>
</td>
<td>
<ht-input
v-model="item.paraDesc"
:maxlength="50"
:showWordLimit="true"
/>
</td>
<td>
<span>
<el-select
@change="selectorChange"
v-model="item.paraCt"
placeholder="请选择"
:clearable="true"
style="width:100%"
>
<el-option-group
v-for="group in options"
:key="group.label"
:label="group.label"
>
<el-option
v-for="item in group.options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-option-group>
</el-select>
</span>
</td>
<td>
<el-select
@change="selectorChange"
v-model="item.paraCtBindKey"
placeholder="请选择"
:clearable="true"
>
<el-option
v-for="item in field"
:key="item.field"
:label="item.comment"
:value="item.field"
>
</el-option>
</el-select>
</td>
</tr>
</tbody>
</table>
<span v-else>{{ formData.argument }}</span>
</ht-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="handleClose">取 消</el-button>
<ht-submit-button
:url="saveUrl()"
:model="formData"
:is-submit="isSubmit"
scope-name="templateForm"
@before-save-data="beforeSaveData()"
@after-save-data="afterSaveData()"
>保存</ht-submit-button
>
</div>
</el-dialog>
</el-container>
</template>
<script>
import flow from '@/api/flow.js'
export default {
props: ['editData'],
data() {
return {
isEnable: [
{key: 0, value: '无效'},
{key: 1, value: '有效'}
],
className: [],
title: '',
dialogVisible: false,
formData: {
type: 2,
className: '',
classInsName: '',
enable: 1,
methodDesc: '',
methodName: '',
returnType: '',
argument: [{paraName: '', paraType: '', paraDesc: ''}]
},
isSubmit: false,
status: '',
argument: [],
options: [
{
label: '基本选择器',
options: [
{
value: 'base:user-selector',
label: '用户选择器'
},
{
value: 'base:org-selector',
label: '组织选择器'
},
{
value: 'base:role-selector',
label: '角色选择器'
},
{
value: 'base:pos-selector',
label: '岗位选择器'
},
{
value: 'base:job-selector',
label: '职务选择器'
},
{
value: 'base:dem-selector',
label: '维度选择器'
}
]
},
{
label: '',
options: [{value: '', label: ''}]
}
],
field: [],
linkageData: [],
methodName: [],
methodChangeData: []
}
},
methods: {
//打开侧边栏
handleOpen() {
this.dialogVisible = true
if (this.editData.data) {
this.formData = this.editData.data
this.argument = JSON.parse(this.editData.data.argument)
}
if (this.editData.status) {
this.status = this.editData.status
}
if (!this.editData.id) {
this.getConditionScriptEditData('')
}
this.title = this.editData.title
this.getClassName()
},
//获取选择器
getConditionScriptEditData(id) {
flow.getConditionScriptEditData(id).then(resp => {
this.linkageData = resp.data
let optionsLabel = resp.data.optionJson[0].lable
let options = []
for (let i = 0; i < resp.data.optionJson[0].option.length; i++) {
let value = resp.data.optionJson[0].option[i].value
let label = resp.data.optionJson[0].option[i].name
options.push({value, label})
}
this.options[1].label = optionsLabel
this.options[1].options = options
})
},
//获取选定选择器的字段
selectorChange(row) {
switch (row) {
case 'base:user-selector':
this.field = [
{comment: 'id', field: 'id'},
{comment: 'fullname', field: 'fullname'},
{comment: 'account', field: 'account'}
]
break
case 'base:org-selector':
this.field = [
{comment: 'id', field: 'id'},
{comment: 'name', field: 'name'},
{comment: 'code', field: 'code'}
]
break
case 'base:role-selector':
this.field = [
{comment: 'id', field: 'id'},
{comment: 'name', field: 'name'},
{comment: 'code', field: 'code'}
]
break
case 'base:pos-selector':
this.field = [
{comment: 'id', field: 'id'},
{comment: 'name', field: 'name'},
{comment: 'code', field: 'code'}
]
break
case 'base:job-selector':
this.field = [
{comment: 'id', field: 'id'},
{comment: 'name', field: 'name'},
{comment: 'code', field: 'code'}
]
break
case 'base:dem-selector':
this.field = [
{comment: 'id', field: 'id'},
{comment: 'name', field: 'name'},
{comment: 'code', field: 'code'}
]
break
}
for (let i = 0; i < this.linkageData.optionJson[0].option.length; i++) {
if (row == this.linkageData.optionJson[0].option[i].value) {
this.field = JSON.parse(
this.linkageData.optionJson[0].option[i].resultfield
)
return
}
}
},
//关闭侧边栏
handleClose() {
this.dialogVisible = false
this.field = []
this.status = ''
this.argument = []
this.formData = {
type: 2,
className: '',
classInsName: '',
enable: 1,
methodDesc: '',
methodName: '',
returnType: '',
argument: [{paraName: '', paraType: '', paraDesc: ''}]
}
this.$emit('loadData')
},
saveUrl() {
return window.context.bpmRunTime + '/runtime/conditionScript/v1/save'
},
beforeSaveData() {
this.formData.argument = JSON.stringify(this.argument)
this.isSubmit = true
},
afterSaveData() {
this.handleClose()
},
//方法切换
methodNameChange(row) {
for (let i = 0; i < this.methodChangeData.length; i++) {
if (row == this.methodChangeData[i].methodName) {
this.formData.returnType = this.methodChangeData[i].returnType
this.argument = this.methodChangeData[i].para
return
}
}
},
//切换脚本所在类
classNameChange() {
this.methodName = []
if (!this.formData.id) {
this.formData.id = ''
}
let classInName = this.formData.className.substr(
this.formData.className.lastIndexOf('.') + 1,
this.formData.className.length
)
this.formData.classInsName = classInName.replace(
classInName[0],
classInName[0].toLowerCase()
)
flow
.getClassMethod(
this.formData.className,
this.formData.id,
this.formData.type
)
.then(resp => {
if (resp.data.state) {
var result = JSON.parse(resp.data.value)
this.methodChangeData = result
for (let i = 0; i < result.length; i++) {
this.methodName.push({value: result[i].methodName})
}
}
})
},
//获取脚本所在类
getClassName() {
this.className = []
flow.getConditionScriptClassName(this.formData.type).then(resp => {
for (let i = 0; i < resp.data.length; i++) {
this.className.push({value: resp.data[i]})
}
})
}
}
}
</script>
<style scoped lang="scss">
::v-deep .el-input.is-disabled .el-input__inner {
background: #f6f6f6;
border: none;
}
::v-deep .el-form-item__label{
color: #888888;
}
.form-table {
border: 1px solid #ebebeb;
tbody {
.tr_header {
th {
border-bottom: 1px solid #ebebeb;
color: #333333;
font-weight: bold;
background: rgba(244, 244, 244, 0.89);
}
}
}
}
</style>