|
@@ -265,12 +265,32 @@ export default {
|
|
|
this.handleClose();
|
|
|
} else {
|
|
|
// 清空选择但不关闭弹窗
|
|
|
- this.$refs.sourceTree.setCheckedKeys([]);
|
|
|
- this.$refs.targetTree.setCheckedKeys([]);
|
|
|
- this.selectedSourceNodes = [];
|
|
|
- this.selectedTargetNodes = [];
|
|
|
+ this.clearSelections();
|
|
|
}
|
|
|
});
|
|
|
+ },
|
|
|
+ // 新增清空选择的方法
|
|
|
+ clearSelections() {
|
|
|
+ // 确保组件已加载
|
|
|
+ if (this.$refs.sourceTree) {
|
|
|
+ // 对于懒加载树,先获取所有已勾选的节点ID
|
|
|
+ const sourceCheckedKeys = this.$refs.sourceTree.getCheckedKeys();
|
|
|
+ // 逐个取消勾选
|
|
|
+ sourceCheckedKeys.forEach(key => {
|
|
|
+ this.$refs.sourceTree.setChecked(key, false, true);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.$refs.targetTree) {
|
|
|
+ const targetCheckedKeys = this.$refs.targetTree.getCheckedKeys();
|
|
|
+ targetCheckedKeys.forEach(key => {
|
|
|
+ this.$refs.targetTree.setChecked(key, false, true);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 手动清空数据
|
|
|
+ this.selectedSourceNodes = [];
|
|
|
+ this.selectedTargetNodes = [];
|
|
|
}
|
|
|
}
|
|
|
};
|