28
28
<div >
29
29
<el-form ref =" formRef" :model =" configForm" label-position =" top" :rules =" formRules" >
30
30
<el-form-item label =" 是否异步" prop =" async" >
31
- <el-switch
32
- v-model =" configForm.async"
33
- active-text =" 异步"
34
- inactive-text =" 不异步"
35
- />
31
+ <el-switch v-model =" configForm.async" active-text =" 异步" inactive-text =" 不异步" />
36
32
</el-form-item >
37
33
<el-form-item label =" 选择子流程" prop =" calledProcessDefinitionKey" >
38
34
<el-select
194
190
/>
195
191
</el-select >
196
192
</el-form-item >
193
+
194
+ <el-divider content-position =" left" >超时设置</el-divider >
195
+ <el-form-item label =" 启用开关" prop =" timeoutEnable" >
196
+ <el-switch
197
+ v-model =" configForm.timeoutEnable"
198
+ active-text =" 开启"
199
+ inactive-text =" 关闭"
200
+ />
201
+ </el-form-item >
202
+ <div v-if =" configForm.timeoutEnable" >
203
+ <el-form-item prop =" timeoutType" >
204
+ <el-radio-group v-model =" configForm.timeoutType" >
205
+ <el-radio-button
206
+ v-for =" item in DELAY_TYPE"
207
+ :key =" item.value"
208
+ :label =" item.label"
209
+ :value =" item.value"
210
+ />
211
+ </el-radio-group >
212
+ </el-form-item >
213
+ <el-form-item v-if =" configForm.timeoutType === DelayTypeEnum.FIXED_TIME_DURATION" >
214
+ <el-form-item prop =" timeDuration" >
215
+ <el-input-number
216
+ class =" mr-2"
217
+ :style =" { width: '100px' }"
218
+ v-model =" configForm.timeDuration"
219
+ :min =" 1"
220
+ controls-position =" right"
221
+ />
222
+ </el-form-item >
223
+ <el-select v-model =" configForm.timeUnit" class =" mr-2" :style =" { width: '100px' }" >
224
+ <el-option
225
+ v-for =" item in TIME_UNIT_TYPES"
226
+ :key =" item.value"
227
+ :label =" item.label"
228
+ :value =" item.value"
229
+ />
230
+ </el-select >
231
+ <el-text >后进入下一节点</el-text >
232
+ </el-form-item >
233
+ <el-form-item
234
+ v-if =" configForm.timeoutType === DelayTypeEnum.FIXED_DATE_TIME"
235
+ prop =" dateTime"
236
+ >
237
+ <el-date-picker
238
+ class =" mr-2"
239
+ v-model =" configForm.dateTime"
240
+ type =" datetime"
241
+ placeholder =" 请选择日期和时间"
242
+ value-format =" YYYY-MM-DDTHH:mm:ss"
243
+ />
244
+ <el-text >后进入下一节点</el-text >
245
+ </el-form-item >
246
+ </div >
197
247
</el-form >
198
248
</div >
199
249
</el-tab-pane >
210
260
<script setup lang="ts">
211
261
import { getModelList } from ' @/api/bpm/model'
212
262
import { getForm } from ' @/api/bpm/form'
213
- import { SimpleFlowNode , NodeType } from ' ../consts'
263
+ import {
264
+ SimpleFlowNode ,
265
+ NodeType ,
266
+ TIME_UNIT_TYPES ,
267
+ TimeUnitType ,
268
+ DelayTypeEnum ,
269
+ DELAY_TYPE
270
+ } from ' ../consts'
214
271
import { useWatchNode , useDrawer , useNodeName , useFormFieldsAndStartUser } from ' ../node'
215
272
import { parseFormFields } from ' @/components/FormCreate/src/utils'
273
+ import { convertTimeUnit } from ' ../utils'
216
274
defineOptions ({
217
275
name: ' ChildProcessNodeConfig'
218
276
})
@@ -243,16 +301,26 @@ const formRules = reactive({
243
301
startUserEmptyType: [
244
302
{ required: true , message: ' 当子流程发起人为空时不能为空' , trigger: ' change' }
245
303
],
246
- startUserFormField: [{ required: true , message: ' 发起人表单不能为空' , trigger: ' change' }]
304
+ startUserFormField: [{ required: true , message: ' 发起人表单不能为空' , trigger: ' change' }],
305
+ timeoutEnable: [{ required: true , message: ' 超时设置是否开启不能为空' , trigger: ' change' }],
306
+ timeoutType: [{ required: true , message: ' 超时设置时间不能为空' , trigger: ' change' }],
307
+ timeDuration: [{ required: true , message: ' 超时设置时间不能为空' , trigger: ' change' }],
308
+ dateTime: [{ required: true , message: ' 超时设置时间不能为空' , trigger: ' change' }]
247
309
})
248
310
const configForm = ref ({
311
+ async: false ,
249
312
calledProcessDefinitionKey: ' ' ,
250
313
skipStartUserNode: false ,
251
314
inVariables: [],
252
315
outVariables: [],
253
316
startUserType: 1 ,
254
317
startUserEmptyType: 1 ,
255
- startUserFormField: ' '
318
+ startUserFormField: ' ' ,
319
+ timeoutEnable: false ,
320
+ timeoutType: DelayTypeEnum .FIXED_TIME_DURATION ,
321
+ timeDuration: 1 ,
322
+ timeUnit: TimeUnitType .HOUR ,
323
+ dateTime: ' '
256
324
})
257
325
const childProcessOptions = ref ()
258
326
const formFieldOptions = useFormFieldsAndStartUser ()
@@ -269,18 +337,39 @@ const saveConfig = async () => {
269
337
)
270
338
currentNode .value .name = nodeName .value !
271
339
if (currentNode .value .childProcessSetting ) {
340
+ // 1. 是否异步
272
341
currentNode .value .childProcessSetting .async = configForm .value .async
342
+ // 2. 调用流程
273
343
currentNode .value .childProcessSetting .calledProcessDefinitionKey = childInfo .key
274
344
currentNode .value .childProcessSetting .calledProcessDefinitionName = childInfo .name
345
+ // 3. 是否跳过发起人
275
346
currentNode .value .childProcessSetting .skipStartUserNode = configForm .value .skipStartUserNode
347
+ // 4. 主->子变量
276
348
currentNode .value .childProcessSetting .inVariables = configForm .value .inVariables
349
+ // 5. 子->主变量
277
350
currentNode .value .childProcessSetting .outVariables = configForm .value .outVariables
351
+ // 6. 发起人设置
278
352
currentNode .value .childProcessSetting .startUserSetting .type = configForm .value .startUserType
279
353
currentNode .value .childProcessSetting .startUserSetting .emptyType =
280
354
configForm .value .startUserEmptyType
281
355
currentNode .value .childProcessSetting .startUserSetting .formField =
282
356
configForm .value .startUserFormField
357
+ // 7. 超时设置
358
+ currentNode .value .childProcessSetting .timeoutSetting = {
359
+ enable: configForm .value .timeoutEnable
360
+ }
361
+ if (configForm .value .timeoutEnable ) {
362
+ currentNode .value .childProcessSetting .timeoutSetting .type = configForm .value .timeoutType
363
+ if (configForm .value .timeoutType === DelayTypeEnum .FIXED_TIME_DURATION ) {
364
+ currentNode .value .childProcessSetting .timeoutSetting .timeExpression = getIsoTimeDuration ()
365
+ }
366
+ if (configForm .value .timeoutType === DelayTypeEnum .FIXED_DATE_TIME ) {
367
+ currentNode .value .childProcessSetting .timeoutSetting .timeExpression =
368
+ configForm .value .dateTime
369
+ }
370
+ }
283
371
}
372
+
284
373
currentNode .value .showText = ` 调用子流程:${childInfo .name } `
285
374
settingVisible .value = false
286
375
return true
@@ -289,16 +378,39 @@ const saveConfig = async () => {
289
378
const showChildProcessNodeConfig = (node : SimpleFlowNode ) => {
290
379
nodeName .value = node .name
291
380
if (node .childProcessSetting ) {
292
- configForm .value .async =
293
- node .childProcessSetting .async
381
+ // 1. 是否异步
382
+ configForm .value .async = node .childProcessSetting .async
383
+ // 2. 调用流程
294
384
configForm .value .calledProcessDefinitionKey =
295
- node .childProcessSetting .calledProcessDefinitionKey
385
+ node .childProcessSetting ?.calledProcessDefinitionKey
386
+ // 3. 是否跳过发起人
296
387
configForm .value .skipStartUserNode = node .childProcessSetting .skipStartUserNode
388
+ // 4. 主->子变量
297
389
configForm .value .inVariables = node .childProcessSetting .inVariables
390
+ // 5. 子->主变量
298
391
configForm .value .outVariables = node .childProcessSetting .outVariables
392
+ // 6. 发起人设置
299
393
configForm .value .startUserType = node .childProcessSetting .startUserSetting .type
300
394
configForm .value .startUserEmptyType = node .childProcessSetting .startUserSetting .emptyType ?? 1
301
395
configForm .value .startUserFormField = node .childProcessSetting .startUserSetting .formField ?? ' '
396
+ // 7. 超时设置
397
+ configForm .value .timeoutEnable = node .childProcessSetting .timeoutSetting .enable ?? false
398
+ if (configForm .value .timeoutEnable ) {
399
+ configForm .value .timeoutType =
400
+ node .childProcessSetting .timeoutSetting .type ?? DelayTypeEnum .FIXED_TIME_DURATION
401
+ // 固定时长
402
+ if (configForm .value .timeoutType === DelayTypeEnum .FIXED_TIME_DURATION ) {
403
+ const strTimeDuration = node .childProcessSetting .timeoutSetting .timeExpression ?? ' '
404
+ let parseTime = strTimeDuration .slice (2 , strTimeDuration .length - 1 )
405
+ let parseTimeUnit = strTimeDuration .slice (strTimeDuration .length - 1 )
406
+ configForm .value .timeDuration = parseInt (parseTime )
407
+ configForm .value .timeUnit = convertTimeUnit (parseTimeUnit )
408
+ }
409
+ // 固定日期时间
410
+ if (configForm .value .timeoutType === DelayTypeEnum .FIXED_DATE_TIME ) {
411
+ configForm .value .dateTime = node .childProcessSetting .timeoutSetting .timeExpression ?? ' '
412
+ }
413
+ }
302
414
}
303
415
loadFormInfo ()
304
416
}
@@ -330,7 +442,19 @@ const loadFormInfo = async () => {
330
442
parseFormFields (JSON .parse (fieldStr ), childFormFieldOptions .value )
331
443
})
332
444
}
333
- console .log (childFormFieldOptions .value )
445
+ }
446
+ const getIsoTimeDuration = () => {
447
+ let strTimeDuration = ' PT'
448
+ if (configForm .value .timeUnit === TimeUnitType .MINUTE ) {
449
+ strTimeDuration += configForm .value .timeDuration + ' M'
450
+ }
451
+ if (configForm .value .timeUnit === TimeUnitType .HOUR ) {
452
+ strTimeDuration += configForm .value .timeDuration + ' H'
453
+ }
454
+ if (configForm .value .timeUnit === TimeUnitType .DAY ) {
455
+ strTimeDuration += configForm .value .timeDuration + ' D'
456
+ }
457
+ return strTimeDuration
334
458
}
335
459
336
460
onMounted (async () => {
0 commit comments