Просмотр исходного кода

Merge branch 'master' into 'master'

merge

See merge request spfm/spfm-market-front!347
杨壁繁 2 лет назад
Родитель
Сommit
cd56a39eff
1 измененных файлов с 58 добавлено и 24 удалено
  1. 58 24
      src/components/newTree.vue

+ 58 - 24
src/components/newTree.vue

@@ -2,6 +2,8 @@
   <div class="flex-box">
     <div class="treebox">
       <div class="tree-text">组织机构</div>
+      <el-input placeholder="可按名字匹配所在部门" v-model="filterText">
+      </el-input>
       <el-tree
         ref="tree"
         @node-click="handleNodeClick"
@@ -26,7 +28,6 @@
       <el-transfer
         v-model="value"
         :titles="['待选人员', '已选人员']"
-        filterable
         @change="handleCheckChange"
         :data="transferList"
       ></el-transfer>
@@ -39,9 +40,11 @@ export default {
   props: ["defaultList", "type"],
   data() {
     return {
+      filterTexts: "",
+      filterText: "",
       transferList: [],
       treeList: [],
-      treeLists:[],
+      treeLists: [],
       rightList: [],
       value: [],
       newArr: [],
@@ -56,6 +59,24 @@ export default {
   },
   methods: {
     handleNodeClick(v) {
+      for(let i = v.children.length-1;i>=0;i--){
+        if(v.children[i].haveUserFlag == "N"){
+          v.children.splice(i, 1);
+        }
+      }
+      // v.children.map((item,index) =>{
+        
+      //   if(item.haveUserFlag == "N"){
+      //     v.children.splice(index, 1);
+      //   }
+      //   console.log(v.children);
+      // })
+      let list = {
+        groupId: v.o,
+      };
+      if (this.filterTexts) {
+        list.loginNameStr = this.filterTexts;
+      }
       if (v.o !== this.treeId) {
         if (this.value.length !== 0) {
           let a = [];
@@ -87,22 +108,20 @@ export default {
       }
       if (v.o !== this.treeId) {
         this.$http({
-          url: "/sysmgr/sysuserinfo/queryList",
+          url: "/sysmgr/sysuserinfo/queryListByName",
           method: "post",
           headers: {
             "Content-Type": "application/json",
           },
-          data: {
-            groupId: v.o,
-          },
+          data:list
         }).then((res) => {
+          v.children = v.children ? v.children : [];
           this.treeId = v.o;
-          this.treeLists = res.data
+          this.treeLists = res.data;
           res.data.map((item, index) => {
             this.transferList.push({
               label: item.loginNameStr,
-              key: item.loginNoStr
-,
+              key: item.loginNoStr,
             });
           });
         });
@@ -110,20 +129,29 @@ export default {
         console.log(this.transferList);
       }
     },
-    getTree(v) {
+    getTree(v,e) {
+      let list = {
+        parentorgid: v,
+        // functionName: e,
+      };
+      if (e) {
+        list.functionName = e;
+      }
+      this.loading = true;
       this.$http({
         url: "/sysmgr/csysdept/queryAllList",
         method: "post",
         headers: {
           "Content-Type": "application/json",
         },
-        data: {
-          parentorgid: v,
-        },
+        data: list,
       }).then((res) => {
+        this.loading = false;
         this.treeList = res.data;
-
-        console.log(this.treeLists);
+        let list = res.data[0].children.filter((item, i, array) => {
+          return item.haveUserFlag === "Y";
+        });
+        this.treeList[0].children = list;
       });
     },
     handleCheckChange(v) {
@@ -143,24 +171,30 @@ export default {
       //   }
       // }
       // console.log(opt);
-      console.log(this.transferList);
-      console.log(this.value);
       let opt = [];
-      this.transferList.map((item) =>{
-        this.value.map((items) =>{
-          if(item.key === items){
-            opt.push(item)
+      this.transferList.map((item) => {
+        this.value.map((items) => {
+          if (item.key === items) {
+            opt.push(item);
           }
-        })
-      })
+        });
+      });
       console.log(opt);
-      this.$emit("treeCheck",opt);
+      this.$emit("treeCheck", opt);
     },
   },
   created() {
     this.getTree();
     this.defaultListc = this.defaultList;
   },
+  watch: {
+    filterText(val) {
+      // this.$refs.tree.filter(val);
+      console.log(val);
+      this.filterTexts = val;
+      this.getTree("", this.filterTexts);
+    },
+  },
 };
 </script>