From 1b21e0e2aabcab6f3b148bcdac8cb7942ed926ff Mon Sep 17 00:00:00 2001 From: xing Date: Tue, 23 Jun 2020 11:22:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=85=8D=E7=94=A8=E6=88=B7=E8=A7=92?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/users/users.vue | 51 ++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/src/components/users/users.vue b/src/components/users/users.vue index ba2a38e..90d1a04 100644 --- a/src/components/users/users.vue +++ b/src/components/users/users.vue @@ -37,8 +37,8 @@ @@ -105,6 +105,23 @@ + +
+

当前的用户: {{user.username}}

+

当前的角色: {{user.role_name}}

+

分配角色: + + + +

+ +
+ + 取消 + 确定 + +
+ @@ -151,6 +168,7 @@ export default { return { dialogVisible: false, editVisible: false, + setDialogVisible: false, addForm: { username: '', password: '', @@ -162,6 +180,7 @@ export default { email: '', mobile: '' }, + rights: [], editRules: editRule, rules: rule, queryInfo: { @@ -170,10 +189,36 @@ export default { pagesize: 5 }, userList: [], - total: 0 + total: 0, + user: {}, + roles: [], + selectKey: '' } }, methods: { + async setRole (user) { + this.user = user + this.setDialogVisible = true + const { data: res } = await this.$http.get('roles') + if (res.meta.status !== 200) { + return this.$message.error(res.meta.msg) + } + this.roles = res.data + }, + sub () { + if (!this.selectKey) { + return this.$message.warning('请先选择角色') + } + this.$http.put(`users/${this.user.id}/role`, { rid: this.selectKey }).then(response => { + const res = response.data + if (res.meta.status !== 200) { + return this.$message.error(res.meta.msg) + } + this.$message.success(res.meta.msg) + this.setDialogVisible = false + this.getUserList() + }).catch(error => error) + }, del (id) { this.$confirm('要删除该用户么?').then(async value => { const { data: res } = await this.$http.delete('users/' + id)