瀏覽代碼

搜索提示修改

duy 1 周之前
父節點
當前提交
e764fedd5f
共有 1 個文件被更改,包括 84 次插入28 次删除
  1. 84 28
      src/views/manager/projectinfo/tree.vue

+ 84 - 28
src/views/manager/projectinfo/tree.vue

@@ -250,7 +250,7 @@
                 </div>
               </el-scrollbar>
             </div>
-            <div v-else>        
+            <div v-else  class="flex1 ov-hidden">        
               <el-scrollbar class="h-100p" >
               
               <el-tree
@@ -352,7 +352,7 @@
                 <el-table-column
                   align="center"
                   prop="tableName"
-                  label="表单名称111"
+                  label="表单名称"
                 ></el-table-column>
                 <el-table-column
                   align="center"
@@ -2713,6 +2713,7 @@ export default {
       this.isNodeType=val
       this.formData=[]
        localStorage.setItem('isNodeType',val);
+       this.filterText1=''
         
 
     },
@@ -3248,23 +3249,24 @@ export default {
         cancelButtonText: "取消",
       }).then(() => {
        
-        if(this.isNodeType){
-           removeTableById(row.id, this.projectid, this.id).then(() => {
-              this.formData.splice(index, 1);
-              this.$message({
-                type: "success",
-                message: "删除成功!",
-              });
-          });
-        }else{
-             delTabInfoAll(row.pkeyId).then(() => {
-              this.formData.splice(index, 1);
-              this.$message({
-                type: "success",
-                message: "删除成功!",
-              });
-          });
-        }
+       
+          if(this.isNodeType){
+              removeTableById(row.id, this.projectid, this.id).then(() => {
+                this.formData.splice(index, 1);
+                this.$message({
+                  type: "success",
+                  message: "删除成功!",
+                });
+            });
+          }else{
+              delTabInfoAll(row.pkeyId).then(() => {
+                this.formData.splice(index, 1);
+                this.$message({
+                  type: "success",
+                  message: "删除成功!",
+                });
+            });
+          }
       });
     },
     async hideMD(row) {
@@ -3433,22 +3435,76 @@ export default {
       this.searchtreeLoad = false;
     },
      searchTreeClick1() {
-      
-        // 强制重新加载整个树结构,从根节点开始
-  // this.$refs.treeByType.load({ level: 0, data: { id: 12345678910 } });
-  const lastDataNode=localStorage.getItem('lastDataNode');
-        this.loadNodeByType(lastDataNode);
+      if(!this.curTreeData.hasChildren){
+        this.$message.warning('请先选择一个父节点');
+        return;
+      }
+        // if (!this.filterText1.trim()) {
+        //   this.$message.warning('请输入搜索内容');
+        //   return;
+        // }
+        
+        // 保存当前状态
+            // 保存当前状态
+      this.saveTreeState();
+           // 清空缓存
+      this.cachedNodes.clear();
+        
+           // 重新加载选中节点及其子节点
+      this.reloadSelectedNode();
+
       },
       
   // 清空搜索
 clearSearch1() {
   this.filterText1 = '';
-  // 同样从根节点重新加载
-  // this.$refs.treeByType.load({ level: 0, data: { id: 12345678910 } });
-        const lastDataNode=localStorage.getItem('lastDataNode');
-        this.loadNodeByType(lastDataNode);
+
+    this.searchTreeClick1();
 
 },
+    // 重新加载选中节点
+ async reloadSelectedNode() {
+      const tree = this.$refs.treeByType;
+      if (!tree || !this.currentNodeKey) return;
+      
+      // 获取当前节点
+      const currentNode = tree.getNode(this.currentNodeKey);
+      if (!currentNode) return;
+      
+      // 标记为未加载,强制重新加载
+      currentNode.loaded = false;
+      currentNode.expand(); // 这会触发loadNodeByType
+      
+      // 恢复状态
+      await this.$nextTick();
+      tree.setCurrentKey(this.currentNodeKey);
+  },
+    // 重新加载树
+    reloadTree() {
+      const tree = this.$refs.treeByType;
+      if (!tree) return;
+      
+      // 清空根节点
+      const rootNode = tree.store.root;
+      const rootId = rootNode.childNodes[0].data.id || 'root';
+      tree.updateKeyChildren(rootId, []);
+      
+      // 强制重新加载根节点
+      const root = tree.getNode(rootId);
+      if (root) {
+        root.loaded = false;
+        root.expand();
+      }
+      
+      // 恢复状态
+      this.$nextTick(() => {
+        if (this.currentNodeKey) {
+          tree.setCurrentKey(this.currentNodeKey);
+        }
+      });
+    },
+
+
 // 刷新树数据