浏览代码

添加搜索节点功能

duy 2 年之前
父节点
当前提交
f0b6979afe
共有 1 个文件被更改,包括 63 次插入23 次删除
  1. 63 23
      src/views/exctab/ElementIdentification/index.vue

+ 63 - 23
src/views/exctab/ElementIdentification/index.vue

@@ -471,7 +471,7 @@
               </el-option>
             </el-select>
             <el-scrollbar style="height: 50vh">
-              <div class="flex" style="margin-top: 10px">
+              <div class="flex" style="margin-top: 10px" v-if="isShowInput">
                 <el-input
                   size="small"
                   placeholder="输入关键字搜索"
@@ -506,11 +506,11 @@
                 ref="treeall1"
                 v-loading="treeloading1"
                 :data="allTreeData1"
-                :props="treeProps"
-                @node-click="handleNodeClick"
+                :props="treeProps1"
+                @node-click="handleNodeClickExcel"
                 node-key="id"
                 :expand-on-click-node="false"
-                :filter-node-method="filterNode"
+                :filter-node-method="filterNode1"
                 v-show="GLExcelFromtag1"
               >
               </el-tree>
@@ -628,7 +628,7 @@ import {
 } from "@/api/exctab/excelmodel";
 import { dictionarydataType } from "@/api/exctab/editelement";
 import { getColByTabId } from "@/api/manager/AdjustForm";
-import { selectByNodeTable } from "@/api/manager/wbstree";
+import { selectByNodeTable, getAlltree } from "@/api/manager/wbstree";
 import { getDictionary } from "@/api/system/dict";
 import Vue from "vue";
 import draggable from "vuedraggable";
@@ -642,6 +642,11 @@ export default {
         children: "children",
         isLeaf: "hasChildren",
       },
+      treeProps1: {
+        label: "title",
+        children: "children",
+        isLeaf: "hasChildren",
+      },
       //#endregion
       excelSrc: "",
       from: {
@@ -677,6 +682,7 @@ export default {
           }
         },
       },
+      isShowInput: false,
       exceldata: [], //清表模板树数据
       addTableData: [], //新增元素信息表
       exceltypeData: [], //清表类型
@@ -733,6 +739,7 @@ export default {
             this.treeloading = false;
             this.allTreeData = res.data.data;
             this.$nextTick(() => {
+              console.log("过滤");
               this.$refs.treeall.filter(this.filterText);
             });
           });
@@ -753,29 +760,34 @@ export default {
       if (this.filterText1) {
         this.GLExcelFromtag1 = true;
         this.GLExcelFromtag = false;
-        if (!this.allTreeData1.length) {
-          this.treeloading1 = true;
-          tabLazytreeAll({
-            modeId: this.selectedId,
-            name: "",
-          }).then((res) => {
-            this.treeloading1 = false;
-            this.allTreeData1 = res.data.data;
-            this.$nextTick(() => {
-              this.$refs.treeall1.filter(this.filterText1);
-            });
+        this.treeloading1 = true;
+        console.log(this.selectedId, "selectedId");
+        console.log(this.GLExcelFrom.name, "this.GLExcelFrom.name");
+        // tabLazytreeAll({
+        //   modeId: this.GLExcelFrom.name,
+        //   name: "",
+        // })
+        getAlltree("000000", 1, this.GLExcelFrom.name).then((res) => {
+          this.treeloading1 = false;
+          this.allTreeData1 = res.data.data;
+          console.log(this.exceldata, "this.exceldata");
+          console.log(this.GLExcelFromtag, "this.GLExcelFromtag");
+
+          this.$nextTick(() => {
+            console.log("过滤2", this.filterText1);
+            this.$refs.treeall1.filter(this.filterText1);
           });
-        } else {
-          this.$refs.treeall1.filter(this.filterText1);
-        }
-      } else {
-        this.GLExcelFromtag1 = false;
+        });
       }
     },
     filterNode(value, data) {
       if (!value) return true;
       return data.name.indexOf(value) !== -1;
     },
+    filterNode1(value, data) {
+      if (!value) return true;
+      return data.title.indexOf(value) !== -1;
+    },
     //#region
     handleNodeClick(data) {
       //树节点点击事件
@@ -906,9 +918,29 @@ export default {
       }
 
       this.getWbsTypeList();
+
       this.AssociatedPublicTap = true;
+      //清除数据
+      this.filterText1 = "";
+      this.exceldata = [];
+      this.allTreeData1 = [];
+      this.selectedId = "";
+      this.GLExcelFrom.name = "";
+      this.isShowInput = false;
+
+      //清理之前填写的数据
+      this.addElementForm.wbsId = "";
+      this.addElementForm.tableOwner = "";
+
+      if (this.$refs.tree) {
+        this.$refs.tree.setCheckedKeys([]);
+        this.$refs.tree.setCurrentKey(null);
+      }
+
+      this.addTableData = [];
     },
     AssociatedPublicClose() {
+      console.log("AssociatedPublicClose");
       //关联公共WBS模板关闭事件
       // this.addElementForm = {
       //   id: "",
@@ -949,13 +981,19 @@ export default {
         return resolve(await this.getLazytree(node.data.id));
       }
     },
-    changetherr() {
+
+    changetherr(item) {
+      console.log(item, "item");
+      console.log(this.GLExcelFrom.name, "name");
       //下拉框change事件
       this.GLExcelFromtag = false;
+      this.GLExcelFromtag1 = false;
+      this.filterText1 = "";
       if (this.GLExcelFrom.name != "") {
         this.GLExcelFrom.search = "";
         this.exceldata = [];
         this.addTableData = [];
+        this.isShowInput = false;
         this.addElementForm.wbsId = "";
         this.$nextTick(() => {
           this.GLExcelFromtag = true;
@@ -970,7 +1008,7 @@ export default {
     async getWbsTypeList() {
       //获取清表模板信息
       const { data: res } = await getWbsTypeList({ wbstype: 1 });
-      console.log(res);
+
       if (res.code === 200 && res.msg === "操作成功") {
         this.GLExcelData = res.data;
       }
@@ -984,6 +1022,8 @@ export default {
       });
       console.log(res);
       if (res.code === 200 && res.msg === "操作成功") {
+        this.isShowInput = true;
+        console.log(this.isShowInput, " this.isShowInput");
         res.data.forEach((val) => {
           val.isExistForm = !!val.isExistForm;
         });