feat: 子流程-超时设置

This commit is contained in:
Lesan 2025-02-24 15:27:27 +08:00
parent 2f8f5454b3
commit 64ff45e46c
3 changed files with 145 additions and 14 deletions

View File

@ -303,6 +303,9 @@ const addNode = (type: number) => {
skipStartUserNode: false, skipStartUserNode: false,
startUserSetting: { startUserSetting: {
type: 1 type: 1
},
timeoutSetting: {
enable: false
} }
} }
} }

View File

@ -818,17 +818,21 @@ export type ChildProcessSetting = {
outVariables?: IOParameter[], outVariables?: IOParameter[],
skipStartUserNode: boolean, skipStartUserNode: boolean,
startUserSetting: StartUserSetting, startUserSetting: StartUserSetting,
timeoutSetting: TimeoutSetting,
} }
export type IOParameter = { export type IOParameter = {
source: string source: string
sourceExpression: string sourceExpression: string
target: string target: string
targetExpression: string targetExpression: string
} }
export type StartUserSetting = { export type StartUserSetting = {
type: number type: number
formField?: string formField?: string
emptyType?: number emptyType?: number
} }
export type TimeoutSetting = {
enable: boolean,
type?: DelayTypeEnum,
timeExpression?: string,
}

View File

@ -28,11 +28,7 @@
<div> <div>
<el-form ref="formRef" :model="configForm" label-position="top" :rules="formRules"> <el-form ref="formRef" :model="configForm" label-position="top" :rules="formRules">
<el-form-item label="是否异步" prop="async"> <el-form-item label="是否异步" prop="async">
<el-switch <el-switch v-model="configForm.async" active-text="异步" inactive-text="不异步" />
v-model="configForm.async"
active-text="异步"
inactive-text="不异步"
/>
</el-form-item> </el-form-item>
<el-form-item label="选择子流程" prop="calledProcessDefinitionKey"> <el-form-item label="选择子流程" prop="calledProcessDefinitionKey">
<el-select <el-select
@ -194,6 +190,60 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-divider content-position="left">超时设置</el-divider>
<el-form-item label="启用开关" prop="timeoutEnable">
<el-switch
v-model="configForm.timeoutEnable"
active-text="开启"
inactive-text="关闭"
/>
</el-form-item>
<div v-if="configForm.timeoutEnable">
<el-form-item prop="timeoutType">
<el-radio-group v-model="configForm.timeoutType">
<el-radio-button
v-for="item in DELAY_TYPE"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-radio-group>
</el-form-item>
<el-form-item v-if="configForm.timeoutType === DelayTypeEnum.FIXED_TIME_DURATION">
<el-form-item prop="timeDuration">
<el-input-number
class="mr-2"
:style="{ width: '100px' }"
v-model="configForm.timeDuration"
:min="1"
controls-position="right"
/>
</el-form-item>
<el-select v-model="configForm.timeUnit" class="mr-2" :style="{ width: '100px' }">
<el-option
v-for="item in TIME_UNIT_TYPES"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<el-text>后进入下一节点</el-text>
</el-form-item>
<el-form-item
v-if="configForm.timeoutType === DelayTypeEnum.FIXED_DATE_TIME"
prop="dateTime"
>
<el-date-picker
class="mr-2"
v-model="configForm.dateTime"
type="datetime"
placeholder="请选择日期和时间"
value-format="YYYY-MM-DDTHH:mm:ss"
/>
<el-text>后进入下一节点</el-text>
</el-form-item>
</div>
</el-form> </el-form>
</div> </div>
</el-tab-pane> </el-tab-pane>
@ -210,9 +260,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { getModelList } from '@/api/bpm/model' import { getModelList } from '@/api/bpm/model'
import { getForm } from '@/api/bpm/form' import { getForm } from '@/api/bpm/form'
import { SimpleFlowNode, NodeType } from '../consts' import {
SimpleFlowNode,
NodeType,
TIME_UNIT_TYPES,
TimeUnitType,
DelayTypeEnum,
DELAY_TYPE
} from '../consts'
import { useWatchNode, useDrawer, useNodeName, useFormFieldsAndStartUser } from '../node' import { useWatchNode, useDrawer, useNodeName, useFormFieldsAndStartUser } from '../node'
import { parseFormFields } from '@/components/FormCreate/src/utils' import { parseFormFields } from '@/components/FormCreate/src/utils'
import { convertTimeUnit } from '../utils'
defineOptions({ defineOptions({
name: 'ChildProcessNodeConfig' name: 'ChildProcessNodeConfig'
}) })
@ -243,16 +301,26 @@ const formRules = reactive({
startUserEmptyType: [ startUserEmptyType: [
{ required: true, message: '当子流程发起人为空时不能为空', trigger: 'change' } { required: true, message: '当子流程发起人为空时不能为空', trigger: 'change' }
], ],
startUserFormField: [{ required: true, message: '发起人表单不能为空', trigger: 'change' }] startUserFormField: [{ required: true, message: '发起人表单不能为空', trigger: 'change' }],
timeoutEnable: [{ required: true, message: '超时设置是否开启不能为空', trigger: 'change' }],
timeoutType: [{ required: true, message: '超时设置时间不能为空', trigger: 'change' }],
timeDuration: [{ required: true, message: '超时设置时间不能为空', trigger: 'change' }],
dateTime: [{ required: true, message: '超时设置时间不能为空', trigger: 'change' }]
}) })
const configForm = ref({ const configForm = ref({
async: false,
calledProcessDefinitionKey: '', calledProcessDefinitionKey: '',
skipStartUserNode: false, skipStartUserNode: false,
inVariables: [], inVariables: [],
outVariables: [], outVariables: [],
startUserType: 1, startUserType: 1,
startUserEmptyType: 1, startUserEmptyType: 1,
startUserFormField: '' startUserFormField: '',
timeoutEnable: false,
timeoutType: DelayTypeEnum.FIXED_TIME_DURATION,
timeDuration: 1,
timeUnit: TimeUnitType.HOUR,
dateTime: ''
}) })
const childProcessOptions = ref() const childProcessOptions = ref()
const formFieldOptions = useFormFieldsAndStartUser() const formFieldOptions = useFormFieldsAndStartUser()
@ -269,18 +337,39 @@ const saveConfig = async () => {
) )
currentNode.value.name = nodeName.value! currentNode.value.name = nodeName.value!
if (currentNode.value.childProcessSetting) { if (currentNode.value.childProcessSetting) {
// 1.
currentNode.value.childProcessSetting.async = configForm.value.async currentNode.value.childProcessSetting.async = configForm.value.async
// 2.
currentNode.value.childProcessSetting.calledProcessDefinitionKey = childInfo.key currentNode.value.childProcessSetting.calledProcessDefinitionKey = childInfo.key
currentNode.value.childProcessSetting.calledProcessDefinitionName = childInfo.name currentNode.value.childProcessSetting.calledProcessDefinitionName = childInfo.name
// 3.
currentNode.value.childProcessSetting.skipStartUserNode = configForm.value.skipStartUserNode currentNode.value.childProcessSetting.skipStartUserNode = configForm.value.skipStartUserNode
// 4. ->
currentNode.value.childProcessSetting.inVariables = configForm.value.inVariables currentNode.value.childProcessSetting.inVariables = configForm.value.inVariables
// 5. ->
currentNode.value.childProcessSetting.outVariables = configForm.value.outVariables currentNode.value.childProcessSetting.outVariables = configForm.value.outVariables
// 6.
currentNode.value.childProcessSetting.startUserSetting.type = configForm.value.startUserType currentNode.value.childProcessSetting.startUserSetting.type = configForm.value.startUserType
currentNode.value.childProcessSetting.startUserSetting.emptyType = currentNode.value.childProcessSetting.startUserSetting.emptyType =
configForm.value.startUserEmptyType configForm.value.startUserEmptyType
currentNode.value.childProcessSetting.startUserSetting.formField = currentNode.value.childProcessSetting.startUserSetting.formField =
configForm.value.startUserFormField configForm.value.startUserFormField
// 7.
currentNode.value.childProcessSetting.timeoutSetting = {
enable: configForm.value.timeoutEnable
} }
if (configForm.value.timeoutEnable) {
currentNode.value.childProcessSetting.timeoutSetting.type = configForm.value.timeoutType
if (configForm.value.timeoutType === DelayTypeEnum.FIXED_TIME_DURATION) {
currentNode.value.childProcessSetting.timeoutSetting.timeExpression = getIsoTimeDuration()
}
if (configForm.value.timeoutType === DelayTypeEnum.FIXED_DATE_TIME) {
currentNode.value.childProcessSetting.timeoutSetting.timeExpression =
configForm.value.dateTime
}
}
}
currentNode.value.showText = `调用子流程:${childInfo.name}` currentNode.value.showText = `调用子流程:${childInfo.name}`
settingVisible.value = false settingVisible.value = false
return true return true
@ -289,16 +378,39 @@ const saveConfig = async () => {
const showChildProcessNodeConfig = (node: SimpleFlowNode) => { const showChildProcessNodeConfig = (node: SimpleFlowNode) => {
nodeName.value = node.name nodeName.value = node.name
if (node.childProcessSetting) { if (node.childProcessSetting) {
configForm.value.async = // 1.
node.childProcessSetting.async configForm.value.async = node.childProcessSetting.async
// 2.
configForm.value.calledProcessDefinitionKey = configForm.value.calledProcessDefinitionKey =
node.childProcessSetting.calledProcessDefinitionKey node.childProcessSetting?.calledProcessDefinitionKey
// 3.
configForm.value.skipStartUserNode = node.childProcessSetting.skipStartUserNode configForm.value.skipStartUserNode = node.childProcessSetting.skipStartUserNode
// 4. ->
configForm.value.inVariables = node.childProcessSetting.inVariables configForm.value.inVariables = node.childProcessSetting.inVariables
// 5. ->
configForm.value.outVariables = node.childProcessSetting.outVariables configForm.value.outVariables = node.childProcessSetting.outVariables
// 6.
configForm.value.startUserType = node.childProcessSetting.startUserSetting.type configForm.value.startUserType = node.childProcessSetting.startUserSetting.type
configForm.value.startUserEmptyType = node.childProcessSetting.startUserSetting.emptyType ?? 1 configForm.value.startUserEmptyType = node.childProcessSetting.startUserSetting.emptyType ?? 1
configForm.value.startUserFormField = node.childProcessSetting.startUserSetting.formField ?? '' configForm.value.startUserFormField = node.childProcessSetting.startUserSetting.formField ?? ''
// 7.
configForm.value.timeoutEnable = node.childProcessSetting.timeoutSetting.enable ?? false
if (configForm.value.timeoutEnable) {
configForm.value.timeoutType =
node.childProcessSetting.timeoutSetting.type ?? DelayTypeEnum.FIXED_TIME_DURATION
//
if (configForm.value.timeoutType === DelayTypeEnum.FIXED_TIME_DURATION) {
const strTimeDuration = node.childProcessSetting.timeoutSetting.timeExpression ?? ''
let parseTime = strTimeDuration.slice(2, strTimeDuration.length - 1)
let parseTimeUnit = strTimeDuration.slice(strTimeDuration.length - 1)
configForm.value.timeDuration = parseInt(parseTime)
configForm.value.timeUnit = convertTimeUnit(parseTimeUnit)
}
//
if (configForm.value.timeoutType === DelayTypeEnum.FIXED_DATE_TIME) {
configForm.value.dateTime = node.childProcessSetting.timeoutSetting.timeExpression ?? ''
}
}
} }
loadFormInfo() loadFormInfo()
} }
@ -330,7 +442,19 @@ const loadFormInfo = async () => {
parseFormFields(JSON.parse(fieldStr), childFormFieldOptions.value) parseFormFields(JSON.parse(fieldStr), childFormFieldOptions.value)
}) })
} }
console.log(childFormFieldOptions.value) }
const getIsoTimeDuration = () => {
let strTimeDuration = 'PT'
if (configForm.value.timeUnit === TimeUnitType.MINUTE) {
strTimeDuration += configForm.value.timeDuration + 'M'
}
if (configForm.value.timeUnit === TimeUnitType.HOUR) {
strTimeDuration += configForm.value.timeDuration + 'H'
}
if (configForm.value.timeUnit === TimeUnitType.DAY) {
strTimeDuration += configForm.value.timeDuration + 'D'
}
return strTimeDuration
} }
onMounted(async () => { onMounted(async () => {