Skip to content

Commit de35fd0

Browse files
YunaiVgitee-org
authored andcommitted
!708 优化代码 流程模型的流程设计中的条件分支问题 : 来回切换点击条件分支后带来的 条件切换问题
Merge pull request !708 from Lemon/feature/bpm-流程条件切换分支
2 parents 50df1f3 + ce0020a commit de35fd0

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

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

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { SimpleFlowNode, ConditionType } from '../consts'
4747
import { getDefaultConditionNodeName } from '../utils'
4848
import { useFormFieldsAndStartUser, getConditionShowText } from '../node'
4949
import Condition from './components/Condition.vue'
50+
import { cloneDeep } from 'lodash-es'
5051
const message = useMessage() // 消息弹窗
5152
defineOptions({
5253
name: 'ConditionNodeConfig'
@@ -63,9 +64,43 @@ const props = defineProps({
6364
})
6465
const settingVisible = ref(false)
6566
const currentNode = ref<SimpleFlowNode>(props.conditionNode)
66-
const condition = ref<any>()
67+
const condition = ref<any>({
68+
conditionType: ConditionType.RULE, // 设置默认值
69+
conditionExpression: '',
70+
conditionGroups: {
71+
and: true,
72+
conditions: [{
73+
and: true,
74+
rules: [{
75+
opCode: '==',
76+
leftSide: '',
77+
rightSide: ''
78+
}]
79+
}]
80+
}
81+
})
6782
const open = () => {
68-
condition.value = currentNode.value.conditionSetting
83+
// 如果有已存在的配置则使用,否则使用默认值
84+
if (currentNode.value.conditionSetting) {
85+
condition.value = cloneDeep(currentNode.value.conditionSetting)
86+
} else {
87+
// 重置为默认值
88+
condition.value = {
89+
conditionType: ConditionType.RULE,
90+
conditionExpression: '',
91+
conditionGroups: {
92+
and: true,
93+
conditions: [{
94+
and: true,
95+
rules: [{
96+
opCode: '==',
97+
leftSide: '',
98+
rightSide: ''
99+
}]
100+
}]
101+
}
102+
}
103+
}
69104
settingVisible.value = true
70105
}
71106
@@ -123,15 +158,13 @@ const saveConfig = async () => {
123158
return false
124159
}
125160
currentNode.value.showText = showText
126-
currentNode.value.conditionSetting!.conditionType = condition.value?.conditionType
127-
if (currentNode.value.conditionSetting?.conditionType === ConditionType.EXPRESSION) {
128-
currentNode.value.conditionSetting.conditionGroups = undefined
129-
currentNode.value.conditionSetting.conditionExpression = condition.value?.conditionExpression
130-
}
131-
if (currentNode.value.conditionSetting!.conditionType === ConditionType.RULE) {
132-
currentNode.value.conditionSetting!.conditionExpression = undefined
133-
currentNode.value.conditionSetting!.conditionGroups = condition.value?.conditionGroups
134-
}
161+
// 使用 cloneDeep 进行深拷贝
162+
currentNode.value.conditionSetting = cloneDeep({
163+
...currentNode.value.conditionSetting,
164+
conditionType: condition.value?.conditionType,
165+
conditionExpression: condition.value?.conditionType === ConditionType.EXPRESSION ? condition.value?.conditionExpression : undefined,
166+
conditionGroups: condition.value?.conditionType === ConditionType.RULE ? condition.value?.conditionGroups : undefined
167+
})
135168
}
136169
settingVisible.value = false
137170
return true

0 commit comments

Comments
 (0)