Commit 1b2dc570de9bca616f664838c147e9f81fdc2f1c

Authored by YunaiV
1 parent f564137f

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

yudao-ui-admin/src/views/system/dept/index.vue
@@ -17,12 +17,16 @@ @@ -17,12 +17,16 @@
17 17
18 <el-row :gutter="10" class="mb8"> 18 <el-row :gutter="10" class="mb8">
19 <el-col :span="1.5"> 19 <el-col :span="1.5">
20 - <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:dept:create']">新增</el-button> 20 + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  21 + v-hasPermi="['system:dept:create']">新增</el-button>
  22 + </el-col>
  23 + <el-col :span="1.5">
  24 + <el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">展开/折叠</el-button>
21 </el-col> 25 </el-col>
22 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> 26 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
23 </el-row> 27 </el-row>
24 28
25 - <el-table v-loading="loading" :data="deptList" row-key="id" default-expand-all 29 + <el-table v-if="refreshTable" v-loading="loading" :data="deptList" row-key="id" :default-expand-all="isExpandAll"
26 :tree-props="{children: 'children', hasChildren: 'hasChildren'}"> 30 :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
27 <el-table-column prop="name" label="部门名称" width="260"></el-table-column> 31 <el-table-column prop="name" label="部门名称" width="260"></el-table-column>
28 <el-table-column prop="leader" label="负责人" :formatter="userNicknameFormat" width="120"/> 32 <el-table-column prop="leader" label="负责人" :formatter="userNicknameFormat" width="120"/>
@@ -131,6 +135,12 @@ export default { @@ -131,6 +135,12 @@ export default {
131 title: "", 135 title: "",
132 // 是否显示弹出层 136 // 是否显示弹出层
133 open: false, 137 open: false,
  138 + // 是否展开,默认全部展开
  139 + isExpandAll: true,
  140 + // 重新渲染表格状态
  141 + refreshTable: true,
  142 + // 是否展开
  143 + expand: false,
134 // 状态数据字典 144 // 状态数据字典
135 statusOptions: [], 145 statusOptions: [],
136 // 查询参数 146 // 查询参数
@@ -255,6 +265,14 @@ export default { @@ -255,6 +265,14 @@ export default {
255 this.deptOptions = this.handleTree(response.data, "id"); 265 this.deptOptions = this.handleTree(response.data, "id");
256 }); 266 });
257 }, 267 },
  268 + /** 展开/折叠操作 */
  269 + toggleExpandAll() {
  270 + this.refreshTable = false;
  271 + this.isExpandAll = !this.isExpandAll;
  272 + this.$nextTick(() => {
  273 + this.refreshTable = true;
  274 + });
  275 + },
258 /** 修改按钮操作 */ 276 /** 修改按钮操作 */
259 handleUpdate(row) { 277 handleUpdate(row) {
260 this.reset(); 278 this.reset();
yudao-ui-admin/src/views/system/menu/index.vue
@@ -20,10 +20,13 @@ @@ -20,10 +20,13 @@
20 <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" 20 <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
21 v-hasPermi="['system:menu:create']">新增</el-button> 21 v-hasPermi="['system:menu:create']">新增</el-button>
22 </el-col> 22 </el-col>
  23 + <el-col :span="1.5">
  24 + <el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">展开/折叠</el-button>
  25 + </el-col>
23 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> 26 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
24 </el-row> 27 </el-row>
25 28
26 - <el-table v-loading="loading" :data="menuList" row-key="id" 29 + <el-table v-if="refreshTable" v-loading="loading" :data="menuList" row-key="id" :default-expand-all="isExpandAll"
27 :tree-props="{children: 'children', hasChildren: 'hasChildren'}"> 30 :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
28 <el-table-column prop="name" label="菜单名称" :show-overflow-tooltip="true" width="250"></el-table-column> 31 <el-table-column prop="name" label="菜单名称" :show-overflow-tooltip="true" width="250"></el-table-column>
29 <el-table-column prop="icon" label="图标" align="center" width="100"> 32 <el-table-column prop="icon" label="图标" align="center" width="100">
@@ -155,6 +158,10 @@ export default { @@ -155,6 +158,10 @@ export default {
155 title: "", 158 title: "",
156 // 是否显示弹出层 159 // 是否显示弹出层
157 open: false, 160 open: false,
  161 + // 是否展开,默认全部折叠
  162 + isExpandAll: false,
  163 + // 重新渲染表格状态
  164 + refreshTable: true,
158 // 查询参数 165 // 查询参数
159 queryParams: { 166 queryParams: {
160 name: undefined, 167 name: undefined,
@@ -249,6 +256,14 @@ export default { @@ -249,6 +256,14 @@ export default {
249 this.resetForm("queryForm"); 256 this.resetForm("queryForm");
250 this.handleQuery(); 257 this.handleQuery();
251 }, 258 },
  259 + /** 展开/折叠操作 */
  260 + toggleExpandAll() {
  261 + this.refreshTable = false;
  262 + this.isExpandAll = !this.isExpandAll;
  263 + this.$nextTick(() => {
  264 + this.refreshTable = true;
  265 + });
  266 + },
252 /** 新增按钮操作 */ 267 /** 新增按钮操作 */
253 handleAdd(row) { 268 handleAdd(row) {
254 this.reset(); 269 this.reset();