Explorar el Código

复制节点修改

duy hace 1 día
padre
commit
66dfb10331
Se han modificado 1 ficheros con 26 adiciones y 12 borrados
  1. 26 12
      src/views/manager/wbsinfo/TreeCopyModal.vue

+ 26 - 12
src/views/manager/wbsinfo/TreeCopyModal.vue

@@ -32,8 +32,7 @@
           @check="handleSourceCheck"
           check-strictly
           :default-expanded-keys="defaultExpandedKeys" 
-          
-         
+           
 
         ></el-tree>
       </div>
@@ -59,6 +58,7 @@
           :expand-on-click-node="false"
           @check="handleTargetCheck"
           :default-expanded-keys="defaultExpandedKeys" 
+        
            
         ></el-tree>
       </div>
@@ -165,21 +165,35 @@ export default {
   methods: {
     // 显示弹窗
     show() {
-    this.isShowTree = true;
-    this.isShowRight = true;
+      this.isShowTree = true;
+      this.isShowRight = true;
       this.visible = true;
+      
       // 重置选中状态
       this.selectedSourceNodes = [];
       this.selectedTargetNodes = [];
-      // 重置树
-      if (this.$refs.sourceTree) {
-        this.$refs.sourceTree.setCheckedKeys([]);
-      }
-      if (this.$refs.targetTree) {
-        this.$refs.targetTree.setCheckedKeys([]);
-      }
+      
+      // 使用 $nextTick 确保 DOM 已更新
+      this.$nextTick(() => {
+        // 设置默认选中的源节点
+        if (this.checkId && this.$refs.sourceTree) {
+          this.$refs.sourceTree.setCheckedKeys([this.checkId]);
+        
+           setTimeout(() => {
+              const checkedNodes = this.$refs.sourceTree.getCheckedNodes();
+              this.selectedSourceNodes = checkedNodes;
+              console.log('选中的节点:', this.selectedSourceNodes);
+            }, 3000);
+        }
+        
+        // 重置目标树
+        if (this.$refs.targetTree) {
+          this.$refs.targetTree.setCheckedKeys([]);
+        }
+      });
     },
 
+
     // 关闭弹窗
     handleClose() {
       this.visible = false;
@@ -298,7 +312,7 @@ export default {
         this.$message.success('复制成功');
         if (exitAfterLink) {
           this.handleClose();
-          this.clearSelection();
+         
   
         } else {
           // 清空选择但不关闭弹窗