diff --git a/README-zh.md b/README-zh.md index 5b6f7bd..1beec9b 100644 --- a/README-zh.md +++ b/README-zh.md @@ -8,6 +8,15 @@ 目前版本为 `v4.0+` 基于 `vue-cli` 进行构建,若你想使用旧版本,可以切换分支到[tag/3.11.0](https://github.com/PanJiaChen/vue-admin-template/tree/tag/3.11.0),它不依赖 `vue-cli`。 +
+ SPONSORED BY +
++ + + +
+ ## Extra 如果你想要根据用户角色来动态生成侧边栏和 router,你可以使用该分支[permission-control](https://github.com/PanJiaChen/vue-admin-template/tree/permission-control) diff --git a/README.md b/README.md index a2f3c71..fa54b78 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,15 @@ English | [简体中文](./README-zh.md) **The current version is `v4.0+` build on `vue-cli`. If you want to use the old version , you can switch branch to [tag/3.11.0](https://github.com/PanJiaChen/vue-admin-template/tree/tag/3.11.0), it does not rely on `vue-cli`** ++ SPONSORED BY +
++ + + +
+ ## Build Setup ```bash diff --git a/src/api/system/sysRole.js b/src/api/system/sysRole.js new file mode 100644 index 0000000..194068c --- /dev/null +++ b/src/api/system/sysRole.js @@ -0,0 +1,116 @@ +/* +角色管理相关的API请求函数 +*/ +import request from '@/utils/request' + +const api_name = '/admin/system/sysRole' + +export default { + + /** + * 获取角色分页列表(带搜索) + * @param {*} page + * @param {*} limit + * @param {*} searchObj + * @returns + */ + getPageList(page, limit, searchObj) { + return request({ + url: `${api_name}/${page}/${limit}`, + method: 'get', + // 如果是普通对象参数写法,params:对象参数名 + // 如果是使用json格式传递,data:对象参数名 + params: searchObj + }) + }, + + /** + * 角色删除 + * @param {*} id + * @returns + */ + removeById(id) { + return request({ + url: `${api_name}/remove/${id}`, + method: 'delete' + }) + }, + + /** + * 角色添加 + * @param {*} role + * @returns + */ + save(role) { + return request({ + url: `${api_name}/save`, + method: 'post', + data: role + }) + }, + + /** + * 回显要修改的id信息 + * + * @param id + * @returns {*} + */ + getById(id) { + return request({ + url: `${api_name}/get/${id}`, + method: 'get' + }) + }, + + /** 修改 + * + * @param role + * @returns {*} + */ + updateById(role) { + return request({ + url: `${api_name}/update`, + method: 'put', + data: role + }) + }, + + /** + * 批量删除 + * + * @param idList + * @returns {*} + */ + batchRemove(idList) { + return request({ + url: `${api_name}/batchRemove`, + method: `delete`, + data: idList + }) + }, + /** + * 根据用户获取角色数据 + * + * @param adminId + * @returns {*} + */ + getRoles(adminId) { + return request({ + url: `${api_name}/toAssign/${adminId}`, + method: 'get' + }) + }, + /** + * 为用户分配角色 + * + * @param assginRoleVo + * @returns {*} + */ + assignRoles(assginRoleVo) { + return request({ + url: `${api_name}/doAssign`, + method: 'post', + data: assginRoleVo + }) + } +} diff --git a/src/api/system/sysUser.js b/src/api/system/sysUser.js new file mode 100644 index 0000000..6f8e9cf --- /dev/null +++ b/src/api/system/sysUser.js @@ -0,0 +1,49 @@ +import request from '@/utils/request' + +const api_name = '/admin/system/sysUser' + +export default { + + getPageList(page, limit, searchObj) { + return request({ + url: `${api_name}/${page}/${limit}`, + method: 'get', + params: searchObj // url查询字符串或表单键值对 + }) + }, + getById(id) { + return request({ + url: `${api_name}/get/${id}`, + method: 'get' + }) + }, + + save(role) { + return request({ + url: `${api_name}/save`, + method: 'post', + data: role + }) + }, + + updateById(role) { + return request({ + url: `${api_name}/update`, + method: 'put', + data: role + }) + }, + removeById(id) { + return request({ + url: `${api_name}/remove/${id}`, + method: 'delete' + }) + }, + + updateStatus(id, status) { + return request({ + url: `${api_name}/updateStatus/${id}/${status}`, + method: 'get' + }) + } +} diff --git a/src/api/user.js b/src/api/user.js index 8ff4389..cc79a94 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -2,7 +2,7 @@ import request from '@/utils/request' export function login(data) { return request({ - url: '/vue-admin-template/user/login', + url: '/admin/system/index/login', method: 'post', data }) @@ -10,15 +10,15 @@ export function login(data) { export function getInfo(token) { return request({ - url: '/vue-admin-template/user/info', + url: '/admin/system/index/info', method: 'get', - params: { token } + params: {token} }) } export function logout() { return request({ - url: '/vue-admin-template/user/logout', + url: '/admin/system/index/logout', method: 'post' }) } diff --git a/src/router/index.js b/src/router/index.js index 13459e9..773df0f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,11 +1,10 @@ import Vue from 'vue' import Router from 'vue-router' - -Vue.use(Router) - /* Layout */ import Layout from '@/layout' +Vue.use(Router) + /** * Note: sub-menu only appear when route children.length >= 1 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html @@ -54,6 +53,34 @@ export const constantRoutes = [ meta: { title: 'Dashboard', icon: 'dashboard' } }] }, + { + path: '/system', + component: Layout, + meta: { + title: '系统管理', + icon: 'el-icon-s-tools' + }, + alwaysShow: true, + children: [ + { + name: 'sysUser', + path: 'sysUser', + component: () => import('@/views/system/sysUser/list'), + meta: { + title: '用户管理', + icon: 'el-icon-s-custom' + } + }, + { + path: 'sysRole', + component: () => import('@/views/system/sysRole/list'), + meta: { + title: '角色管理', + icon: 'el-icon-s-help' + } + } + ] + }, { path: '/example', diff --git a/src/utils/request.js b/src/utils/request.js index 2fb95ac..0976d23 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -46,7 +46,7 @@ service.interceptors.response.use( const res = response.data // if the custom code is not 20000, it is judged as an error. - if (res.code !== 20000) { + if (res.code !== 200) { Message({ message: res.message || 'Error', type: 'error', diff --git a/src/views/system/sysRole/list.vue b/src/views/system/sysRole/list.vue new file mode 100644 index 0000000..fb841de --- /dev/null +++ b/src/views/system/sysRole/list.vue @@ -0,0 +1,230 @@ + +