【功能优化】条件节点设置优化

This commit is contained in:
jason 2025-01-19 18:40:18 +08:00
parent baa4116697
commit 42de3d9127
5 changed files with 59 additions and 39 deletions

View File

@ -163,8 +163,10 @@ const addNode = (type: number) => {
showText: '', showText: '',
type: NodeType.CONDITION_NODE, type: NodeType.CONDITION_NODE,
childNode: undefined, childNode: undefined,
conditionType: 1, conditionSetting: {
defaultFlow: false defaultFlow: false
},
}, },
{ {
id: 'Flow_' + generateUUID(), id: 'Flow_' + generateUUID(),
@ -172,8 +174,9 @@ const addNode = (type: number) => {
showText: '未满足其它条件时,将进入此分支', showText: '未满足其它条件时,将进入此分支',
type: NodeType.CONDITION_NODE, type: NodeType.CONDITION_NODE,
childNode: undefined, childNode: undefined,
conditionType: undefined, conditionSetting: {
defaultFlow: true defaultFlow: true
}
} }
] ]
} }
@ -217,7 +220,10 @@ const addNode = (type: number) => {
showText: '', showText: '',
type: NodeType.CONDITION_NODE, type: NodeType.CONDITION_NODE,
childNode: undefined, childNode: undefined,
defaultFlow: false conditionSetting: {
defaultFlow: false
}
}, },
{ {
id: 'Flow_' + generateUUID(), id: 'Flow_' + generateUUID(),
@ -225,7 +231,9 @@ const addNode = (type: number) => {
showText: '未满足其它条件时,将进入此分支', showText: '未满足其它条件时,将进入此分支',
type: NodeType.CONDITION_NODE, type: NodeType.CONDITION_NODE,
childNode: undefined, childNode: undefined,
defaultFlow: true conditionSetting: {
defaultFlow: true
}
} }
] ]
} }

View File

@ -103,14 +103,8 @@ export interface SimpleFlowNode {
taskAssignListener?: ListenerHandler taskAssignListener?: ListenerHandler
// 创建任务监听器 // 创建任务监听器
taskCompleteListener?: ListenerHandler taskCompleteListener?: ListenerHandler
// 条件类型 // 条件设置
conditionType?: ConditionType conditionSetting?: ConditionSetting
// 条件表达式
conditionExpression?: string
// 条件组
conditionGroups?: ConditionGroup
// 是否默认的条件
defaultFlow?: boolean
// 活动的状态,用于前端节点状态展示 // 活动的状态,用于前端节点状态展示
activityStatus?: TaskStatusEnum activityStatus?: TaskStatusEnum
// 延迟设置 // 延迟设置
@ -365,6 +359,20 @@ export enum TimeUnitType {
DAY = 3 DAY = 3
} }
/**
*
*/
export type ConditionSetting = {
// 条件类型
conditionType?: ConditionType,
// 条件表达式
conditionExpression?: string,
// 条件组
conditionGroups?: ConditionGroup,
// 是否默认的条件
defaultFlow?: boolean
}
// 条件配置类型 用于条件节点配置 // 条件配置类型 用于条件节点配置
export enum ConditionType { export enum ConditionType {
/** /**

View File

@ -113,7 +113,6 @@ export function useFormFields() {
} }
export type UserTaskFormType = { export type UserTaskFormType = {
//candidateParamArray: any[]
candidateStrategy: CandidateStrategy candidateStrategy: CandidateStrategy
approveMethod: ApproveMethodType approveMethod: ApproveMethodType
roleIds?: number[] // 角色 roleIds?: number[] // 角色
@ -152,7 +151,6 @@ export type UserTaskFormType = {
} }
export type CopyTaskFormType = { export type CopyTaskFormType = {
// candidateParamArray: any[]
candidateStrategy: CandidateStrategy candidateStrategy: CandidateStrategy
roleIds?: number[] // 角色 roleIds?: number[] // 角色
deptIds?: number[] // 部门 deptIds?: number[] // 部门

View File

@ -26,13 +26,16 @@
</div> </div>
</template> </template>
<div> <div>
<div class="mb-3 font-size-16px" v-if="currentNode.defaultFlow" <div class="mb-3 font-size-16px" v-if="currentNode.conditionSetting?.defaultFlow">
>未满足其它条件时将进入此分支该分支不可编辑和删除</div 未满足其它条件时将进入此分支该分支不可编辑和删除
> </div>
<div v-else> <div v-else>
<el-form ref="formRef" :model="currentNode" :rules="formRules" label-position="top"> <el-form ref="formRef" :model="currentNode.conditionSetting" :rules="formRules" label-position="top">
<el-form-item label="配置方式" prop="conditionType"> <el-form-item label="配置方式" prop="conditionType">
<el-radio-group v-model="currentNode.conditionType" @change="changeConditionType"> <el-radio-group
v-model="currentNode.conditionSetting!.conditionType"
@change="changeConditionType"
>
<el-radio <el-radio
v-for="(dict, index) in conditionConfigTypes" v-for="(dict, index) in conditionConfigTypes"
:key="index" :key="index"
@ -45,18 +48,21 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="currentNode.conditionType === 1" v-if="currentNode.conditionSetting?.conditionType === ConditionType.EXPRESSION"
label="条件表达式" label="条件表达式"
prop="conditionExpression" prop="conditionExpression"
> >
<el-input <el-input
type="textarea" type="textarea"
v-model="currentNode.conditionExpression" v-model="currentNode.conditionSetting.conditionExpression"
clearable clearable
style="width: 100%" style="width: 100%"
/> />
</el-form-item> </el-form-item>
<el-form-item v-if="currentNode.conditionType === 2" label="条件规则"> <el-form-item
v-if="currentNode.conditionSetting?.conditionType === ConditionType.RULE"
label="条件规则"
>
<div class="condition-group-tool"> <div class="condition-group-tool">
<div class="flex items-center"> <div class="flex items-center">
<div class="mr-4">条件组关系</div> <div class="mr-4">条件组关系</div>
@ -194,9 +200,9 @@ const props = defineProps({
}) })
const settingVisible = ref(false) const settingVisible = ref(false)
const open = () => { const open = () => {
if (currentNode.value.conditionType === ConditionType.RULE) { if (currentNode.value.conditionSetting?.conditionType === ConditionType.RULE) {
if (currentNode.value.conditionGroups) { if (currentNode.value.conditionSetting?.conditionGroups) {
conditionGroups.value = currentNode.value.conditionGroups conditionGroups.value = currentNode.value.conditionSetting.conditionGroups
} }
} }
settingVisible.value = true settingVisible.value = true
@ -219,7 +225,7 @@ const blurEvent = () => {
showInput.value = false showInput.value = false
currentNode.value.name = currentNode.value.name =
currentNode.value.name || currentNode.value.name ||
getDefaultConditionNodeName(props.nodeIndex, currentNode.value?.defaultFlow) getDefaultConditionNodeName(props.nodeIndex, currentNode.value?.conditionSetting?.defaultFlow)
} }
const currentNode = ref<SimpleFlowNode>(props.conditionNode) const currentNode = ref<SimpleFlowNode>(props.conditionNode)
@ -248,7 +254,7 @@ const formRef = ref() // 表单 Ref
// //
const saveConfig = async () => { const saveConfig = async () => {
if (!currentNode.value.defaultFlow) { if (!currentNode.value.conditionSetting?.defaultFlow) {
// //
if (!formRef) return false if (!formRef) return false
const valid = await formRef.value.validate() const valid = await formRef.value.validate()
@ -258,12 +264,12 @@ const saveConfig = async () => {
return false return false
} }
currentNode.value.showText = showText currentNode.value.showText = showText
if (currentNode.value.conditionType === ConditionType.EXPRESSION) { if (currentNode.value.conditionSetting?.conditionType === ConditionType.EXPRESSION) {
currentNode.value.conditionGroups = undefined currentNode.value.conditionSetting.conditionGroups = undefined
} }
if (currentNode.value.conditionType === ConditionType.RULE) { if (currentNode.value.conditionSetting?.conditionType === ConditionType.RULE) {
currentNode.value.conditionExpression = undefined currentNode.value.conditionSetting.conditionExpression = undefined
currentNode.value.conditionGroups = conditionGroups.value currentNode.value.conditionSetting.conditionGroups = conditionGroups.value
} }
} }
settingVisible.value = false settingVisible.value = false
@ -271,12 +277,12 @@ const saveConfig = async () => {
} }
const getShowText = (): string => { const getShowText = (): string => {
let showText = '' let showText = ''
if (currentNode.value.conditionType === ConditionType.EXPRESSION) { if (currentNode.value.conditionSetting?.conditionType === ConditionType.EXPRESSION) {
if (currentNode.value.conditionExpression) { if (currentNode.value.conditionSetting.conditionExpression) {
showText = `表达式:${currentNode.value.conditionExpression}` showText = `表达式:${currentNode.value.conditionSetting.conditionExpression}`
} }
} }
if (currentNode.value.conditionType === ConditionType.RULE) { if (currentNode.value.conditionSetting?.conditionType === ConditionType.RULE) {
// //
const groupAnd = conditionGroups.value.and const groupAnd = conditionGroups.value.and
let warningMesg: undefined | string = undefined let warningMesg: undefined | string = undefined

View File

@ -34,7 +34,7 @@
]" ]"
> >
<div class="branch-node-title-container"> <div class="branch-node-title-container">
<div v-if="showInputs[index]"> <div v-if="!readonly && showInputs[index]">
<input <input
type="text" type="text"
class="editable-title-input" class="editable-title-input"