From baeed2e8d3a82f94e80d04ea47c95b122fcf93dd Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期二, 02 二月 2021 16:25:37 +0800 Subject: [PATCH] 修复角色管理-编辑角色-功能权限显示异常 --- ruoyi-ui/src/views/system/menu/index.vue | 123 +++++++++++++++++++++++++++++------------ 1 files changed, 87 insertions(+), 36 deletions(-) diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue index 9f2d04f..734e8e8 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -1,7 +1,7 @@ <template> <div class="app-container"> - <el-form :inline="true"> - <el-form-item label="菜单名称"> + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch"> + <el-form-item label="菜单名称" prop="menuName"> <el-input v-model="queryParams.menuName" placeholder="请输入菜单名称" @@ -10,10 +10,10 @@ @keyup.enter.native="handleQuery" /> </el-form-item> - <el-form-item label="状态"> - <el-select v-model="queryParams.visible" placeholder="菜单状态" clearable size="small"> + <el-form-item label="状态" prop="status"> + <el-select v-model="queryParams.status" placeholder="菜单状态" clearable size="small"> <el-option - v-for="dict in visibleOptions" + v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" @@ -22,9 +22,23 @@ </el-form-item> <el-form-item> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> - <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:menu:add']">新增</el-button> + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> </el-form-item> </el-form> + + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button + type="primary" + plain + icon="el-icon-plus" + size="mini" + @click="handleAdd" + v-hasPermi="['system:menu:add']" + >新增</el-button> + </el-col> + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> + </el-row> <el-table v-loading="loading" @@ -32,22 +46,22 @@ row-key="menuId" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" > - <el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="130px"></el-table-column> - <el-table-column prop="icon" label="图标" align="center" width="100px"> + <el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column> + <el-table-column prop="icon" label="图标" align="center" width="100"> <template slot-scope="scope"> <svg-icon :icon-class="scope.row.icon" /> </template> </el-table-column> - <el-table-column prop="orderNum" label="排序" width="60px"></el-table-column> - <el-table-column prop="perms" label="权限标识" width="130px" :show-overflow-tooltip="true"></el-table-column> - <el-table-column prop="component" label="组件路径" width="180px" :show-overflow-tooltip="true"></el-table-column> - <el-table-column prop="visible" label="可见" :formatter="visibleFormat" width="80px"></el-table-column> - <el-table-column label="创建时间" align="center" prop="createTime" width="180"> + <el-table-column prop="orderNum" label="排序" width="60"></el-table-column> + <el-table-column prop="perms" label="权限标识" :show-overflow-tooltip="true"></el-table-column> + <el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column> + <el-table-column prop="status" label="状态" :formatter="statusFormat" width="80"></el-table-column> + <el-table-column label="创建时间" align="center" prop="createTime"> <template slot-scope="scope"> <span>{{ parseTime(scope.row.createTime) }}</span> </template> </el-table-column> - <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width"> + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <template slot-scope="scope"> <el-button size="mini" type="text" @@ -74,7 +88,7 @@ </el-table> <!-- 添加或修改菜单对话框 --> - <el-dialog :title="title" :visible.sync="open" width="600px"> + <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> <el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-row> <el-col :span="24"> @@ -152,14 +166,33 @@ <el-input v-model="form.perms" placeholder="请权限标识" maxlength="50" /> </el-form-item> </el-col> - <el-col :span="24"> - <el-form-item v-if="form.menuType != 'F'" label="菜单状态"> + <el-col :span="12"> + <el-form-item v-if="form.menuType != 'F'" label="显示状态"> <el-radio-group v-model="form.visible"> <el-radio v-for="dict in visibleOptions" :key="dict.dictValue" :label="dict.dictValue" >{{dict.dictLabel}}</el-radio> + </el-radio-group> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item v-if="form.menuType != 'F'" label="菜单状态"> + <el-radio-group v-model="form.status"> + <el-radio + v-for="dict in statusOptions" + :key="dict.dictValue" + :label="dict.dictValue" + >{{dict.dictLabel}}</el-radio> + </el-radio-group> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item v-if="form.menuType == 'C'" label="是否缓存"> + <el-radio-group v-model="form.isCache"> + <el-radio label="0">缓存</el-radio> + <el-radio label="1">不缓存</el-radio> </el-radio-group> </el-form-item> </el-col> @@ -186,6 +219,8 @@ return { // 遮罩层 loading: true, + // 显示搜索条件 + showSearch: true, // 菜单表格树数据 menuList: [], // 菜单树选项 @@ -194,8 +229,10 @@ title: "", // 是否显示弹出层 open: false, - // 菜单状态数据字典 + // 显示状态数据字典 visibleOptions: [], + // 菜单状态数据字典 + statusOptions: [], // 查询参数 queryParams: { menuName: undefined, @@ -210,6 +247,9 @@ ], orderNum: [ { required: true, message: "菜单顺序不能为空", trigger: "blur" } + ], + path: [ + { required: true, message: "路由地址不能为空", trigger: "blur" } ] } }; @@ -218,6 +258,9 @@ this.getList(); this.getDicts("sys_show_hide").then(response => { this.visibleOptions = response.data; + }); + this.getDicts("sys_normal_disable").then(response => { + this.statusOptions = response.data; }); }, methods: { @@ -253,12 +296,19 @@ this.menuOptions.push(menu); }); }, - // 菜单显示状态字典翻译 + // 显示状态字典翻译 visibleFormat(row, column) { if (row.menuType == "F") { return ""; } return this.selectDictLabel(this.visibleOptions, row.visible); + }, + // 菜单状态字典翻译 + statusFormat(row, column) { + if (row.menuType == "F") { + return ""; + } + return this.selectDictLabel(this.statusOptions, row.status); }, // 取消按钮 cancel() { @@ -275,7 +325,9 @@ menuType: "M", orderNum: undefined, isFrame: "1", - visible: "0" + isCache: "0", + visible: "0", + status: "0" }; this.resetForm("form"); }, @@ -283,12 +335,19 @@ handleQuery() { this.getList(); }, + /** 重置按钮操作 */ + resetQuery() { + this.resetForm("queryForm"); + this.handleQuery(); + }, /** 新增按钮操作 */ handleAdd(row) { this.reset(); this.getTreeselect(); - if (row != null) { + if (row != null && row.menuId) { this.form.parentId = row.menuId; + } else { + this.form.parentId = 0; } this.open = true; this.title = "添加菜单"; @@ -309,23 +368,15 @@ if (valid) { if (this.form.menuId != undefined) { updateMenu(this.form).then(response => { - if (response.code === 200) { - this.msgSuccess("修改成功"); - this.open = false; - this.getList(); - } else { - this.msgError(response.msg); - } + this.msgSuccess("修改成功"); + this.open = false; + this.getList(); }); } else { addMenu(this.form).then(response => { - if (response.code === 200) { - this.msgSuccess("新增成功"); - this.open = false; - this.getList(); - } else { - this.msgError(response.msg); - } + this.msgSuccess("新增成功"); + this.open = false; + this.getList(); }); } } @@ -342,7 +393,7 @@ }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }).catch(function() {}); + }) } } }; -- Gitblit v1.9.2