Browse Source

复制节点更改

duy 19 hours ago
parent
commit
5b76ff8b13
1 changed files with 24 additions and 4 deletions
  1. 24 4
      src/views/manager/wbsinfo/TreeCopyModal.vue

+ 24 - 4
src/views/manager/wbsinfo/TreeCopyModal.vue

@@ -265,12 +265,32 @@ export default {
           this.handleClose();
           this.handleClose();
         } else {
         } 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 = [];
     }
     }
   }
   }
 };
 };