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)