95
95
<Icon
96
96
icon =" ep:delete"
97
97
:size =" 18"
98
- @click =" deleteVariable(configForm.inVariables, index )"
98
+ @click =" deleteVariable(index, configForm.inVariables)"
99
99
/>
100
100
</div >
101
101
</div >
102
102
<el-button type =" primary" text @click =" addVariable(configForm.inVariables)" >
103
103
<Icon icon =" ep:plus" class =" mr-5px" />添加一行
104
104
</el-button >
105
105
</el-form-item >
106
- <!-- TODO @lesan:async、source、target 几个字段,会告警 -->
107
106
<el-form-item
108
107
v-if =" configForm.async === false"
109
108
label =" 子→主变量传递"
152
151
<Icon
153
152
icon =" ep:delete"
154
153
:size =" 18"
155
- @click =" deleteVariable(configForm.outVariables, index )"
154
+ @click =" deleteVariable(index, configForm.outVariables)"
156
155
/>
157
156
</div >
158
157
</div >
159
158
<el-button type =" primary" text @click =" addVariable(configForm.outVariables)" >
160
159
<Icon icon =" ep:plus" class =" mr-5px" />添加一行
161
160
</el-button >
162
161
</el-form-item >
163
- <!-- TODO @lesan:startUserType、startUserEmptyType 要不走写下枚举类? -->
164
162
<el-form-item label =" 子流程发起人" prop =" startUserType" >
165
163
<el-radio-group v-model =" configForm.startUserType" >
166
- <el-radio :value =" 1" >同主流程发起人</el-radio >
167
- <el-radio :value =" 2" >表单</el-radio >
164
+ <el-radio
165
+ v-for =" item in CHILD_PROCESS_START_USER_TYPE"
166
+ :key =" item.value"
167
+ :value =" item.value"
168
+ >
169
+ {{ item.label }}</el-radio
170
+ >
168
171
</el-radio-group >
169
172
</el-form-item >
170
173
<el-form-item
173
176
prop =" startUserType"
174
177
>
175
178
<el-radio-group v-model =" configForm.startUserEmptyType" >
176
- <el-radio :value =" 1" >同主流程发起人</el-radio >
177
- <el-radio :value =" 2" >子流程管理员</el-radio >
178
- <el-radio :value =" 3" >主流程管理员</el-radio >
179
+ <el-radio
180
+ v-for =" item in CHILD_PROCESS_START_USER_EMPTY_TYPE"
181
+ :key =" item.value"
182
+ :value =" item.value"
183
+ >
184
+ {{ item.label }}</el-radio
185
+ >
179
186
</el-radio-group >
180
187
</el-form-item >
181
188
<el-form-item
246
253
<el-text >后进入下一节点</el-text >
247
254
</el-form-item >
248
255
</div >
256
+
257
+ <el-divider content-position =" left" >多实例设置</el-divider >
258
+ <el-form-item label =" 启用开关" prop =" multiInstanceEnable" >
259
+ <el-switch
260
+ v-model =" configForm.multiInstanceEnable"
261
+ active-text =" 开启"
262
+ inactive-text =" 关闭"
263
+ />
264
+ </el-form-item >
265
+ <div v-if =" configForm.multiInstanceEnable" >
266
+ <el-form-item prop =" sequential" >
267
+ <el-switch
268
+ v-model =" configForm.sequential"
269
+ active-text =" 串行"
270
+ inactive-text =" 并行"
271
+ />
272
+ </el-form-item >
273
+ <el-form-item prop =" completeRatio" >
274
+ <el-text >完成比例(%)</el-text >
275
+ <el-input-number
276
+ class =" ml-10px"
277
+ v-model =" configForm.completeRatio"
278
+ :min =" 10"
279
+ :max =" 100"
280
+ :step =" 10"
281
+ />
282
+ </el-form-item >
283
+ <el-form-item prop =" multiInstanceSourceType" >
284
+ <el-text >多实例来源</el-text >
285
+ <el-select class =" ml-10px w-200px!" v-model =" configForm.multiInstanceSourceType" @change =" handleMultiInstanceSourceTypeChange" >
286
+ <el-option
287
+ v-for =" item in CHILD_PROCESS_MULTI_INSTANCE_SOURCE_TYPE"
288
+ :key =" item.value"
289
+ :label =" item.label"
290
+ :value =" item.value"
291
+ />
292
+ </el-select >
293
+ </el-form-item >
294
+ <el-form-item v-if =" configForm.multiInstanceSourceType === 1" >
295
+ <el-input-number v-model =" configForm.multiInstanceSource" :min =" 1" />
296
+ </el-form-item >
297
+ <el-form-item v-if =" configForm.multiInstanceSourceType === 2" >
298
+ <el-select class =" w-200px!" v-model =" configForm.multiInstanceSource" >
299
+ <el-option
300
+ v-for =" (field, fIdx) in digitalFormFieldOptions"
301
+ :key =" fIdx"
302
+ :label =" field.title"
303
+ :value =" field.field"
304
+ />
305
+ </el-select >
306
+ </el-form-item >
307
+ <el-form-item v-if =" configForm.multiInstanceSourceType === 3" >
308
+ <el-select class =" w-200px!" v-model =" configForm.multiInstanceSource" >
309
+ <el-option
310
+ v-for =" (field, fIdx) in multiFormFieldOptions"
311
+ :key =" fIdx"
312
+ :label =" field.title"
313
+ :value =" field.field"
314
+ />
315
+ </el-select >
316
+ </el-form-item >
317
+ </div >
249
318
</el-form >
250
319
</div >
251
320
</el-tab-pane >
@@ -268,7 +337,14 @@ import {
268
337
TIME_UNIT_TYPES ,
269
338
TimeUnitType ,
270
339
DelayTypeEnum ,
271
- DELAY_TYPE
340
+ DELAY_TYPE ,
341
+ IOParameter ,
342
+ ChildProcessStartUserTypeEnum ,
343
+ CHILD_PROCESS_START_USER_TYPE ,
344
+ ChildProcessStartUserEmptyTypeEnum ,
345
+ CHILD_PROCESS_START_USER_EMPTY_TYPE ,
346
+ CHILD_PROCESS_MULTI_INSTANCE_SOURCE_TYPE ,
347
+ ChildProcessMultiInstanceSourceTypeEnum
272
348
} from ' ../consts'
273
349
import { useWatchNode , useDrawer , useNodeName , useFormFieldsAndStartUser } from ' ../node'
274
350
import { parseFormFields } from ' @/components/FormCreate/src/utils'
@@ -307,25 +383,57 @@ const formRules = reactive({
307
383
timeoutEnable: [{ required: true , message: ' 超时设置是否开启不能为空' , trigger: ' change' }],
308
384
timeoutType: [{ required: true , message: ' 超时设置时间不能为空' , trigger: ' change' }],
309
385
timeDuration: [{ required: true , message: ' 超时设置时间不能为空' , trigger: ' change' }],
310
- dateTime: [{ required: true , message: ' 超时设置时间不能为空' , trigger: ' change' }]
386
+ dateTime: [{ required: true , message: ' 超时设置时间不能为空' , trigger: ' change' }],
387
+ multiInstanceEnable: [{ required: true , message: ' 多实例设置不能为空' , trigger: ' change' }]
311
388
})
312
- const configForm = ref ({
389
+ type ChildProcessFormType = {
390
+ async: boolean
391
+ calledProcessDefinitionKey: string
392
+ skipStartUserNode: boolean
393
+ inVariables? : IOParameter []
394
+ outVariables? : IOParameter []
395
+ startUserType: ChildProcessStartUserTypeEnum
396
+ startUserEmptyType: ChildProcessStartUserEmptyTypeEnum
397
+ startUserFormField: string
398
+ timeoutEnable: boolean
399
+ timeoutType: DelayTypeEnum
400
+ timeDuration: number
401
+ timeUnit: TimeUnitType
402
+ dateTime: string
403
+ multiInstanceEnable: boolean
404
+ sequential: boolean
405
+ completeRatio: number
406
+ multiInstanceSourceType: ChildProcessMultiInstanceSourceTypeEnum
407
+ multiInstanceSource: string
408
+ }
409
+ const configForm = ref <ChildProcessFormType >({
313
410
async: false ,
314
411
calledProcessDefinitionKey: ' ' ,
315
412
skipStartUserNode: false ,
316
413
inVariables: [],
317
414
outVariables: [],
318
- startUserType: 1 ,
319
- startUserEmptyType: 1 ,
415
+ startUserType: ChildProcessStartUserTypeEnum . MAIN_PROCESS_START_USER ,
416
+ startUserEmptyType: ChildProcessStartUserEmptyTypeEnum . MAIN_PROCESS_START_USER ,
320
417
startUserFormField: ' ' ,
321
418
timeoutEnable: false ,
322
419
timeoutType: DelayTypeEnum .FIXED_TIME_DURATION ,
323
420
timeDuration: 1 ,
324
421
timeUnit: TimeUnitType .HOUR ,
325
- dateTime: ' '
422
+ dateTime: ' ' ,
423
+ multiInstanceEnable: false ,
424
+ sequential: false ,
425
+ completeRatio: 100 ,
426
+ multiInstanceSourceType: ChildProcessMultiInstanceSourceTypeEnum .FIXED_QUANTITY ,
427
+ multiInstanceSource: ' '
326
428
})
327
429
const childProcessOptions = ref ()
328
430
const formFieldOptions = useFormFieldsAndStartUser ()
431
+ const digitalFormFieldOptions = computed (() => {
432
+ return formFieldOptions .filter ((item ) => item .type === ' inputNumber' )
433
+ })
434
+ const multiFormFieldOptions = computed (() => {
435
+ return formFieldOptions .filter ((item ) => item .type === ' select' || item .type === ' checkbox' )
436
+ })
329
437
const childFormFieldOptions = ref ()
330
438
331
439
// 保存配置
@@ -334,9 +442,8 @@ const saveConfig = async () => {
334
442
if (! formRef ) return false
335
443
const valid = await formRef .value .validate ()
336
444
if (! valid ) return false
337
- // TODO @lesan:这里的 option 黄色告警,也处理下哈
338
445
const childInfo = childProcessOptions .value .find (
339
- (option ) => option .key === configForm .value .calledProcessDefinitionKey
446
+ (option : any ) => option .key === configForm .value .calledProcessDefinitionKey
340
447
)
341
448
currentNode .value .name = nodeName .value !
342
449
if (currentNode .value .childProcessSetting ) {
@@ -371,14 +478,26 @@ const saveConfig = async () => {
371
478
configForm .value .dateTime
372
479
}
373
480
}
481
+ // 8. 多实例设置
482
+ currentNode .value .childProcessSetting .multiInstanceSetting = {
483
+ enable: configForm .value .multiInstanceEnable
484
+ }
485
+ if (configForm .value .multiInstanceEnable ) {
486
+ currentNode .value .childProcessSetting .multiInstanceSetting .sequential = configForm .value .sequential
487
+ currentNode .value .childProcessSetting .multiInstanceSetting .completeRatio =
488
+ configForm .value .completeRatio
489
+ currentNode .value .childProcessSetting .multiInstanceSetting .sourceType =
490
+ configForm .value .multiInstanceSourceType
491
+ currentNode .value .childProcessSetting .multiInstanceSetting .source =
492
+ configForm .value .multiInstanceSource
493
+ }
374
494
}
375
495
376
496
currentNode .value .showText = ` 调用子流程:${childInfo .name } `
377
497
settingVisible .value = false
378
498
return true
379
499
}
380
500
// 显示子流程节点配置, 由父组件传过来
381
- // TODO @lesan:inVariables、outVariables 红色告警
382
501
const showChildProcessNodeConfig = (node : SimpleFlowNode ) => {
383
502
nodeName .value = node .name
384
503
if (node .childProcessSetting ) {
@@ -415,21 +534,30 @@ const showChildProcessNodeConfig = (node: SimpleFlowNode) => {
415
534
configForm .value .dateTime = node .childProcessSetting .timeoutSetting .timeExpression ?? ' '
416
535
}
417
536
}
537
+ // 8. 多实例设置
538
+ configForm .value .multiInstanceEnable =
539
+ node .childProcessSetting .multiInstanceSetting .enable ?? false
540
+ if (configForm .value .multiInstanceEnable ) {
541
+ configForm .value .sequential = node .childProcessSetting .multiInstanceSetting .sequential ?? false
542
+ configForm .value .completeRatio = node .childProcessSetting .multiInstanceSetting .completeRatio ?? 100
543
+ configForm .value .multiInstanceSourceType =
544
+ node .childProcessSetting .multiInstanceSetting .sourceType ?? ChildProcessMultiInstanceSourceTypeEnum .FIXED_QUANTITY
545
+ configForm .value .multiInstanceSource = node .childProcessSetting .multiInstanceSetting .source ?? ' '
546
+ }
418
547
}
419
548
loadFormInfo ()
420
549
}
421
550
422
551
defineExpose ({ openDrawer , showChildProcessNodeConfig }) // 暴露方法给父组件
423
552
424
- // TODO @lesan:这里的 arr 黄色告警,也处理下哈,可以用 cursor quick fix 哈
425
- const addVariable = (arr ) => {
426
- arr .push ({
553
+ const addVariable = (arr ? : IOParameter []) => {
554
+ arr ?.push ({
427
555
source: ' ' ,
428
556
target: ' '
429
557
})
430
558
}
431
- const deleteVariable = (arr , index : number ) => {
432
- arr .splice (index , 1 )
559
+ const deleteVariable = (index : number , arr ? : IOParameter [] ) => {
560
+ arr ? .splice (index , 1 )
433
561
}
434
562
const handleCalledElementChange = () => {
435
563
configForm .value .inVariables = []
@@ -461,6 +589,9 @@ const getIsoTimeDuration = () => {
461
589
}
462
590
return strTimeDuration
463
591
}
592
+ const handleMultiInstanceSourceTypeChange = () => {
593
+ configForm .value .multiInstanceSource = ' '
594
+ }
464
595
465
596
onMounted (async () => {
466
597
childProcessOptions .value = await getModelList (undefined )
0 commit comments