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