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

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

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

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

@@ -78,14 +78,24 @@
78
           v-hasPermi="['${moduleName}:${businessName}:add']"
78
           v-hasPermi="['${moduleName}:${businessName}:add']"
79
         >新增</el-button>
79
         >新增</el-button>
80
       </el-col>
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
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
90
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
82
     </el-row>
91
     </el-row>
83
 
92
 
84
     <el-table
93
     <el-table
94
+      v-if="refreshTable"
85
       v-loading="loading"
95
       v-loading="loading"
86
       :data="${businessName}List"
96
       :data="${businessName}List"
87
       row-key="${treeCode}"
97
       row-key="${treeCode}"
88
-      default-expand-all
98
+      :default-expand-all="isExpandAll"
89
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
99
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
90
     >
100
     >
91
 #foreach($column in $columns)
101
 #foreach($column in $columns)
@@ -293,6 +303,10 @@ export default {
293
       title: "",
303
       title: "",
294
       // 是否显示弹出层
304
       // 是否显示弹出层
295
       open: false,
305
       open: false,
306
+      // 是否展开,默认全部展开
307
+      isExpandAll: true,
308
+      // 重新渲染表格状态
309
+      refreshTable: true,
296
 #foreach ($column in $columns)
310
 #foreach ($column in $columns)
297
 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
311
 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
298
 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
312
 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
@@ -423,6 +437,14 @@ export default {
423
       this.open = true;
437
       this.open = true;
424
       this.title = "添加${functionName}";
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
     handleUpdate(row) {
449
     handleUpdate(row) {
428
       this.reset();
450
       this.reset();

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

@@ -76,14 +76,23 @@
76
           v-hasPermi="['${moduleName}:${businessName}:add']"
76
           v-hasPermi="['${moduleName}:${businessName}:add']"
77
         >新增</el-button>
77
         >新增</el-button>
78
       </el-col>
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
       <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
87
       <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
80
     </el-row>
88
     </el-row>
81
 
89
 
82
     <el-table
90
     <el-table
91
+      v-if="refreshTable"
83
       v-loading="loading"
92
       v-loading="loading"
84
       :data="${businessName}List"
93
       :data="${businessName}List"
85
       row-key="${treeCode}"
94
       row-key="${treeCode}"
86
-      default-expand-all
95
+      :default-expand-all="isExpandAll"
87
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
96
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
88
     >
97
     >
89
 #foreach($column in $columns)
98
 #foreach($column in $columns)
@@ -283,6 +292,8 @@ const open = ref(false);
283
 const loading = ref(true);
292
 const loading = ref(true);
284
 const showSearch = ref(true);
293
 const showSearch = ref(true);
285
 const title = ref("");
294
 const title = ref("");
295
+const isExpandAll = ref(true);
296
+const refreshTable = ref(true);
286
 #foreach ($column in $columns)
297
 #foreach ($column in $columns)
287
 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
298
 #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
288
 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
299
 #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
@@ -405,6 +416,15 @@ async function handleAdd(row) {
405
   title.value = "添加${functionName}";
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
 async function handleUpdate(row) {
429
 async function handleUpdate(row) {
410
   reset();
430
   reset();