Skip to content

Commit 0ce9ece

Browse files
committed
【代码重构】将审批超时的 action 统一换成 handlerType,保持一致
1 parent 2dae231 commit 0ce9ece

File tree

3 files changed

+40
-24
lines changed

3 files changed

+40
-24
lines changed

src/components/SimpleProcessDesignerV2/src/consts.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export type TimeoutHandler = {
159159
//是否开启超时处理
160160
enable: boolean
161161
// 超时执行的动作
162-
action?: number
162+
type?: number
163163
// 超时时间设置
164164
timeDuration?: string
165165
// 执行动作是自动提醒, 最大提醒次数
@@ -176,6 +176,21 @@ export enum RejectHandlerType {
176176
*/
177177
RETURN_USER_TASK = 2
178178
}
179+
// 用户任务超时处理类型枚举
180+
export enum TimeoutHandlerType {
181+
/**
182+
* 自动提醒
183+
*/
184+
REMINDER = 1,
185+
/**
186+
* 自动同意
187+
*/
188+
APPROVE = 2,
189+
/**
190+
* 自动拒绝
191+
*/
192+
REJECT = 3
193+
}
179194
// 用户任务的审批人与发起人相同时,处理类型枚举
180195
export enum AssignStartUserHandlerType {
181196
/**
@@ -316,7 +331,7 @@ export const TIME_UNIT_TYPES: DictDataVO[] = [
316331
{ label: '天', value: TimeUnitType.DAY }
317332
]
318333
// 超时处理执行动作类型
319-
export const TIMEOUT_HANDLER_ACTION_TYPES: DictDataVO[] = [
334+
export const TIMEOUT_HANDLER_TYPES: DictDataVO[] = [
320335
{ label: '自动提醒', value: 1 },
321336
{ label: '自动同意', value: 2 },
322337
{ label: '自动拒绝', value: 3 }

src/components/SimpleProcessDesignerV2/src/node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export type UserTaskFormType = {
9898
rejectHandlerType?: RejectHandlerType
9999
returnNodeId?: string
100100
timeoutHandlerEnable?: boolean
101-
timeoutHandlerAction?: number
101+
timeoutHandlerType?: number
102102
assignStartUserHandlerType?: AssignStartUserHandlerType
103103
timeDuration?: number
104104
maxRemindCount?: number
@@ -131,7 +131,7 @@ export function useNodeForm(nodeType: NodeType) {
131131
assignStartUserHandlerType: AssignStartUserHandlerType.START_USER_AUDIT,
132132
returnNodeId: '',
133133
timeoutHandlerEnable: false,
134-
timeoutHandlerAction: 1,
134+
timeoutHandlerType: 1,
135135
timeDuration: 6, // 默认 6小时
136136
maxRemindCount: 1, // 默认 提醒 1次
137137
buttonsSetting: []

src/components/SimpleProcessDesignerV2/src/nodes-config/UserTaskNodeConfig.vue

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,15 @@
227227
</el-form-item>
228228
<el-form-item
229229
label="执行动作"
230-
prop="timeoutHandlerAction"
230+
prop="timeoutHandlerType"
231231
v-if="configForm.timeoutHandlerEnable"
232232
>
233233
<el-radio-group
234-
v-model="configForm.timeoutHandlerAction"
235-
@change="timeoutActionChanged"
234+
v-model="configForm.timeoutHandlerType"
235+
@change="timeoutHandlerTypeChanged"
236236
>
237237
<el-radio-button
238-
v-for="item in TIMEOUT_HANDLER_ACTION_TYPES"
238+
v-for="item in TIMEOUT_HANDLER_TYPES"
239239
:key="item.value"
240240
:value="item.value"
241241
:label="item.label"
@@ -271,7 +271,7 @@
271271
<el-form-item
272272
label="最大提醒次数"
273273
prop="maxRemindCount"
274-
v-if="configForm.timeoutHandlerEnable && configForm.timeoutHandlerAction === 1"
274+
v-if="configForm.timeoutHandlerEnable && configForm.timeoutHandlerType === 1"
275275
>
276276
<el-input-number v-model="configForm.maxRemindCount" :min="1" :max="10" />
277277
</el-form-item>
@@ -370,13 +370,14 @@ import {
370370
ApproveMethodType,
371371
TimeUnitType,
372372
RejectHandlerType,
373-
TIMEOUT_HANDLER_ACTION_TYPES,
373+
TIMEOUT_HANDLER_TYPES,
374374
TIME_UNIT_TYPES,
375375
REJECT_HANDLER_TYPES,
376376
DEFAULT_BUTTON_SETTING,
377377
OPERATION_BUTTON_NAME,
378378
ButtonSetting,
379-
ASSIGN_START_USER_HANDLER_TYPES
379+
ASSIGN_START_USER_HANDLER_TYPES,
380+
TimeoutHandlerType
380381
} from '../consts'
381382
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
382383
import {
@@ -426,7 +427,7 @@ const formRules = reactive({
426427
approveRatio: [{ required: true, message: '通过比例不能为空', trigger: 'blur' }],
427428
returnNodeId: [{ required: true, message: '驳回节点不能为空', trigger: 'change' }],
428429
timeoutHandlerEnable: [{ required: true }],
429-
timeoutHandlerAction: [{ required: true }],
430+
timeoutHandlerType: [{ required: true }],
430431
timeDuration: [{ required: true, message: '超时时间不能为空', trigger: 'blur' }],
431432
maxRemindCount: [{ required: true, message: '提醒次数不能为空', trigger: 'blur' }]
432433
})
@@ -482,8 +483,8 @@ const returnTaskList = ref<SimpleFlowNode[]>([])
482483
// 审批人超时未处理设置
483484
const {
484485
timeoutHandlerChange,
485-
cTimeoutAction,
486-
timeoutActionChanged,
486+
cTimeoutType,
487+
timeoutHandlerTypeChanged,
487488
timeUnit,
488489
timeUnitChange,
489490
isoTimeDuration,
@@ -514,7 +515,7 @@ const saveConfig = async () => {
514515
// 设置超时处理
515516
currentNode.value.timeoutHandler = {
516517
enable: configForm.value.timeoutHandlerEnable!,
517-
action: cTimeoutAction.value,
518+
type: cTimeoutType.value,
518519
timeDuration: isoTimeDuration.value,
519520
maxRemindCount: cTimeoutMaxRemindCount.value
520521
}
@@ -572,7 +573,7 @@ const showUserTaskNodeConfig = (node: SimpleFlowNode) => {
572573
configForm.value.timeDuration = parseInt(parseTime)
573574
timeUnit.value = convertTimeUnit(parseTimeUnit)
574575
}
575-
configForm.value.timeoutHandlerAction = node.timeoutHandler?.action
576+
configForm.value.timeoutHandlerType = node.timeoutHandler?.type
576577
configForm.value.maxRemindCount = node.timeoutHandler?.maxRemindCount
577578
// 1.5 设置用户任务的审批人与发起人相同时
578579
configForm.value.assignStartUserHandlerType = node.assignStartUserHandlerType
@@ -619,21 +620,21 @@ function useTimeoutHandler() {
619620
if (configForm.value.timeoutHandlerEnable) {
620621
timeUnit.value = 2
621622
configForm.value.timeDuration = 6
622-
configForm.value.timeoutHandlerAction = 1
623+
configForm.value.timeoutHandlerType = 1
623624
configForm.value.maxRemindCount = 1
624625
}
625626
}
626627
// 超时执行的动作
627-
const cTimeoutAction = computed(() => {
628+
const cTimeoutType = computed(() => {
628629
if (!configForm.value.timeoutHandlerEnable) {
629630
return undefined
630631
}
631-
return configForm.value.timeoutHandlerAction
632+
return configForm.value.timeoutHandlerType
632633
})
633634
634635
// 超时处理动作改变
635-
const timeoutActionChanged = () => {
636-
if (configForm.value.timeoutHandlerAction === 1) {
636+
const timeoutHandlerTypeChanged = () => {
637+
if (configForm.value.timeoutHandlerType === TimeoutHandlerType.REMINDER) {
637638
configForm.value.maxRemindCount = 1 // 超时提醒次数,默认为1
638639
}
639640
}
@@ -676,16 +677,16 @@ function useTimeoutHandler() {
676677
if (!configForm.value.timeoutHandlerEnable) {
677678
return undefined
678679
}
679-
if (configForm.value.timeoutHandlerAction !== 1) {
680+
if (configForm.value.timeoutHandlerType !== TimeoutHandlerType.REMINDER) {
680681
return undefined
681682
}
682683
return configForm.value.maxRemindCount
683684
})
684685
685686
return {
686687
timeoutHandlerChange,
687-
cTimeoutAction,
688-
timeoutActionChanged,
688+
cTimeoutType,
689+
timeoutHandlerTypeChanged,
689690
timeUnit,
690691
timeUnitChange,
691692
isoTimeDuration,

0 commit comments

Comments
 (0)