动态路由修改

This commit is contained in:
aoli.qu 2021-09-02 11:04:14 +08:00
parent 903e75936f
commit 0554c79f65
13 changed files with 202 additions and 455 deletions

View File

@ -14,7 +14,7 @@ export function login (parameter) {
})
}
export function getLoginUser () {
export function getLoginUser (parameter) {
return request({
url: userApi.getLoginUser,
method: 'post',
@ -25,10 +25,7 @@ export function getLoginUser () {
export function logout () {
return request({
url: userApi.logout,
method: 'post',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
method: 'get'
})
}
export function getSmsCaptcha (parameter) {

BIN
src/assets/welcome.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,431 +1,28 @@
// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'
import { UserLayout, BasicLayout, RouteView } from '@/layouts'
import { bxAnaalyse } from '@/core/icons'
const RouteView = {
name: 'RouteView',
render: (h) => h('router-view')
}
export const asyncRouterMap = [
{
path: '/',
name: 'index',
name: 'MenuIndex.vue',
component: BasicLayout,
meta: { title: 'menu.home' },
meta: { title: '首页' },
redirect: '/dashboard/workplace',
children: [
// dashboard
{
path: '/dashboard',
path: 'dashboard',
name: 'dashboard',
redirect: '/dashboard/workplace',
component: RouteView,
meta: { title: 'menu.dashboard', keepAlive: true, icon: bxAnaalyse, permission: ['dashboard'] },
meta: { title: '仪表盘', keepAlive: true, icon: bxAnaalyse /* permission: [ 'dashboard' ] */ },
children: [
{
path: '/dashboard/workplace',
path: 'workplace',
name: 'Workplace',
component: () => import('@/views/dashboard/Workplace'),
meta: { title: 'menu.dashboard.workplace', keepAlive: true, permission: ['dashboard'] }
}
]
},
// 权限管理
{
path: '/security',
name: 'security',
redirect: '/security/user',
component: RouteView,
meta: { title: '系统设置', keepAlive: true, icon: bxAnaalyse, permission: ['security'] },
children: [
{
path: '/security/user',
name: 'SecurityUser',
component: () => import('@/views/security/user/UserList'),
meta: { title: '用户管理', keepAlive: true, permission: ['security'] }
},
{
path: '/security/role',
name: 'SecurityRole',
component: () => import('@/views/security/role/RoleList'),
meta: { title: '角色管理', keepAlive: true }
},
{
path: '/security/menu',
name: 'SecurityMenu',
component: () => import('@/views/security/menu/MenuList'),
meta: { title: '菜单管理', keepAlive: true }
},
{
path: '/sys/dictionary',
name: 'DictionaryList',
component: () => import('@/views/sys/dictionary/DictionaryList'),
meta: { title: '数据词典', keepAlive: true }
},
{
path: '/sys/oss',
name: 'OssList',
component: () => import('@/views/sys/oss/OssList'),
meta: { title: '文件中心', keepAlive: true }
}
]
},
// 项目管理
{
path: '/project',
redirect: '/project/list',
component: RouteView,
meta: { title: '项目管理', icon: bxAnaalyse, permission: ['from'] },
children: [
{
path: '/project/list',
name: 'projectList',
component: () => import('@/views/project/ProjectList'),
meta: { title: '自主项目', keepAlive: true, permission: ['form'] },
},
// {
// path: '/project/add',
// name: 'ProjectForm',
// component: () => import('@/views/project/ProjectForm'),
// meta: { title: '新增项目', keepAlive: true, permission: ['form'], show: false }
// },
{
path: '/project/projectStepForm',
name: 'projectStepForm',
component: () => import('@/views/project/form/ProjectStepForm'),
meta: { title: '新增项目-分布', keepAlive: true, permission: ['form'] }
},
// {
// path: '/project/unitSelect',
// name: 'unitSelect',
// component: () => import('@/views/project/ProjectUnitSelect'),
// meta: { title: '选择单位', keepAlive: true, permission: ['form'] }
// },
{
path: '/form/step-form',
name: 'StepForm',
component: () => import('@/views/form/stepForm/StepForm'),
meta: { title: '系统推荐', keepAlive: true, permission: ['form'] }
},
{
path: '/form/advanced-form',
name: 'AdvanceForm',
component: () => import('@/views/form/advancedForm/AdvancedForm'),
meta: { title: '终端培训', keepAlive: true, permission: ['form'] }
}
]
},
// 课程管理
{
path: '/courseManagement',
redirect: '/courseManagement/course/courseList',
component: RouteView,
meta: { title: '课程管理', icon: bxAnaalyse, permission: ['from'] },
children: [
{
path: '/courseManagement/course/courseList',
name: 'courseList',
component: () => import('@/views/course/CourseList'),
meta: { title: '系统课程', keepAlive: true, permission: ['form'] }
},
{
path: '/courseManagement/customCourseList',
name: 'customCourse',
component: () => import('@/views/course/customCourseList'),
meta: { title: '自制课程', keepAlive: true, permission: ['form'] }
},
{
path: '/form/advanced-form',
name: 'AdvanceForm',
component: () => import('@/views/form/advancedForm/AdvancedForm'),
meta: { title: '资源库', keepAlive: true, permission: ['form'] }
}
]
},
// 档案管理
{
path: "/archives",
redirect: "/archives/user",
component: RouteView,
meta: { title: '档案管理', icon: 'profile', permission: ['form'] },
children: [
{
path: "/archives/user",
name: "archivesUser",
component: () => import('@/views/archives/user/Index'),
meta: { title: '人员档案', keepAlive: true, permission: ['form'] }
}
]
},
// forms
{
path: '/form',
redirect: '/form/base-form',
component: RouteView,
meta: { title: '表单页', icon: 'form', permission: ['form'] },
children: [
{
path: '/form/base-form',
name: 'BaseForm',
component: () => import('@/views/form/basicForm/Index'),
meta: { title: '基础表单', keepAlive: true, permission: ['form'] }
},
{
path: '/form/step-form',
name: 'StepForm',
component: () => import('@/views/form/stepForm/StepForm'),
meta: { title: '分步表单', keepAlive: true, permission: ['form'] }
},
{
path: '/form/advanced-form',
name: 'AdvanceForm',
component: () => import('@/views/form/advancedForm/AdvancedForm'),
meta: { title: '高级表单', keepAlive: true, permission: ['form'] }
}
]
},
// list
{
path: '/list',
name: 'list',
component: RouteView,
redirect: '/list/table-list',
meta: { title: '列表页', icon: 'table', permission: ['table'] },
children: [
{
path: '/list/table-list/:pageNo([1-9]\\d*)?',
name: 'TableListWrapper',
hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
component: () => import('@/views/list/TableList'),
meta: { title: '查询表格', keepAlive: true, permission: ['table'] }
},
{
path: '/list/basic-list',
name: 'BasicList',
component: () => import('@/views/list/BasicList'),
meta: { title: '标准列表', keepAlive: true, permission: ['table'] }
},
{
path: '/list/card',
name: 'CardList',
component: () => import('@/views/list/CardList'),
meta: { title: '卡片列表', keepAlive: true, permission: ['table'] }
},
{
path: '/list/search',
name: 'SearchList',
component: () => import('@/views/list/search/SearchLayout'),
redirect: '/list/search/article',
meta: { title: '搜索列表', keepAlive: true, permission: ['table'] },
children: [
{
path: '/list/search/article',
name: 'SearchArticles',
component: () => import('../views/list/search/Article'),
meta: { title: '搜索列表(文章)', permission: ['table'] }
},
{
path: '/list/search/project',
name: 'SearchProjects',
component: () => import('../views/list/search/Projects'),
meta: { title: '搜索列表(项目)', permission: ['table'] }
},
{
path: '/list/search/application',
name: 'SearchApplications',
component: () => import('../views/list/search/Applications'),
meta: { title: '搜索列表(应用)', permission: ['table'] }
}
]
}
]
},
// profile
{
path: '/profile',
name: 'profile',
component: RouteView,
redirect: '/profile/basic',
meta: { title: '详情页', icon: 'profile', permission: ['profile'] },
children: [
{
path: '/profile/basic',
name: 'ProfileBasic',
component: () => import('@/views/profile/basic/Index'),
meta: { title: '基础详情页', permission: ['profile'] }
},
{
path: '/profile/advanced',
name: 'ProfileAdvanced',
component: () => import('@/views/profile/advanced/Advanced'),
meta: { title: '高级详情页', permission: ['profile'] }
}
]
},
// result
{
path: '/result',
name: 'result',
component: RouteView,
redirect: '/result/success',
meta: { title: '结果页', icon: 'check-circle-o', permission: ['result'] },
children: [
{
path: '/result/success',
name: 'ResultSuccess',
component: () => import(/* webpackChunkName: "result" */ '@/views/result/Success'),
meta: { title: '成功', keepAlive: false, hiddenHeaderContent: true, permission: ['result'] }
},
{
path: '/result/fail',
name: 'ResultFail',
component: () => import(/* webpackChunkName: "result" */ '@/views/result/Error'),
meta: { title: '失败', keepAlive: false, hiddenHeaderContent: true, permission: ['result'] }
}
]
},
// Exception
{
path: '/exception',
name: 'exception',
component: RouteView,
redirect: '/exception/403',
meta: { title: '异常页', icon: 'warning', permission: ['exception'] },
children: [
{
path: '/exception/403',
name: 'Exception403',
component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'),
meta: { title: '403', permission: ['exception'] }
},
{
path: '/exception/404',
name: 'Exception404',
component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'),
meta: { title: '404', permission: ['exception'] }
},
{
path: '/exception/500',
name: 'Exception500',
component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'),
meta: { title: '500', permission: ['exception'] }
}
]
},
// account
{
path: '/account',
component: RouteView,
redirect: '/account/center',
name: 'account',
meta: { title: '个人页', icon: 'user', keepAlive: true, permission: ['user'] },
children: [
{
path: '/account/center',
name: 'center',
component: () => import('@/views/account/center/Index'),
meta: { title: '个人中心', keepAlive: true, permission: ['user'] }
},
{
path: '/account/settings',
name: 'settings',
component: () => import('@/views/account/settings/Index'),
meta: { title: '个人设置', hideHeader: true, permission: ['user'] },
redirect: '/account/settings/base',
hideChildrenInMenu: true,
children: [
{
path: '/account/settings/base',
name: 'BaseSettings',
component: () => import('@/views/account/settings/BaseSetting'),
meta: { title: '基本设置', hidden: true, permission: ['user'] }
},
{
path: '/account/settings/security',
name: 'SecuritySettings',
component: () => import('@/views/account/settings/Security'),
meta: { title: '安全设置', hidden: true, keepAlive: true, permission: ['user'] }
},
{
path: '/account/settings/custom',
name: 'CustomSettings',
component: () => import('@/views/account/settings/Custom'),
meta: { title: '个性化设置', hidden: true, keepAlive: true, permission: ['user'] }
},
{
path: '/account/settings/binding',
name: 'BindingSettings',
component: () => import('@/views/account/settings/Binding'),
meta: { title: '账户绑定', hidden: true, keepAlive: true, permission: ['user'] }
},
{
path: '/account/settings/notification',
name: 'NotificationSettings',
component: () => import('@/views/account/settings/Notification'),
meta: { title: '新消息通知', hidden: true, keepAlive: true, permission: ['user'] }
}
]
}
]
},
{
path: '/other',
name: 'otherPage',
component: RouteView,
meta: { title: '其他组件', icon: 'slack', permission: ['dashboard'] },
redirect: '/other/icon-selector',
children: [
{
path: '/other/icon-selector',
name: 'TestIconSelect',
component: () => import('@/views/other/IconSelectorView'),
meta: { title: 'IconSelector', icon: 'tool', keepAlive: true, permission: ['dashboard'] }
},
{
path: '/other/list',
component: RouteView,
meta: { title: '业务布局', icon: 'layout', permission: ['support'] },
redirect: '/other/list/tree-list',
children: [
{
path: '/other/list/tree-list',
name: 'TreeList',
component: () => import('@/views/other/TreeList'),
meta: { title: '树目录表格', keepAlive: true }
},
{
path: '/other/list/edit-table',
name: 'EditList',
component: () => import('@/views/other/TableInnerEditList'),
meta: { title: '内联编辑表格', keepAlive: true }
},
{
path: '/other/list/user-list',
name: 'UserList',
component: () => import('@/views/other/UserList'),
meta: { title: '用户列表', keepAlive: true }
},
{
path: '/other/list/role-list',
name: 'RoleList',
component: () => import('@/views/other/RoleList'),
meta: { title: '角色列表', keepAlive: true }
},
{
path: '/other/list/system-role',
name: 'SystemRole',
component: () => import('@/views/role/RoleList'),
meta: { title: '角色列表2', keepAlive: true }
},
{
path: '/other/list/permission-list',
name: 'PermissionList',
component: () => import('@/views/other/PermissionList'),
meta: { title: '权限列表', keepAlive: true }
}
]
meta: { title: '工作台', keepAlive: false/*, permission: [ 'dashboard' ] */ }
}
]
}
@ -486,5 +83,5 @@ export const constantRouterMap = [
meta: { title: '词典项', keepAlive: true, permission: ['dictionaryItem'] }
}
]
},
}
]

View File

@ -13,13 +13,15 @@ import themePluginConfig from '../config/themePluginConfig'
import bootstrap from './core/bootstrap'
import './core/lazy_use'
// import './permission' // permission control
import './permission' // permission control
import './utils/filter' // global filter
import './global.less'
import moment from 'moment'
import { FormModel } from 'ant-design-vue'
// import './mock'
import { hasBtnPermission } from './utils/permissions'
Vue.use(FormModel)
Vue.prototype.hasPerm = hasBtnPermission
Vue.config.productionTip = false

View File

@ -15,21 +15,19 @@ const loginRoutePath = '/user/login'
const defaultRoutePath = '/dashboard/workplace'
router.beforeEach((to, from, next) => {
debugger
NProgress.start() // start progress bar
to.meta && (typeof to.meta.title !== 'undefined' && setDocumentTitle(`${i18nRender(to.meta.title)} - ${domTitle}`))
/* has token */
console.log(storage.get(ACCESS_TOKEN))
debugger
if (storage.get(ACCESS_TOKEN)) {
if (to.path === loginRoutePath) {
next({ path: defaultRoutePath })
NProgress.done()
} else {
if (store.getters.roles.length === 0) {
console.log('逻辑开始1 => src/permission.js')
store
.dispatch('GetInfo')
.then(res => {
console.log('流程3-获取个人信息返回 => src/permission.js ')
if (res.menus.length < 1) {
Modal.error({
title: '提示:',
@ -45,14 +43,19 @@ router.beforeEach((to, from, next) => {
}
const antDesignMenus = res.menus
// generate dynamic router
console.log('流程4-从后端获取权限开始')
store.dispatch('GenerateRoutes', { antDesignMenus }).then(() => {
// 根据菜单权限生成可访问的路由表
// 动态添加可访问路由表
router.addRoutes(store.getters.addRouters)
const routes = store.getters.addRouters
for(let i =0,length =routes.length;i<length;i+=1){
const element = routes[i];
router.addRoute(element);
}
// router.addRoutes(store.getters.addRouters) router.addRoutes方法被遗弃
// 请求带有 redirect 重定向时,登录自动重定向到该地址
const redirect = decodeURIComponent(from.query.redirect || to.path)
if (to.path === redirect) {
next({ path: redirect })
// set the replace: true so the navigation will not leave a history record
next({ ...to, replace: true })
} else {

View File

@ -15,6 +15,17 @@ const constantRouterComponents = {
// 你需要动态引入的页面组件
'Workplace': () => import('@/views/dashboard/Workplace'),
// account
'AccountCenter': () => import('@/views/account/center/Index'),
'AccountSettings': () => import('@/views/account/settings/Index'),
'BaseSettings': () => import('@/views/account/settings/BaseSetting'),
'SecuritySettings': () => import('@/views/account/settings/Security'),
'CustomSettings': () => import('@/views/account/settings/Custom'),
'BindingSettings': () => import('@/views/account/settings/Binding'),
'NotificationSettings': () => import('@/views/account/settings/Notification'),
// 默认首页
'Console': () => import('@/views/index/welcome')
}
// 前端未找到页面路由(固定不用改)
@ -22,11 +33,120 @@ const notFoundRouter = {
path: '*', redirect: '/404', hidden: true
}
// 个人中心页面
const userAccount = [
// account
{
'name': 'account',
'pid': 0,
'id': 10028,
'meta': {
'title': '个人页',
'icon': 'user',
'show': false
},
'redirect': '/account/center',
'component': 'RouteView'
},
{
'name': 'center',
'pid': 10028,
'id': 10029,
'meta': {
'title': '个人中心',
'show': false
},
'component': 'AccountCenter'
},
// 特殊三级菜单
{
'name': 'settings',
'pid': '10028',
'id': '10030',
'meta': {
'title': '个人设置',
'hideHeader': true,
'hideChildren': true,
'show': false
},
'redirect': '/account/settings/base',
'component': 'AccountSettings'
},
{
'name': 'BaseSettings',
'path': '/account/settings/base',
'pid': 10030,
'id': 10031,
'meta': {
'title': '基本设置',
'show': false
},
'component': 'BaseSettings'
},
{
'name': 'SecuritySettings',
'path': '/account/settings/security',
'pid': 10030,
'id': 10032,
'meta': {
'title': '安全设置',
'show': false
},
'component': 'SecuritySettings'
},
{
'name': 'CustomSettings',
'path': '/account/settings/custom',
'pid': 10030,
'id': 10033,
'meta': {
'title': '个性化设置',
'show': false
},
'component': 'CustomSettings'
},
{
'name': 'BindingSettings',
'path': '/account/settings/binding',
'pid': 10030,
'id': 10034,
'meta': {
'title': '账户绑定',
'show': false
},
'component': 'BindingSettings'
},
{
'name': 'NotificationSettings',
'path': '/account/settings/notification',
'pid': 10030,
'id': 10034,
'meta': {
'title': '新消息通知',
'show': false
},
'component': 'NotificationSettings'
},
{
'name': 'Console',
'path': '/welcome',
'pid': 0,
'id': 183183,
'meta': {
'title': '首页',
'show': false
},
'component': 'Console'
}
]
// 根级菜单
const rootRouter = {
path: '/',
name: 'index',
component: 'BasicLayout',
redirect: '/welcome',
meta: { title: '首页' },
children: []
}
@ -38,17 +158,14 @@ const rootRouter = {
*/
export const generatorDynamicRouter = (data) => {
return new Promise((resolve, reject) => {
console.log('流程5-后端返回的权限菜单generatorDynamicRouter')
console.log(data)
const resNav = data.antDesignMenus
const menuNav = []
const childrenNav = []
// 后端数据, 根级树数组, 根级 PID
// 后端数据, 根级树数组, 根级 PID
listToTree(resNav, childrenNav, 0)
// 增加静态网页
listToTree(userAccount, childrenNav, 0)
rootRouter.children = childrenNav
if (childrenNav.length > 0) {
rootRouter.redirect = childrenNav[0].path
}
menuNav.push(rootRouter)
const routers = generator(menuNav)
routers.push(notFoundRouter)
@ -85,7 +202,7 @@ export const generator = (routerMap, parent) => {
icon: icon || undefined,
hiddenHeaderContent: hiddenHeaderContent,
target: target,
permission: item.name
// permission: item.name
}
}
// 是否设置了隐藏菜单
@ -120,7 +237,7 @@ export const generator = (routerMap, parent) => {
const listToTree = (list, tree, parentId) => {
list.forEach(item => {
// 判断是否为父级菜单
if (item.parentId === parentId) {
if (item.pid === parentId) {
const child = {
...item,
key: item.key || item.name,

View File

@ -8,6 +8,7 @@ const getters = {
nickname: state => state.user.name,
welcome: state => state.user.welcome,
roles: state => state.user.roles,
buttons: state => state.user.buttons,
userInfo: state => state.user.info,
addRouters: state => state.permission.addRouters,
multiTab: state => state.app.multiTab

View File

@ -18,7 +18,6 @@ const permission = {
actions: {
GenerateRoutes ({ commit }, data) {
return new Promise(resolve => {
console.log('动态生成路由:GenerateRoutes async-router 111')
generatorDynamicRouter(data).then(routers => {
commit('SET_ROUTERS', routers)
resolve()

View File

@ -56,8 +56,6 @@ const user = {
getLoginUser().then(response => {
if (response.code === 200) {
const data = response.data
console.log('流程2-获取到个人信息 => user.js')
console.log(data)
commit('SET_ROLES', 1)
commit('SET_BUTTONS', data.permissions)
commit('SET_INFO', data)
@ -79,7 +77,7 @@ const user = {
// 登出
Logout ({ commit, state }) {
return new Promise((resolve) => {
logout(state.token).then(() => {
logout().then(() => {
resolve()
}).catch(() => {
resolve()
@ -87,6 +85,7 @@ const user = {
commit('SET_TOKEN', '')
commit('SET_ROLES', [])
commit('SET_BUTTONS', [])
storage.remove(ACCESS_TOKEN)
})
})
}

View File

@ -1,3 +1,5 @@
import store from '@/store'
export function actionToObject (json) {
try {
return JSON.parse(json)
@ -6,3 +8,15 @@ export function actionToObject (json) {
}
return []
}
/**
* 控制按钮是否显示
*/
export function hasBtnPermission (permission) {
const myBtns = store.getters.buttons
const nickname = store.getters.nickname
if (nickname == '超级管理员') {
return true
}
return myBtns.indexOf(permission) > -1
}

View File

@ -4,9 +4,10 @@ import storage from 'store'
import notification from 'ant-design-vue/es/notification'
import { VueAxios } from './axios'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import router from '../router'
const SUCCESS_CODE = 200
const INVALID_TOKEN_CODE = '0000'
const INVALID_TOKEN_CODE = 401
const toast = (msg, description) => {
notification.error({
@ -29,7 +30,7 @@ const errorHandler = (error) => {
// 从 localstorage 获取 token
const token = storage.get(ACCESS_TOKEN)
if (error.response.status === 403) {
toast('Forbidden:', data.message)
toast('Forbidden:', data.msg)
}
if (error.response.status === 401 && !(data.result && data.result.isLogin)) {
toast('Unauthorized:', 'Authorization verification failed')
@ -47,9 +48,9 @@ const errorHandler = (error) => {
// request interceptor
request.interceptors.request.use(config => {
// const token = storage.get(ACCESS_TOKEN)
const token = storage.get(ACCESS_TOKEN)
// 由于登录接口待联调token使用默认值
const token = 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjBkYjU0YzQ0LWQ5MDktNDQ0ZC05YTYwLTE4ZGU1YjgyMzg5YyJ9.l37UO6WC9tPTuoJnbWKpTusHdtmon95Islq-jRNo9zmCKJ4GWwnY9_szBpgOii2Y7OVvc4sWibmFBdTwmAg8sg'
// const token = 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjY0MjM0YmY0LTkxOWEtNDFkMS05MzZlLTMwZDU3NDhkYmVjZCJ9.J15_FhVqcm_GsNIS2BCEYf26sWQQ4pMSTedV5eKauZT8-f6480Mx1s5ZdqWdEOlORnkKSc5pUioCngbCopr9cQ'
// 如果 token 存在,让每个请求携带自定义 token 请根据实际情况自行修改
if (token) {
config.headers[ACCESS_TOKEN] = token
@ -69,7 +70,7 @@ request.interceptors.response.use((response) => {
} else if (response.data && response.data.code === INVALID_TOKEN_CODE) {
toast(response.data.msg)
store.dispatch('Logout').then(() => {
this.$router.push({ name: 'login' })
router.push({ name: 'login' })
})
return Promise.reject(response)
} else {

View File

@ -0,0 +1,15 @@
<template>
<a-card :bordered="false" style="display: flex;justify-content:center;height: 100%" >
<div style="margin:100px auto;">
<img src="~@/assets/welcome.png" class="logo" alt="logo">
</div>
</a-card>
</template>
<script>
</script>
<style lang="less" scoped>
</style>

View File

@ -28,8 +28,8 @@
</div>
<div class="table-operator">
<a-button type="primary" icon="plus" @click="$refs.userForm.add()">新增用户</a-button>
<a-button type="danger" :disabled="selectedRowKeys.length < 1" @click="batchDelete">
<a-button type="primary" icon="plus" v-if="hasPerm('sys:user:add')" @click="$refs.userForm.add()">新增用户</a-button>
<a-button type="danger" :disabled="selectedRowKeys.length < 1" v-if="hasPerm('sys:user:delete')" @click="batchDelete">
<a-icon type="delete"/>批量删除
</a-button>
</div>
@ -46,22 +46,22 @@
{{ record.sex | sexFilter }}
</span>
<span slot="action" slot-scope="text, record">
<a @click="$refs.userForm.edit(record)">编辑</a>
<a-divider type="vertical" />
<a-dropdown >
<a v-if="hasPerm('sys:user:edit')" @click="$refs.userForm.edit(record)">编辑</a>
<a-divider type="vertical" v-if="hasPerm('sysUser:edit')" />
<a-dropdown v-if="hasPerm('sys:user:resetPwd') || hasPerm('sys:user:grantRole') || hasPerm('sys:user:delete')">
<a class="ant-dropdown-link">
更多 <a-icon type="down" />
</a>
<a-menu slot="overlay">
<a-menu-item>
<a-menu-item v-if="hasPerm('sys:user:resetPwd')">
<a-popconfirm placement="topRight" title="确认重置密码?" @confirm="() => resetPwd(record)">
<a>重置密码</a>
</a-popconfirm>
</a-menu-item>
<a-menu-item>
<a-menu-item v-if="hasPerm('sys:user:grantRole')">
<a @click="$refs.userRoleForm.userRole(record)">授权角色</a>
</a-menu-item>
<a-menu-item>
<a-menu-item v-if="hasPerm('sys:user:delete')">
<a-popconfirm placement="topRight" title="确认删除?" @confirm="() => singleDelete(record)">
<a>删除</a>
</a-popconfirm>
@ -112,12 +112,6 @@ export default {
}, {
title: '手机',
dataIndex: 'phoneNumber'
},
{
title: '操作',
width: '150px',
dataIndex: 'action',
scopedSlots: { customRender: 'action' }
}
],
// Promise
@ -144,6 +138,14 @@ export default {
},
created () {
//
if (this.hasPerm('sys:user:edit') || this.hasPerm('sys:user:resetPwd') || this.hasPerm('sys:user:grantRole') || this.hasPerm('sys:user:delete')) {
this.columns.push({
title: '操作',
width: '150px',
dataIndex: 'action',
scopedSlots: { customRender: 'action' }
})
}
},
methods: {
//