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

菜单&部门新增展开/折叠功能

RuoYi лет назад: 4
Родитель
Сommit
d2de744c3f
2 измененных файлов с 49 добавлено и 2 удалено
  1. 26 2
      ruoyi-ui/src/views/system/dept/index.vue
  2. 23 0
      ruoyi-ui/src/views/system/menu/index.vue

+ 26 - 2
ruoyi-ui/src/views/system/dept/index.vue

@@ -37,14 +37,24 @@
37 37
           v-hasPermi="['system:dept:add']"
38 38
         >新增</el-button>
39 39
       </el-col>
40
+      <el-col :span="1.5">
41
+        <el-button
42
+          type="info"
43
+          plain
44
+          icon="el-icon-sort"
45
+          size="mini"
46
+          @click="toggleExpandAll"
47
+        >展开/折叠</el-button>
48
+      </el-col>
40 49
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
41 50
     </el-row>
42 51
 
43 52
     <el-table
53
+      v-if="refreshTable"
44 54
       v-loading="loading"
45 55
       :data="deptList"
46 56
       row-key="deptId"
47
-      default-expand-all
57
+      :default-expand-all="isExpandAll"
48 58
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
49 59
     >
50 60
       <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
@@ -164,6 +174,12 @@ export default {
164 174
       title: "",
165 175
       // 是否显示弹出层
166 176
       open: false,
177
+      // 是否展开,默认全部展开
178
+      isExpandAll: true,
179
+      // 重新渲染表格状态
180
+      refreshTable: true,
181
+      // 是否展开
182
+      expand: false,
167 183
       // 状态数据字典
168 184
       statusOptions: [],
169 185
       // 查询参数
@@ -267,6 +283,14 @@ export default {
267 283
 	        this.deptOptions = this.handleTree(response.data, "deptId");
268 284
       });
269 285
     },
286
+    /** 展开/折叠操作 */
287
+    toggleExpandAll() {
288
+      this.refreshTable = false;
289
+      this.isExpandAll = !this.isExpandAll;
290
+      this.$nextTick(() => {
291
+        this.refreshTable = true;
292
+      });
293
+    },
270 294
     /** 修改按钮操作 */
271 295
     handleUpdate(row) {
272 296
       this.reset();
@@ -314,4 +338,4 @@ export default {
314 338
     }
315 339
   }
316 340
 };
317
-</script>
341
+</script>

+ 23 - 0
ruoyi-ui/src/views/system/menu/index.vue

@@ -37,13 +37,24 @@
37 37
           v-hasPermi="['system:menu:add']"
38 38
         >新增</el-button>
39 39
       </el-col>
40
+      <el-col :span="1.5">
41
+        <el-button
42
+          type="info"
43
+          plain
44
+          icon="el-icon-sort"
45
+          size="mini"
46
+          @click="toggleExpandAll"
47
+        >展开/折叠</el-button>
48
+      </el-col>
40 49
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
41 50
     </el-row>
42 51
 
43 52
     <el-table
53
+      v-if="refreshTable"
44 54
       v-loading="loading"
45 55
       :data="menuList"
46 56
       row-key="menuId"
57
+      :default-expand-all="isExpandAll"
47 58
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
48 59
     >
49 60
       <el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column>
@@ -275,6 +286,10 @@ export default {
275 286
       title: "",
276 287
       // 是否显示弹出层
277 288
       open: false,
289
+      // 是否展开,默认全部折叠
290
+      isExpandAll: false,
291
+      // 重新渲染表格状态
292
+      refreshTable: true,
278 293
       // 显示状态数据字典
279 294
       visibleOptions: [],
280 295
       // 菜单状态数据字典
@@ -384,6 +399,14 @@ export default {
384 399
       this.open = true;
385 400
       this.title = "添加菜单";
386 401
     },
402
+    /** 展开/折叠操作 */
403
+    toggleExpandAll() {
404
+      this.refreshTable = false;
405
+      this.isExpandAll = !this.isExpandAll;
406
+      this.$nextTick(() => {
407
+        this.refreshTable = true;
408
+      });
409
+    },
387 410
     /** 修改按钮操作 */
388 411
     handleUpdate(row) {
389 412
       this.reset();