refactor: 用户管理优化,移除状态修改功能

Former-commit-id: 9ffeddfe64cf0eb87c4c5e6b2d153daf4525cad0
This commit is contained in:
hxr
2023-10-13 23:33:59 +08:00
parent d42a9fc15d
commit 0d8d3c7705
2 changed files with 14 additions and 52 deletions

View File

@@ -66,20 +66,6 @@ export function updateUser(id: number, data: UserForm) {
}); });
} }
/**
* 修改用户状态
*
* @param id
* @param status
*/
export function updateUserStatus(id: number, status: number) {
return request({
url: "/api/v1/users/" + id + "/status",
method: "patch",
params: { status: status },
});
}
/** /**
* 修改用户密码 * 修改用户密码
* *

View File

@@ -11,7 +11,6 @@ import {
deleteUsers, deleteUsers,
addUser, addUser,
updateUser, updateUser,
updateUserStatus,
updateUserPassword, updateUserPassword,
downloadTemplateApi, downloadTemplateApi,
exportUser, exportUser,
@@ -102,30 +101,12 @@ function resetQuery() {
handleQuery(); handleQuery();
} }
/** 行选中事件 */ /** 行选中 */
function handleSelectionChange(selection: any) { function handleSelectionChange(selection: any) {
removeIds.value = selection.map((item: any) => item.id); removeIds.value = selection.map((item: any) => item.id);
} }
/** 用户状态 Change*/ /** 重置密码 */
function changeUserStatus(row: { [key: string]: any }) {
const text = row.status === 1 ? "启用" : "停用";
ElMessageBox.confirm("确认要" + text + row.username + "用户吗?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
updateUserStatus(row.id, row.status)
.then(() => {
ElMessage.success(text + "成功");
})
.catch(() => {
row.status = row.status === 1 ? 0 : 1;
});
});
}
/**重置密码 */
function resetPassword(row: { [key: string]: any }) { function resetPassword(row: { [key: string]: any }) {
ElMessageBox.prompt( ElMessageBox.prompt(
"请输入用户「" + row.username + "」的新密码", "请输入用户「" + row.username + "」的新密码",
@@ -134,17 +115,15 @@ function resetPassword(row: { [key: string]: any }) {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
} }
) ).then(({ value }) => {
.then(({ value }) => { if (!value) {
if (!value) { ElMessage.warning("请输入新密码");
ElMessage.warning("请输入新密码"); return false;
return false; }
} updateUserPassword(row.id, value).then(() => {
updateUserPassword(row.id, value).then(() => { ElMessage.success("密码重置成功,新密码是:" + value);
ElMessage.success("密码重置成功,新密码是:" + value); });
}); });
})
.catch(() => {});
} }
/** 加载角色下拉数据源 */ /** 加载角色下拉数据源 */
@@ -476,12 +455,9 @@ onMounted(() => {
<el-table-column label="状态" align="center" prop="status"> <el-table-column label="状态" align="center" prop="status">
<template #default="scope"> <template #default="scope">
<el-switch <el-tag :type="scope.row.status == 1 ? 'success' : 'info'">{{
v-model="scope.row.status" scope.row.status == 1 ? "启用" : "禁用"
:inactive-value="0" }}</el-tag>
:active-value="1"
@change="changeUserStatus(scope.row)"
/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column