mirror of
https://gitee.com/myxzgzs/boyue-ui-admin-vue3
synced 2025-08-08 16:32:43 +08:00
优化代码 切换点击条件分支后带来的 条件切换问题
This commit is contained in:
parent
b2ddefe4a0
commit
c7b135e1f8
@ -63,9 +63,43 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
const settingVisible = ref(false)
|
const settingVisible = ref(false)
|
||||||
const currentNode = ref<SimpleFlowNode>(props.conditionNode)
|
const currentNode = ref<SimpleFlowNode>(props.conditionNode)
|
||||||
const condition = ref<any>()
|
const condition = ref<any>({
|
||||||
|
conditionType: ConditionType.RULE, // 设置默认值
|
||||||
|
conditionExpression: '',
|
||||||
|
conditionGroups: {
|
||||||
|
and: true,
|
||||||
|
conditions: [{
|
||||||
|
and: true,
|
||||||
|
rules: [{
|
||||||
|
opCode: '==',
|
||||||
|
leftSide: '',
|
||||||
|
rightSide: ''
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
})
|
||||||
const open = () => {
|
const open = () => {
|
||||||
condition.value = currentNode.value.conditionSetting
|
// 如果有已存在的配置则使用,否则使用默认值
|
||||||
|
if (currentNode.value.conditionSetting) {
|
||||||
|
condition.value = JSON.parse(JSON.stringify(currentNode.value.conditionSetting))
|
||||||
|
} else {
|
||||||
|
// 重置为默认值
|
||||||
|
condition.value = {
|
||||||
|
conditionType: ConditionType.RULE,
|
||||||
|
conditionExpression: '',
|
||||||
|
conditionGroups: {
|
||||||
|
and: true,
|
||||||
|
conditions: [{
|
||||||
|
and: true,
|
||||||
|
rules: [{
|
||||||
|
opCode: '==',
|
||||||
|
leftSide: '',
|
||||||
|
rightSide: ''
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
settingVisible.value = true
|
settingVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,15 +157,13 @@ const saveConfig = async () => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
currentNode.value.showText = showText
|
currentNode.value.showText = showText
|
||||||
currentNode.value.conditionSetting!.conditionType = condition.value?.conditionType
|
// 深拷贝保存的条件设置,避免引用问题
|
||||||
if (currentNode.value.conditionSetting?.conditionType === ConditionType.EXPRESSION) {
|
currentNode.value.conditionSetting = JSON.parse(JSON.stringify({
|
||||||
currentNode.value.conditionSetting.conditionGroups = undefined
|
...currentNode.value.conditionSetting,
|
||||||
currentNode.value.conditionSetting.conditionExpression = condition.value?.conditionExpression
|
conditionType: condition.value?.conditionType,
|
||||||
}
|
conditionExpression: condition.value?.conditionType === ConditionType.EXPRESSION ? condition.value?.conditionExpression : undefined,
|
||||||
if (currentNode.value.conditionSetting!.conditionType === ConditionType.RULE) {
|
conditionGroups: condition.value?.conditionType === ConditionType.RULE ? condition.value?.conditionGroups : undefined
|
||||||
currentNode.value.conditionSetting!.conditionExpression = undefined
|
}))
|
||||||
currentNode.value.conditionSetting!.conditionGroups = condition.value?.conditionGroups
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
settingVisible.value = false
|
settingVisible.value = false
|
||||||
return true
|
return true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user