chao vor 3 Jahren
Ursprung
Commit
6730b80111

+ 18 - 11
src/router/modules/sys.js

@@ -25,11 +25,18 @@ const sysRouter = {
           meta: { title: '菜单列表' }
           meta: { title: '菜单列表' }
         },
         },
         {
         {
-          path: 'form',
+          path: 'edit',
           hidden: true,
           hidden: true,
           component: () => import('@/views/sys/menus/form.vue'),
           component: () => import('@/views/sys/menus/form.vue'),
           name: 'SysMenuEdit',
           name: 'SysMenuEdit',
-          meta: { title: '菜单编辑' }
+          meta: { title: '编辑菜单' }
+        },
+        {
+          path: 'add',
+          hidden: true,
+          component: () => import('@/views/sys/menus/form.vue'),
+          name: 'SysMenuEdit',
+          meta: { title: '添加菜单' }
         }
         }
       ]
       ]
     },
     },
@@ -44,22 +51,22 @@ const sysRouter = {
           path: 'list',
           path: 'list',
           hidden: true,
           hidden: true,
           component: () => import('@/views/sys/roles/list.vue'),
           component: () => import('@/views/sys/roles/list.vue'),
-          name: 'SysRoles',
+          name: 'SysRoleList',
           meta: { title: '角色列表' }
           meta: { title: '角色列表' }
         },
         },
         {
         {
-          path: 'add',
+          path: 'edit',
           hidden: true,
           hidden: true,
-          component: () => import('@/views/sys/roles/add.vue'),
-          name: 'SysAddRoles',
-          meta: { title: '添加角色' }
+          component: () => import('@/views/sys/roles/update.vue'),
+          name: 'SysRoleEdit',
+          meta: { title: '编辑角色' }
         },
         },
         {
         {
-          path: 'update',
+          path: 'add',
           hidden: true,
           hidden: true,
-          component: () => import('@/views/sys/roles/update.vue'),
-          name: 'SysUpdateRoles',
-          meta: { title: '编辑角色' }
+          component: () => import('@/views/sys/roles/add.vue'),
+          name: 'SysRoleEdit',
+          meta: { title: '添加角色' }
         }
         }
       ]
       ]
     },
     },

+ 5 - 2
src/store/modules/permission.js

@@ -28,9 +28,12 @@ export function filterAsyncRoutes(routes, menus) {
     const tmp = { ...route }
     const tmp = { ...route }
     const meun = filterMeun(menus, tmp.name)
     const meun = filterMeun(menus, tmp.name)
     if (meun != null && meun.title) {
     if (meun != null && meun.title) {
-      tmp.meta.title = meun.title
-      tmp.sort = meun.sort
       tmp.hidden = meun.hidden !== 0
       tmp.hidden = meun.hidden !== 0
+      // 显示的菜单替换后台设置的标题
+      if (!tmp.hidden) {
+        tmp.meta.title = meun.title
+        tmp.sort = meun.sort
+      }
       if (meun.icon) {
       if (meun.icon) {
         tmp.meta.icon = meun.icon
         tmp.meta.icon = meun.icon
       }
       }

+ 7 - 7
src/views/sys/menus/form.vue

@@ -84,13 +84,6 @@ export default {
       return value && value.substr(0, 7) === 'el-icon'
       return value && value.substr(0, 7) === 'el-icon'
     },
     },
     getFormData() {
     getFormData() {
-      if (this.$route.query.parentId) {
-        this.menu.parentId = this.$route.query.parentId
-        this.parentTitle = this.$route.query.title
-      } else {
-        this.menu.parentId = 0
-        this.parentTitle = '无'
-      }
       if (this.$route.query.id) {
       if (this.$route.query.id) {
         this.menu.id = this.$route.query.id
         this.menu.id = this.$route.query.id
         this.isEdit = true
         this.isEdit = true
@@ -108,6 +101,13 @@ export default {
         this.isEdit = false
         this.isEdit = false
         this.menu = Object.assign({}, defaultMenu)
         this.menu = Object.assign({}, defaultMenu)
       }
       }
+      if (this.$route.query.parentId) {
+        this.menu.parentId = this.$route.query.parentId
+        this.parentTitle = this.$route.query.title
+      } else {
+        this.menu.parentId = 0
+        this.parentTitle = '无'
+      }
     },
     },
     resetForm(formName) {
     resetForm(formName) {
       this.$refs[formName].resetFields()
       this.$refs[formName].resetFields()

+ 3 - 3
src/views/sys/menus/list.vue

@@ -151,16 +151,16 @@ export default {
       this.$router.push({ path: '/sys/menus/list' })
       this.$router.push({ path: '/sys/menus/list' })
     },
     },
     handleCreate() {
     handleCreate() {
-      this.$router.push({ path: '/sys/menus/form', query: { parentId: this.listQuery.parentId, title: this.parentTitle } })
+      this.$router.push({ path: '/sys/menus/add', query: { parentId: this.listQuery.parentId, title: this.parentTitle } })
     },
     },
     handleUpdate(row) {
     handleUpdate(row) {
-      this.$router.push({ path: '/sys/menus/form', query: { id: row.id, parentId: this.listQuery.parentId, title: this.parentTitle } })
+      this.$router.push({ path: '/sys/menus/edit', query: { id: row.id, parentId: this.listQuery.parentId, title: this.parentTitle } })
     },
     },
     handleShowNextLevel(row) {
     handleShowNextLevel(row) {
       this.$router.push({ path: '/sys/menus/list', query: { parentId: row.id, title: row.title } })
       this.$router.push({ path: '/sys/menus/list', query: { parentId: row.id, title: row.title } })
     },
     },
     handleCreateNextLevel(row) {
     handleCreateNextLevel(row) {
-      this.$router.push({ path: '/sys/menus/form', query: { parentId: row.id, title: row.title } })
+      this.$router.push({ path: '/sys/menus/add', query: { parentId: row.id, title: row.title } })
     },
     },
     handleDelete(row) {
     handleDelete(row) {
       this.$confirm('是否要删除该菜单', '提示', {
       this.$confirm('是否要删除该菜单', '提示', {

+ 9 - 54
src/views/sys/roles/list.vue

@@ -23,11 +23,9 @@
       </el-table-column>
       </el-table-column>
       <el-table-column label="操作" width="250" align="center">
       <el-table-column label="操作" width="250" align="center">
         <template slot-scope="scope">
         <template slot-scope="scope">
-          <el-button size="mini" type="primary" @click="handleShowNextLevel(scope.$index, scope.row)">分配
+          <el-button size="mini" type="primary" @click="handleUpdate(scope.row)">修改
           </el-button>
           </el-button>
-          <el-button size="mini" type="primary" @click="handleUpdate(scope.$index, scope.row)">修改
-          </el-button>
-          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除
+          <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除
           </el-button>
           </el-button>
         </template>
         </template>
       </el-table-column>
       </el-table-column>
@@ -45,67 +43,27 @@ import Pagination from '@/components/Pagination'
 export default {
 export default {
   name: 'RoleList',
   name: 'RoleList',
   components: { Pagination },
   components: { Pagination },
-  filters: {
-    levelFilter(value) {
-      if (value === 0) {
-        return '一级'
-      } else if (value === 1) {
-        return '二级'
-      }
-    },
-    iconFilter(value) {
-      if (!value) {
-        return ''
-      }
-      if (value.substr(0, 7) === 'el-icon') {
-        return '<i class="' + value + '" />'
-      } else {
-        return '<svg-icon :icon-class="' + value + '" />'
-      }
-    },
-    disableNextLevel(value) {
-      if (value === 0) {
-        return false
-      } else {
-        return true
-      }
-    }
-  },
   data() {
   data() {
     return {
     return {
       tableKey: 0,
       tableKey: 0,
       list: [],
       list: [],
-      total: 5,
+      total: 0,
       listLoading: true,
       listLoading: true,
       listQuery: {
       listQuery: {
         pageNum: 1,
         pageNum: 1,
-        pageSize: 10,
-        parentId: 0
+        pageSize: 10
       }
       }
     }
     }
   },
   },
   watch: {
   watch: {
     $route(route) {
     $route(route) {
-      this.resetParentId()
       this.getList()
       this.getList()
     }
     }
   },
   },
   created() {
   created() {
-    this.resetParentId()
     this.getList()
     this.getList()
   },
   },
   methods: {
   methods: {
-    isElementIcon(value) {
-      return value.substr(0, 7) === 'el-icon'
-    },
-    resetParentId() {
-      this.listQuery.pageNum = 1
-      if (this.$route.query.parentId != null) {
-        this.parentId = this.$route.query.parentId
-      } else {
-        this.parentId = 0
-      }
-    },
     getList() {
     getList() {
       this.listLoading = true
       this.listLoading = true
       fetchList(this.listQuery).then(response => {
       fetchList(this.listQuery).then(response => {
@@ -119,22 +77,19 @@ export default {
         }, 1.5 * 1000)
         }, 1.5 * 1000)
       })
       })
     },
     },
-    handleShowNextLevel(index, row) {
-      this.$router.push({ path: '/sys/roles', query: { parentId: row.id } })
-    },
-    handleUpdate(index, row) {
-      this.$router.push({ path: '/sys/roles/update', query: { id: row.id } })
-    },
     handleCreate() {
     handleCreate() {
       this.$router.push({ path: '/sys/roles/add' })
       this.$router.push({ path: '/sys/roles/add' })
     },
     },
-    handleDelete(index, row) {
+    handleUpdate(row) {
+      this.$router.push({ path: '/sys/roles/update', query: { id: row.id } })
+    },
+    handleDelete(row) {
       this.$confirm('是否要删除该菜单', '提示', {
       this.$confirm('是否要删除该菜单', '提示', {
         confirmButtonText: '确定',
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         cancelButtonText: '取消',
         type: 'warning'
         type: 'warning'
       }).then(() => {
       }).then(() => {
-        deleteRole(row.id).then(response => {
+        deleteRole(row.id).then(() => {
           this.$message({
           this.$message({
             message: '删除成功',
             message: '删除成功',
             type: 'success',
             type: 'success',