用户删除、重置密码,分配角色.

This commit is contained in:
许晓东
2023-05-09 07:16:55 +08:00
parent 38ca2cfc52
commit da1ddeb1e7
8 changed files with 312 additions and 10 deletions

View File

@@ -53,8 +53,22 @@
>删除
</a-button>
</a-popconfirm>
<a-button size="small" href="javascript:;" class="operation-btn"
>重置密码
<a-popconfirm
:title="'重置用户: ' + record.username + '密码?'"
ok-text="确认"
cancel-text="取消"
@confirm="resetPassword(record)"
>
<a-button size="small" href="javascript:;" class="operation-btn"
>重置密码
</a-button>
</a-popconfirm>
<a-button
size="small"
href="javascript:;"
class="operation-btn"
@click="openUpdateUserRoleDialog(record)"
>分配角色
</a-button>
</div>
</a-table>
@@ -62,6 +76,16 @@
@closeCreateUserDialog="closeCreateUserDialog"
:visible="showCreateUserDialog"
></CreateUser>
<MessageBox
:visible="showMessageBox"
:message="messageBoxContent"
@closeMessageBox="closeMessageBox"
></MessageBox>
<UpdateUserRole
:visible="showUpdateUserRole"
:user="selectUser"
@closeUpdateUserRoleDialog="closeUpdateUserRoleDialog"
></UpdateUserRole>
</a-spin>
</div>
</template>
@@ -72,10 +96,12 @@ import request from "@/utils/request";
import notification from "ant-design-vue/lib/notification";
import { UserManageApi } from "@/utils/api";
import CreateUser from "@/views/user/CreateUser.vue";
import MessageBox from "@/views/components/MessageBox.vue";
import UpdateUserRole from "@/views/user/UpdateUserRole.vue";
export default {
name: "User",
components: { CreateUser },
components: { CreateUser, MessageBox, UpdateUserRole },
props: {
topicList: {
type: Array,
@@ -89,6 +115,10 @@ export default {
filteredData: [],
filterUsername: "",
showCreateUserDialog: false,
showMessageBox: false,
showUpdateUserRole: false,
messageBoxContent: "",
selectUser: {},
columns: [
{
title: "用户名",
@@ -97,8 +127,8 @@ export default {
},
{
title: "角色",
dataIndex: "roleIds",
key: "roleIds",
dataIndex: "roleNames",
key: "roleNames",
},
{
title: "操作",
@@ -150,8 +180,23 @@ export default {
this.showCreateUserDialog = false;
if (p.refresh) {
this.refresh();
this.messageBoxContent = "用户初始密码:" + p.data;
this.showMessageBox = true;
}
},
openUpdateUserRoleDialog(user) {
this.selectUser = user;
this.showUpdateUserRole = true;
},
closeUpdateUserRoleDialog(p) {
this.showUpdateUserRole = false;
if (p.refresh) {
this.refresh();
}
},
closeMessageBox() {
this.showMessageBox = false;
},
deleteUser(user) {
this.loading = true;
request({
@@ -169,6 +214,27 @@ export default {
}
});
},
resetPassword(record) {
this.loading = true;
const params = Object.assign({}, record);
params.resetPassword = true;
request({
url: UserManageApi.addOrUpdateUser.url,
method: UserManageApi.addOrUpdateUser.method,
data: params,
}).then((res) => {
this.loading = false;
if (res.code == 0) {
this.messageBoxContent = "密码重置成功,新密码:" + res.data;
this.showMessageBox = true;
} else {
notification.error({
message: "error",
description: res.msg,
});
}
});
},
},
created() {
this.handleSearch();
@@ -222,4 +288,8 @@ export default {
margin-bottom: 5px;
margin-top: 5px;
}
.operation-btn {
margin-right: 3%;
}
</style>