浏览代码

修改添加菜单权限弹框问题

ljh 2 年之前
父节点
当前提交
339620bc94
共有 3 个文件被更改,包括 17 次插入9 次删除
  1. 1 0
      chuanyi-admin/package.json
  2. 2 0
      chuanyi-admin/src/main.js
  3. 14 9
      chuanyi-admin/src/views/system/menu/menu-auth.vue

+ 1 - 0
chuanyi-admin/package.json

@@ -33,6 +33,7 @@
     "jsencrypt": "^3.3.0",
     "jsonlint": "1.6.3",
     "jszip": "3.2.1",
+    "lodash": "^4.17.21",
     "normalize.css": "7.0.0",
     "nprogress": "0.2.0",
     "path-to-regexp": "2.4.0",

+ 2 - 0
chuanyi-admin/src/main.js

@@ -16,7 +16,9 @@ import Pagination from '@/components/Pagination'
 
 import XEUtils from 'xe-utils'
 import VXEUtils from 'vxe-utils'
+import _ from 'lodash'
 
+Vue.prototype._ = _
 Vue.use(VXEUtils, XEUtils, { mounts: ['cookie'] })
 /**
  * If you don't want to use mock-server

+ 14 - 9
chuanyi-admin/src/views/system/menu/menu-auth.vue

@@ -23,6 +23,7 @@
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="接口名称" prop="permissionUrl" :show-overflow-tooltip="true" align="center" />
       <el-table-column label="备注" prop="permissionName" :show-overflow-tooltip="true" align="center" />
+      <el-table-column label="来源" prop="menuName" :show-overflow-tooltip="true" align="center" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -47,7 +48,7 @@
       @pagination="getTreeMenuList"
     />
 
-    <el-dialog title="分配菜单" :visible.sync="dialogVisible" width="35%">
+    <el-dialog title="分配菜单" :visible.sync="dialogVisible" width="40%">
       <el-row>
         <el-col>
           <el-button
@@ -61,8 +62,8 @@
             批量分配</el-button>
         </el-col>
       </el-row>
-      <el-table :data="addMenuAuthList" row-key="id" @selection-change="handelAddMenuAuth">
-        <el-table-column type="selection" width="55" align="center" />
+      <el-table ref="multipleTable" :data="addMenuAuthList" row-key="id" @selection-change="handelAddMenuAuth">
+        <el-table-column type="selection" width="55" align="center" :reserve-selection="true" />
         <el-table-column label="接口名称" prop="permissionUrl" :show-overflow-tooltip="true" align="center" />
         <el-table-column label="备注" prop="permissionName" :show-overflow-tooltip="true" align="center" />
         <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -152,7 +153,6 @@ export default {
         this.authList = data.permissionList
         this.total = data.count
         this.loading = false
-        this.getAllAuthApi()
       })
     },
     /** 查看所有权限接口 */
@@ -178,20 +178,24 @@ export default {
     },
     /** 添加菜单权限多选框选中数据 */
     handelAddMenuAuth(selection) {
-      this.menuAuthObj.permissionList = selection.map(item => {
-        return {
-          id: item.id
-        }
+      selection.forEach(item => {
+        this.menuAuthObj.permissionList.push({ id: item.id })
       })
+      this.menuAuthObj.permissionList = this._.uniqBy(this.menuAuthObj.permissionList, 'id')
       this.distribution = !selection.length
     },
     /** 添加菜单权限按钮 */
     handelAdd() {
+      this.getAllAuthApi()
+      this.allAuthQuery.page = 1
+      this.menuAuthObj.permissionList = []
       this.dialogVisible = true
+      this.$nextTick(() => {
+        this.$refs.multipleTable.clearSelection()
+      })
     },
     /** 分配按钮操作 */
     distMenuAuthBtn(row) {
-      this.menuAuthObj.permissionList = []
       this.$confirm('是否分配接口权限?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
@@ -267,6 +271,7 @@ export default {
     },
     /** 取消分配菜单权限接口 */
     delMenuAuth() {
+      this.queryParams.page = 1
       this.delMenuAuthObj.id = this.queryParams.id
       delMenuAuth(this.delMenuAuthObj).then(res => {
         if (res.code === 200) {