From c472986f0b134e3450a75a90a961836906fe6fe3 Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Wed, 15 Apr 2020 16:37:53 +0800 Subject: [PATCH] =?UTF-8?q?menu=E5=92=8Cauthority=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=88=B6=E7=BA=A7=E5=8F=98=E4=B8=BA=E9=80=89=E6=8B=A9=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/db/qmplus.sql | 18 +-- web/src/api/authority.js | 15 +++ web/src/components/mixins/infoList.js | 4 - web/src/view/example/customer/customer.vue | 3 + web/src/view/example/upload/upload.vue | 3 + .../view/superAdmin/authority/authority.vue | 122 ++++++++++++++++-- web/src/view/superAdmin/menu/menu.vue | 61 ++++++++- web/src/view/superAdmin/user/user.vue | 13 ++ 8 files changed, 206 insertions(+), 33 deletions(-) diff --git a/server/db/qmplus.sql b/server/db/qmplus.sql index 2d1a94b9..9927cba8 100644 --- a/server/db/qmplus.sql +++ b/server/db/qmplus.sql @@ -11,7 +11,7 @@ Target Server Version : 50644 File Encoding : 65001 - Date: 15/04/2020 13:12:44 + Date: 15/04/2020 16:37:36 */ SET NAMES utf8mb4; @@ -3852,13 +3852,6 @@ CREATE TABLE `exa_files` ( INDEX `idx_exa_files_deleted_at`(`deleted_at`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; --- ---------------------------- --- Records of exa_files --- ---------------------------- -INSERT INTO `exa_files` VALUES (1, '2020-04-14 15:52:18', '2020-04-14 15:52:18', NULL, 'logo.png', '7022fdcb1562ff79cc36ce0644b86b8a', '', 1, 0); -INSERT INTO `exa_files` VALUES (2, '2020-04-14 15:53:00', '2020-04-14 15:53:00', NULL, 'index.html', '139ac05423499b520cbf402ceb663b6f', '', 1, 0); -INSERT INTO `exa_files` VALUES (3, '2020-04-14 16:07:43', '2020-04-14 16:07:43', NULL, 'favicon.ico', '7d34c388d92837200de70d3a90b49d3b', '', 1, 0); - -- ---------------------------- -- Table structure for jwt_blacklists -- ---------------------------- @@ -3871,7 +3864,7 @@ CREATE TABLE `jwt_blacklists` ( `jwt` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL, PRIMARY KEY (`id`) USING BTREE, INDEX `idx_jwt_blacklists_deleted_at`(`deleted_at`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 39 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 40 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of jwt_blacklists @@ -3912,6 +3905,7 @@ INSERT INTO `jwt_blacklists` VALUES (35, '2020-01-06 16:59:26', '2020-01-06 16:5 INSERT INTO `jwt_blacklists` VALUES (36, '2020-03-21 14:46:14', '2020-03-21 14:46:14', NULL, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVVUlEIjoiY2UwZDY2ODUtYzE1Zi00MTI2LWE1YjQtODkwYmM5ZDIzNTZkIiwiSUQiOjEwLCJOaWNrTmFtZSI6Iui2hee6p-euoeeQhuWRmCIsIkF1dGhvcml0eUlkIjoiODg4IiwiZXhwIjoxNTg1Mzc3ODY3LCJpc3MiOiJxbVBsdXMiLCJuYmYiOjE1ODQ3NzIwNjd9.DLhWhD1FdcWLyFLcXQynKJnenbVHrSiKhlDGFRzgo5k'); INSERT INTO `jwt_blacklists` VALUES (37, '2020-03-31 14:24:35', '2020-03-31 14:24:35', NULL, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVVUlEIjoiY2UwZDY2ODUtYzE1Zi00MTI2LWE1YjQtODkwYmM5ZDIzNTZkIiwiSUQiOjEwLCJOaWNrTmFtZSI6Iui2hee6p-euoeeQhuWRmCIsIkF1dGhvcml0eUlkIjoiODg4IiwiZXhwIjoxNTg2MTM4MTA4LCJpc3MiOiJxbVBsdXMiLCJuYmYiOjE1ODU1MzIzMDh9.Ro2F2dZLfOk2Z_OPRbweOuCpchr6HlHfQIF5qjfc8y4'); INSERT INTO `jwt_blacklists` VALUES (38, '2020-04-01 16:07:57', '2020-04-01 16:07:57', NULL, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVVUlEIjoiY2UwZDY2ODUtYzE1Zi00MTI2LWE1YjQtODkwYmM5ZDIzNTZkIiwiSUQiOjEwLCJOaWNrTmFtZSI6Iui2hee6p-euoeeQhuWRmCIsIkF1dGhvcml0eUlkIjoiODg4IiwiZXhwIjoxNTg2MjQwNzQyLCJpc3MiOiJxbVBsdXMiLCJuYmYiOjE1ODU2MzQ5NDJ9.9qaOFu7D5cq4vxTfLi4pyO_JGcKjVAEJIcoStJWJlYg'); +INSERT INTO `jwt_blacklists` VALUES (39, '2020-04-15 16:30:41', '2020-04-15 16:30:41', NULL, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVVUlEIjoiY2UwZDY2ODUtYzE1Zi00MTI2LWE1YjQtODkwYmM5ZDIzNTZkIiwiSUQiOjEwLCJOaWNrTmFtZSI6Iui2hee6p-euoeeQhuWRmCIsIkF1dGhvcml0eUlkIjoiODg4IiwiZXhwIjoxNTg3MDk1Njg5LCJpc3MiOiJxbVBsdXMiLCJuYmYiOjE1ODY0ODk4ODl9.-cNmRAyqhylZlzakwoFY08x7RnjI3CiWTiQc_Iabb-c'); -- ---------------------------- -- Table structure for sys_apis @@ -3997,7 +3991,7 @@ CREATE TABLE `sys_authorities` ( -- ---------------------------- -- Records of sys_authorities -- ---------------------------- -INSERT INTO `sys_authorities` VALUES ('888', '普通用户', '0', '2020-04-04 11:44:56', NULL, NULL); +INSERT INTO `sys_authorities` VALUES ('888', '普通用户', '0', '2020-04-04 11:44:56', '2020-04-15 13:15:24', NULL); INSERT INTO `sys_authorities` VALUES ('8881', '普通用户子角色', '888', '2020-04-04 11:44:56', NULL, NULL); INSERT INTO `sys_authorities` VALUES ('9528', '测试角色', '0', '2020-04-04 11:44:56', NULL, NULL); @@ -4098,14 +4092,14 @@ INSERT INTO `sys_base_menus` VALUES (5, '2019-09-19 22:13:18', '2019-12-12 16:57 INSERT INTO `sys_base_menus` VALUES (6, '2019-09-19 22:13:36', '2019-12-12 16:57:30', NULL, 0, 3, 'api', 'api', 0, 'view/superAdmin/api/api.vue', 'api管理', 's-platform', 'api管理', 3); INSERT INTO `sys_base_menus` VALUES (17, '2019-10-09 15:12:29', '2019-12-12 16:57:25', NULL, 0, 3, 'user', 'user', 0, 'view/superAdmin/user/user.vue', '用户管理', 'coordinate', '用户管理', 4); INSERT INTO `sys_base_menus` VALUES (18, '2019-10-15 22:27:22', '2019-12-12 16:51:33', NULL, 0, 0, 'person', 'person', 1, 'view/person/person.vue', '个人信息', 'user-solid', '个人信息', 4); -INSERT INTO `sys_base_menus` VALUES (19, '2019-10-20 11:14:42', '2020-03-29 21:39:18', NULL, 0, 0, 'example', 'example', 0, 'view/example/index.vue', '示例文件', 's-management', '示例文件', 6); +INSERT INTO `sys_base_menus` VALUES (19, '2019-10-20 11:14:42', '2020-04-15 16:35:28', NULL, 0, 0, 'example', 'example', 0, 'view/example/index.vue', '示例文件', 's-management', '示例文件', 6); INSERT INTO `sys_base_menus` VALUES (20, '2019-10-20 11:18:11', '2019-10-20 11:18:11', NULL, 0, 19, 'table', 'table', 0, 'view/example/table/table.vue', '表格示例', 's-order', '表格示例', 1); INSERT INTO `sys_base_menus` VALUES (21, '2019-10-20 11:19:52', '2019-12-12 16:58:15', NULL, 0, 19, 'form', 'form', 0, 'view/example/form/form.vue', '表单示例', 'document', '表单示例', 2); INSERT INTO `sys_base_menus` VALUES (22, '2019-10-20 11:22:19', '2019-12-12 16:58:20', NULL, 0, 19, 'rte', 'rte', 0, 'view/example/rte/rte.vue', '富文本编辑器', 'reading', '富文本编辑器', 3); INSERT INTO `sys_base_menus` VALUES (23, '2019-10-20 11:23:39', '2019-12-12 16:58:23', NULL, 0, 19, 'excel', 'excel', 0, 'view/example/excel/excel.vue', 'excel导入导出', 's-marketing', 'excel导入导出', 4); INSERT INTO `sys_base_menus` VALUES (26, '2019-10-20 11:27:02', '2019-12-12 16:58:27', NULL, 0, 19, 'upload', 'upload', 0, 'view/example/upload/upload.vue', '上传下载', 'upload', '上传下载', 5); INSERT INTO `sys_base_menus` VALUES (33, '2020-02-17 16:20:47', '2020-02-24 19:45:40', NULL, 0, 19, 'breakpoint', 'breakpoint', 0, 'view/example/breakpoint/breakpoint.vue', '断点续传', 'upload', '断点续传', 6); -INSERT INTO `sys_base_menus` VALUES (34, '2020-02-24 19:48:37', '2020-03-27 20:10:02', NULL, 0, 19, 'customer', 'customer', 0, 'view/example/customer/customer.vue', '客户列表(资源示例)', 's-custom', '客户列表(资源示例)', 7); +INSERT INTO `sys_base_menus` VALUES (34, '2020-02-24 19:48:37', '2020-04-15 16:26:21', NULL, 0, 19, 'customer', 'customer', 0, 'view/example/customer/customer.vue', '客户列表(资源示例)', 's-custom', '客户列表(资源示例)', 7); INSERT INTO `sys_base_menus` VALUES (38, '2020-03-29 21:31:03', '2020-03-29 21:31:03', NULL, 0, 0, 'systemTools', 'systemTools', 0, 'view/systemTools/index.vue', '系统工具', 's-cooperation', '系统工具', 5); INSERT INTO `sys_base_menus` VALUES (40, '2020-03-29 21:35:10', '2020-03-29 21:35:10', NULL, 0, 38, 'autoCode', 'autoCode', 0, 'view/systemTools/autoCode/index.vue', '代码生成器', 'cpu', '代码生成器', 1); INSERT INTO `sys_base_menus` VALUES (41, '2020-03-29 21:36:26', '2020-03-29 21:36:26', NULL, 0, 38, 'formCreate', 'formCreate', 0, 'view/systemTools/formCreate/index.vue', '表单生成器', 'magic-stick', '表单生成器', 2); diff --git a/web/src/api/authority.js b/web/src/api/authority.js index f900f602..c1463df0 100644 --- a/web/src/api/authority.js +++ b/web/src/api/authority.js @@ -59,4 +59,19 @@ export const setDataAuthority = (data) => { method: 'post', data }) +} + +// @Summary 修改角色 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body model.SysAuthority true "修改角色" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}" +// @Router /authority/setDataAuthority [post] +export const updateAuthority = (data) => { + return service({ + url: "/authority/updateAuthority", + method: 'put', + data + }) } \ No newline at end of file diff --git a/web/src/components/mixins/infoList.js b/web/src/components/mixins/infoList.js index ee820ef4..ed0e303a 100644 --- a/web/src/components/mixins/infoList.js +++ b/web/src/components/mixins/infoList.js @@ -24,9 +24,5 @@ export default { this.page = table.data.page this.pageSize = table.data.pageSize } - }, - mounted() { - this.getTableData() } - } \ No newline at end of file diff --git a/web/src/view/example/customer/customer.vue b/web/src/view/example/customer/customer.vue index ccb94f65..c8ba6b18 100644 --- a/web/src/view/example/customer/customer.vue +++ b/web/src/view/example/customer/customer.vue @@ -157,6 +157,9 @@ export default { this.type = "create" this.dialogFormVisible = true } + }, + created(){ + this.getTableData() } } diff --git a/web/src/view/example/upload/upload.vue b/web/src/view/example/upload/upload.vue index 78d14868..f1d96e28 100644 --- a/web/src/view/example/upload/upload.vue +++ b/web/src/view/example/upload/upload.vue @@ -145,6 +145,9 @@ export default { downloadFile(row) { downloadImage(row.url, row.name) } + }, + created(){ + this.getTableData() } } \ No newline at end of file diff --git a/web/src/view/superAdmin/authority/authority.vue b/web/src/view/superAdmin/authority/authority.vue index 5cf9e9e9..56cfde31 100644 --- a/web/src/view/superAdmin/authority/authority.vue +++ b/web/src/view/superAdmin/authority/authority.vue @@ -16,19 +16,34 @@ - - + + + + - + @@ -62,7 +77,8 @@ import { getAuthorityList, deleteAuthority, - createAuthority + createAuthority, + updateAuthority } from '@/api/authority' import Menus from '@/view/superAdmin/authority/components/menus' @@ -75,8 +91,13 @@ export default { mixins: [infoList], data() { return { + AuthorityOption:[{ + authorityId:"0", + authorityName:"根角色" + }], listApi: getAuthorityList, drawer: false, + dialogType:"add", activeRow: {}, activeUserId: 0, dialogTitle:"新增角色", @@ -137,6 +158,11 @@ export default { // 初始化表单 initForm() { this.$refs.authorityForm.resetFields() + this.form = { + authorityId: '', + authorityName: '', + parentId: '0' + } }, // 关闭窗口 closeDialog() { @@ -156,28 +182,96 @@ export default { } this.$refs.authorityForm.validate(async valid => { if (valid) { - const res = await createAuthority(this.form) - if (res.code == 0) { - this.$message({ - type: 'success', - message: '添加成功!' - }) - this.getTableData() - this.closeDialog() + switch (this.dialogType) { + case 'add': + { + const res = await createAuthority(this.form) + if (res.code == 0) { + this.$message({ + type: 'success', + message: '添加成功!' + }) + this.getTableData() + this.closeDialog() + } + } + break; + case 'edit': + { + const res = await updateAuthority(this.form) + if (res.code == 0) { + this.$message({ + type: 'success', + message: '添加成功!' + }) + this.getTableData() + this.closeDialog() + } + } + break; + default: + break; } + this.initForm() this.dialogFormVisible = false } }) }, + getAuthorityList(AuthorityData){ + AuthorityData.map(item=>{ + this.AuthorityOption.push({ + authorityId:item.authorityId, + authorityName:item.authorityName + }) + if(item.children){ + this.getAuthorityList(item.children) + } + }) + }, + findAuthoritySelf(authority,authData,outData){ + authData.some(item=>{ + if(item.authorityId == authority.authorityId){ + outData.push(item) + return true + } + this.findAuthoritySelf(authority,item.children,outData) + }) + }, + findAllChild(authority,array){ + authority&&authority.map(item=>{ + array.push(item.authorityId) + this.findAllChild(item.children,array) + }) + }, + canSelect(authority){ + const array = [] + const arrayIds = [] + this.findAuthoritySelf({authorityId:this.form.authorityId},this.tableData,array) + this.findAllChild(array,arrayIds) + return arrayIds.indexOf(authority.authorityId)>-1 + }, // 增加角色 addAuthority(parentId) { + this. dialogTitle = "新增角色" + this.dialogType = "add" this.form.parentId = parentId this.dialogFormVisible = true + }, + // 增加角色 + editAuthority(row) { + this. dialogTitle = "编辑角色" + this.dialogType = "edit" + for(let key in this.form){ + this.form[key] = row[key] + } + this.dialogFormVisible = true } }, - created() { + async created() { this.pageSize = 999 + await this.getTableData() + this.getAuthorityList(this.tableData) } } diff --git a/web/src/view/superAdmin/menu/menu.vue b/web/src/view/superAdmin/menu/menu.vue index 4fce4fdb..76c3270f 100644 --- a/web/src/view/superAdmin/menu/menu.vue +++ b/web/src/view/superAdmin/menu/menu.vue @@ -47,7 +47,21 @@ - + + + + @@ -90,6 +104,12 @@ export default { listApi: getMenuList, dialogFormVisible: false, dialogTitle:"新增菜单", + menuOption:[ + { + ID:"0", + title:"根菜单" + } + ], form: { ID: 0, path: '', @@ -211,10 +231,45 @@ export default { this.form = res.data.menu this.dialogFormVisible = true this.isEdit = true - } + }, + getMenuList(MenuData){ + MenuData.map(item=>{ + this.menuOption.push({ + ID:String(item.ID), + title:item.meta.title + }) + if(item.children){ + this.getMenuList(item.children) + } + }) + }, + findAuthoritySelf(mune,muneData,outData){ + muneData&&muneData.some(item=>{ + if(item.ID == mune.ID){ + outData.push(item) + return true + } + this.findAuthoritySelf(mune,item.children,outData) + }) + }, + findAllChild(menu,array){ + menu&&menu.map(item=>{ + array.push(String(item.ID)) + this.findAllChild(item.children,array) + }) + }, + canSelect(authority){ + const array = [] + const arrayIds = [] + this.findAuthoritySelf({ID:this.form.ID},this.tableData,array) + this.findAllChild(array,arrayIds) + return arrayIds.indexOf(authority.ID)>-1 + }, }, - created() { + async created() { this.pageSize = 999 + await this.getTableData() + await this.getMenuList(this.tableData) } } diff --git a/web/src/view/superAdmin/user/user.vue b/web/src/view/superAdmin/user/user.vue index a81456d2..8e0613cc 100644 --- a/web/src/view/superAdmin/user/user.vue +++ b/web/src/view/superAdmin/user/user.vue @@ -127,6 +127,17 @@ export default { ...mapGetters('user', ['token']) }, methods: { + getAuthorityList(AuthorityData){ + AuthorityData.map(item=>{ + this.authOptions.push({ + authorityId:item.authorityId, + authorityName:item.authorityName + }) + if(item.children){ + this.getAuthorityList(item.children) + } + }) + }, async enterAddUserDialog() { this.$refs.userForm.validate(async valid => { if (valid) { @@ -160,8 +171,10 @@ export default { } }, async created() { + this.getTableData() const res = await getAuthorityList({ page: 1, pageSize: 999 }) this.authOptions = res.data.list + }