Browse Source

树节点搜索,也查询出子节点

gangyj 2 năm trước cách đây
mục cha
commit
61d799448c
1 tập tin đã thay đổi với 25 bổ sung3 xóa
  1. 25 3
      src/views/manager/archivetree.vue

+ 25 - 3
src/views/manager/archivetree.vue

@@ -714,10 +714,32 @@ export default {
         this.data = res.data
       }
     },
-    filterNode (value, data) {//筛选条件
-      if (!value) return true;
-      return data.title.indexOf(value) !== -1;
+    filterNode (value,data,node) {//筛选条件
+      // 如果什么都没填就直接返回
+      if(!value){
+          return true;
+      }
+
+      let _array = [];//这里使用数组存储 只是为了存储值。
+      this.getReturnNode(node,_array,value);
+      let result = false;
+      
+      _array.forEach((item)=>{
+          result = result || item;
+      });
+      return result;
+    },
+    //判断节点是否匹配
+    getReturnNode(node,_array,value){
+      let isPass = node.data &&  node.data.title && node.data.title.indexOf(value) !== -1;
+      isPass?_array.push(isPass):'';
+
+      //判断节点是否是父节点
+      if(!isPass && node.level!=1 && node.parent){
+          this.getReturnNode(node.parent,_array,value);
+      }
     },
+
     //#endregion
 
     //#region 新增编辑节点弹框