提交代码
parent
d447c3a304
commit
2c161f902a
|
@ -23,15 +23,15 @@ const deleteUser = (id) => {
|
||||||
method: "delete"
|
method: "delete"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//更新用户信息
|
//更新用户密码
|
||||||
const updatePassword = (id, data) => {
|
const updatePassword = (id, data) => {
|
||||||
return request({
|
return request({
|
||||||
url: `/users/${id}/auth`,
|
url: `/users/${id}/password`,
|
||||||
method: "put",
|
method: "put",
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//更新用户密码
|
//更新用户信息
|
||||||
const updateAuth = (id, data) => {
|
const updateAuth = (id, data) => {
|
||||||
return request({
|
return request({
|
||||||
url: `/users/${id}/auth`,
|
url: `/users/${id}/auth`,
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
</div>
|
</div>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item >
|
<el-dropdown-item @click="resetPassword">
|
||||||
修改密码
|
修改密码
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item @click="logout">
|
<el-dropdown-item @click="logout">
|
||||||
|
@ -50,7 +50,9 @@ import {
|
||||||
useUserStore,
|
useUserStore,
|
||||||
useSettingsStore,
|
useSettingsStore,
|
||||||
} from "@/store";
|
} from "@/store";
|
||||||
|
import md5 from 'js-md5';
|
||||||
import defaultSettings from "@/settings";
|
import defaultSettings from "@/settings";
|
||||||
|
import UserAPI from "@/api/myUser";
|
||||||
import { DeviceEnum } from "@/enums/DeviceEnum";
|
import { DeviceEnum } from "@/enums/DeviceEnum";
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
@ -85,6 +87,29 @@ function logout() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 重置密码 */
|
||||||
|
function resetPassword() {
|
||||||
|
ElMessageBox.prompt("请输入用户「" + userStore.user.username + "」的新密码", "重置密码", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
}).then(({ value }) => {
|
||||||
|
if (!value || value.length < 6) {
|
||||||
|
// 检查密码是否为空或少于6位
|
||||||
|
ElMessage.warning("密码至少需要6位字符,请重新输入");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
debugger
|
||||||
|
UserAPI.updatePassword(userStore.user.userId, { password: md5(value) }).then((res) => {
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
ElMessage.success("密码重置成功,新密码是:" + value);
|
||||||
|
} else {
|
||||||
|
ElMessage.error("密码重置失败!" + res.data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.setting-item {
|
.setting-item {
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item >
|
<el-dropdown-item @click="resetPassword">
|
||||||
修改密码
|
修改密码
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item @click="logout">
|
<el-dropdown-item @click="logout">
|
||||||
|
@ -45,7 +45,9 @@ import {
|
||||||
useUserStore,
|
useUserStore,
|
||||||
useSettingsStore,
|
useSettingsStore,
|
||||||
} from "@/store";
|
} from "@/store";
|
||||||
|
import md5 from 'js-md5';
|
||||||
import defaultSettings from "@/settings";
|
import defaultSettings from "@/settings";
|
||||||
|
import UserAPI from "@/api/myUser";
|
||||||
import { DeviceEnum } from "@/enums/DeviceEnum";
|
import { DeviceEnum } from "@/enums/DeviceEnum";
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
@ -80,6 +82,28 @@ function logout() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 重置密码 */
|
||||||
|
function resetPassword() {
|
||||||
|
ElMessageBox.prompt("请输入用户「" + userStore.user.username + "」的新密码", "重置密码", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
}).then(({ value }) => {
|
||||||
|
if (!value || value.length < 6) {
|
||||||
|
// 检查密码是否为空或少于6位
|
||||||
|
ElMessage.warning("密码至少需要6位字符,请重新输入");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
debugger
|
||||||
|
UserAPI.updatePassword(userStore.user.userId, { password: md5(value) }).then((res) => {
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
ElMessage.success("密码重置成功,新密码是:" + value);
|
||||||
|
} else {
|
||||||
|
ElMessage.error("密码重置失败!" + res.data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.setting-item {
|
.setting-item {
|
||||||
|
|
|
@ -235,6 +235,11 @@ const handleSubmit = useThrottleFn(() => {
|
||||||
formLoading.value = false;
|
formLoading.value = false;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
if (form.password.length < 6) {
|
||||||
|
// 检查密码是否为空或少于6位
|
||||||
|
ElMessage.warning("密码至少需要6位字符,请重新输入");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//新增用户时判断密码是否一致
|
//新增用户时判断密码是否一致
|
||||||
if (form.user_password != form.password) {
|
if (form.user_password != form.password) {
|
||||||
ElMessage.error("两次密码不一致");
|
ElMessage.error("两次密码不一致");
|
||||||
|
|
Loading…
Reference in New Issue