duy 2 роки тому
батько
коміт
5661128ea3
1 змінених файлів з 65 додано та 3 видалено
  1. 65 3
      src/views/exctab/ElementIdentification/index.vue

+ 65 - 3
src/views/exctab/ElementIdentification/index.vue

@@ -498,6 +498,7 @@
                 accordion
                 :show-checkbox="activeName == 'add'"
                 :check-strictly="true"
+                :default--checked-keys="selectNodeIds"
               >
               </el-tree>
 
@@ -512,6 +513,8 @@
                 :expand-on-click-node="false"
                 :filter-node-method="filterNode1"
                 v-show="GLExcelFromtag1"
+                :show-checkbox="activeName == 'add'"
+                :default--checked-keys="selectNodeIds"
               >
               </el-tree>
             </el-scrollbar>
@@ -720,12 +723,31 @@ export default {
       },
       titleIndex: -1,
       selectedId: "",
+      nodeIds:[],
+      nodeIds1:[],
+      selectNodeIds:[],
+  
     };
   },
   components: {
     draggable,
   },
+  watch:{
+    activeName(nweval){
+      console.log(nweval,'新增元素');
+       
+            
+    }
+  },
   methods: {
+    //数组去重
+    uniqueArr(arr1, arr2) {
+      //合并两个数组
+      arr1.push(...arr2)//或者arr1 = [...arr1,...arr2]
+      //去重
+      let arr3 = Array.from(new Set(arr1))//let arr3 = [...new Set(arr1)]
+      return arr3
+    },
     //搜索树
     treeFilter() {
       if (this.filterText) {
@@ -751,13 +773,38 @@ export default {
       }
     },
     clearInput() {
+      
       (this.selectedId = ""),
         (this.GLExcelFromtag1 = false),
         (this.GLExcelFromtag = true);
+             if( this.$refs.tree){
+              this.nodeIds = this.$refs.tree.getCheckedKeys();
+              }
+            if(this.$refs.treeall1){
+                this.nodeIds1 = this.$refs.treeall1.getCheckedKeys();
+            }   
+            this.selectNodeIds=this.uniqueArr(this.nodeIds,this.nodeIds1 )
+           console.log(this.selectNodeIds,'this.selectNodeIds111111');
+            // this.$refs.tree.setCheckedKeys(this.selectNodeIds)
+             
+             this.$nextTick(()=>{
+               this.$refs.tree.setCheckedKeys(this.selectNodeIds)
+             })
+
     },
     //搜索树1
     treeFilter1() {
       if (this.filterText1) {
+             if( this.$refs.tree){
+              this.nodeIds = this.$refs.tree.getCheckedKeys();
+              }
+            if(this.$refs.treeall1){
+                this.nodeIds1 = this.$refs.treeall1.getCheckedKeys();
+            }
+            
+          this.selectNodeIds=this.uniqueArr(this.nodeIds,this.nodeIds1 )
+          this.$refs.treeall1.setCheckedKeys(this.selectNodeIds)
+          console.log(this.selectNodeIds,'this.selectNodeIds');
         this.GLExcelFromtag1 = true;
         this.GLExcelFromtag = false;
         this.treeloading1 = true;
@@ -1128,8 +1175,21 @@ export default {
             this.addElementForm.tableType &&
             this.addElementForm.tableOwner
           ) {
-            let nodeIds = this.$refs.tree.getCheckedKeys();
-            if (nodeIds.length < 1) {
+            // let nodeIds = this.$refs.tree.getCheckedKeys();
+            // let nodeIds1 = this.$refs.treeall1.getCheckedKeys();
+            // console.log(nodeIds,'nodeIds');
+            // console.log(nodeIds1,'nodeIds1');
+            if( this.$refs.tree){
+               this.nodeIds = this.$refs.tree.getCheckedKeys();
+            }
+            if(this.$refs.treeall1){
+               this.nodeIds1 = this.$refs.treeall1.getCheckedKeys();
+            }
+            
+            this.selectNodeIds=this.uniqueArr(this.nodeIds,this.nodeIds1 )
+            console.log(this.selectNodeIds,'去重的数组');
+           
+            if (this.selectNodeIds.length < 1) {
               this.$message({
                 type: "warning",
                 message: "至少勾选一个节点",
@@ -1143,7 +1203,7 @@ export default {
               tableOwner: this.addElementForm.tableOwner,
               wbsId: this.addElementForm.wbsId,
               elementList: this.tableData,
-              nodeIds: nodeIds,
+              nodeIds: this.selectNodeIds,
               excelTabId: this.from.id,
               submitStatus: 2,
             });
@@ -1160,6 +1220,7 @@ export default {
           message: "请先选择WBS树节点表单",
         });
       }
+      this.activeName="link"
     },
     async submitExcelRelationWbsTreeAndElement(da) {
       //保存接口
@@ -1229,6 +1290,7 @@ export default {
     handleClose() {
       this.newElements = [];
       this.addNewElementDialog = false;
+      this.activeName='link'
     },
 
     addNewElement() {