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

代码生成树表新增(展开/折叠)

RuoYi лет назад: 4
Родитель
Сommit
6f7b02372e

+ 23 - 1
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index-tree.vue.vm

@@ -78,14 +78,24 @@
78 78
           v-hasPermi="['${moduleName}:${businessName}:add']"
79 79
         >新增</el-button>
80 80
       </el-col>
81
+      <el-col :span="1.5">
82
+        <el-button
83
+          type="info"
84
+          plain
85
+          icon="el-icon-sort"
86
+          size="mini"
87
+          @click="toggleExpandAll"
88
+        >展开/折叠</el-button>
89
+      </el-col>
81 90
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
82 91
     </el-row>
83 92
 
84 93
     <el-table
94
+      v-if="refreshTable"
85 95
       v-loading="loading"
86 96
       :data="${businessName}List"
87 97
       row-key="${treeCode}"
88
-      default-expand-all
98
+      :default-expand-all="isExpandAll"
89 99
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
90 100
     >
91 101
 #foreach($column in $columns)
@@ -293,6 +303,10 @@ export default {
293 303
       title: "",
294 304
       // 是否显示弹出层
295 305
       open: false,
306
+      // 是否展开,默认全部展开
307
+      isExpandAll: true,
308
+      // 重新渲染表格状态
309
+      refreshTable: true,
296 310
 #foreach ($column in $columns)
297 311
 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
298 312
 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
@@ -423,6 +437,14 @@ export default {
423 437
       this.open = true;
424 438
       this.title = "添加${functionName}";
425 439
     },
440
+    /** 展开/折叠操作 */
441
+    toggleExpandAll() {
442
+      this.refreshTable = false;
443
+      this.isExpandAll = !this.isExpandAll;
444
+      this.$nextTick(() => {
445
+        this.refreshTable = true;
446
+      });
447
+    },
426 448
     /** 修改按钮操作 */
427 449
     handleUpdate(row) {
428 450
       this.reset();

+ 21 - 1
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/v3/index-tree.vue.vm

@@ -76,14 +76,23 @@
76 76
           v-hasPermi="['${moduleName}:${businessName}:add']"
77 77
         >新增</el-button>
78 78
       </el-col>
79
+      <el-col :span="1.5">
80
+        <el-button
81
+          type="info"
82
+          plain
83
+          icon="Sort"
84
+          @click="toggleExpandAll"
85
+        >展开/折叠</el-button>
86
+      </el-col>
79 87
       <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
80 88
     </el-row>
81 89
 
82 90
     <el-table
91
+      v-if="refreshTable"
83 92
       v-loading="loading"
84 93
       :data="${businessName}List"
85 94
       row-key="${treeCode}"
86
-      default-expand-all
95
+      :default-expand-all="isExpandAll"
87 96
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
88 97
     >
89 98
 #foreach($column in $columns)
@@ -283,6 +292,8 @@ const open = ref(false);
283 292
 const loading = ref(true);
284 293
 const showSearch = ref(true);
285 294
 const title = ref("");
295
+const isExpandAll = ref(true);
296
+const refreshTable = ref(true);
286 297
 #foreach ($column in $columns)
287 298
 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
288 299
 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
@@ -405,6 +416,15 @@ async function handleAdd(row) {
405 416
   title.value = "添加${functionName}";
406 417
 }
407 418
 
419
+/** 展开/折叠操作 */
420
+function toggleExpandAll() {
421
+  refreshTable.value = false;
422
+  isExpandAll.value = !isExpandAll.value;
423
+  nextTick(() => {
424
+    refreshTable.value = true;
425
+  });
426
+}
427
+
408 428
 /** 修改按钮操作 */
409 429
 async function handleUpdate(row) {
410 430
   reset();