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 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 = () => {
|
||||
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
|
||||
}
|
||||
|
||||
@ -123,15 +157,13 @@ const saveConfig = async () => {
|
||||
return false
|
||||
}
|
||||
currentNode.value.showText = showText
|
||||
currentNode.value.conditionSetting!.conditionType = condition.value?.conditionType
|
||||
if (currentNode.value.conditionSetting?.conditionType === ConditionType.EXPRESSION) {
|
||||
currentNode.value.conditionSetting.conditionGroups = undefined
|
||||
currentNode.value.conditionSetting.conditionExpression = condition.value?.conditionExpression
|
||||
}
|
||||
if (currentNode.value.conditionSetting!.conditionType === ConditionType.RULE) {
|
||||
currentNode.value.conditionSetting!.conditionExpression = undefined
|
||||
currentNode.value.conditionSetting!.conditionGroups = condition.value?.conditionGroups
|
||||
}
|
||||
// 深拷贝保存的条件设置,避免引用问题
|
||||
currentNode.value.conditionSetting = JSON.parse(JSON.stringify({
|
||||
...currentNode.value.conditionSetting,
|
||||
conditionType: condition.value?.conditionType,
|
||||
conditionExpression: condition.value?.conditionType === ConditionType.EXPRESSION ? condition.value?.conditionExpression : undefined,
|
||||
conditionGroups: condition.value?.conditionType === ConditionType.RULE ? condition.value?.conditionGroups : undefined
|
||||
}))
|
||||
}
|
||||
settingVisible.value = false
|
||||
return true
|
||||
|
Loading…
x
Reference in New Issue
Block a user