浏览代码

处理机构查询框可能两次触发的问题

jiawuxian 1 年之前
父节点
当前提交
bcb25c4fd5
共有 1 个文件被更改,包括 12 次插入8 次删除
  1. 12 8
      src/components/orgTree/orgQuerySelector.vue

+ 12 - 8
src/components/orgTree/orgQuerySelector.vue

@@ -120,24 +120,27 @@ export default {
           this.businessTree,
           this.wholeTree
         );
+
+        let treeList=null;
         if (this.hangsheTree) {
-          this.treeList = this.$store.getters.depTree;
+          treeList = this.$store.getters.depTree;
         } else if (this.businessTree) {
-          this.treeList = this.$store.getters.businessTree;
+          treeList = this.$store.getters.businessTree;
         } else if (this.wholeTree) {
-          console.log("wholeTree", this.$store.getters.wholeTree);
-          this.treeList = this.$store.getters.wholeTree;
+          treeList = this.$store.getters.wholeTree;
         } else {
-          this.treeList = this.$store.getters.orgTree;
+          treeList = this.$store.getters.orgTree;
         }
 
-        this.dataFn(this.treeList);
+        this.dataFn(treeList);
       }
     },
     dataFn(arr) {
       if (!arr || arr.length === 0) return;
       // console.log(arr, "arrr");
-
+      if(arr==this.treeList){
+        return;
+      }
       if (arr && arr.length > 0) {
         if (arr.length == 1) {
           arr[0].isDefaultExpanded = true;
@@ -157,6 +160,7 @@ export default {
         }
 
         if (defaultSelectedNode) {
+          // console.trace();
           this.$emit("defaultKey", defaultSelectedNode.id);
           this.$emit("defaultOrg", { ...defaultSelectedNode });
         }
@@ -229,7 +233,7 @@ export default {
     }
   },
   mounted() {
-    this.getDeptTree();
+     this.getDeptTree();
   },
 };
 </script>