Browse Source

复制节点修改

duy 1 ngày trước cách đây
mục cha
commit
bc6bdfb41b
1 tập tin đã thay đổi với 36 bổ sung43 xóa
  1. 36 43
      src/views/manager/wbsinfo/TreeCopyModal.vue

+ 36 - 43
src/views/manager/wbsinfo/TreeCopyModal.vue

@@ -293,51 +293,44 @@ export default {
     },
 
     // 处理关联操作
-    handleLink(exitAfterLink) {
- 
-      
-      if (this.selectedSourceNodes.length === 0 || this.selectedTargetNodes.length === 0) {
-        this.$message.warning('请至少选择一个源节点和一个目标节点');
-        return;
-      }
+   handleLink(exitAfterLink) {
+  if (this.selectedSourceNodes.length === 0 || this.selectedTargetNodes.length === 0) {
+    this.$message.warning('请至少选择一个源节点和一个目标节点');
+    return;
+  }
 
-      // 准备关联数据
-      const linkData = {
-        sourceNodes: this.selectedSourceNodes.map(node => node.id),
-        targetNodes: this.selectedTargetNodes.map(node => node.id)
-      };
-
-      // 触发父组件的关联事件
-      this.$emit('link', linkData, () => {
-        this.$message.success('复制成功');
-        if (exitAfterLink) {
-          this.handleClose();
-         
-  
-        } else {
-          // 清空选择但不关闭弹窗
-          this.clearSelections(); // 清空选择但不关闭弹窗
-    
+  // 准备关联数据
+  const linkData = {
+    sourceNodes: this.selectedSourceNodes.map(node => node.id),
+    targetNodes: this.selectedTargetNodes.map(node => node.id)
+  };
 
-        }
-      });
-       this.isShowTree=false
-          
-          setTimeout(() => {
-            this.isShowTree=true
-         
-          }, 1000);
-            this.isShowRight=false
-          
-          setTimeout(() => {
-            this.isShowRight=true
-        this.selectedSourceNodes = [];
-          this.selectedTargetNodes = [];
-
-          this.checkId = ''
-         
-          }, 1000);
-    },
+  // 触发父组件的关联事件,将刷新操作移到回调中
+  this.$emit('link', linkData, () => {
+    this.$message.success('复制成功');
+    
+    // 接口调用成功后执行的操作
+    this.isShowTree = false;
+    setTimeout(() => {
+      this.isShowTree = true;
+    }, 1000);
+    
+    this.isShowRight = false;
+    setTimeout(() => {
+      this.isShowRight = true;
+      this.selectedSourceNodes = [];
+      this.selectedTargetNodes = [];
+      this.checkId = '';
+    }, 1000);
+
+    if (exitAfterLink) {
+      this.handleClose();
+    } else {
+      // 清空选择但不关闭弹窗
+      this.clearSelections();
+    }
+  });
+},
     // 新增清空选择的方法
     clearSelections() {
       // 确保组件已加载