fix: 修改密码

This commit is contained in:
lzhizhao 2025-09-25 19:38:06 +08:00
parent f897bfcbe9
commit 0aa1746679
1 changed files with 71 additions and 58 deletions

View File

@ -1,9 +1,12 @@
<template> <template>
<el-dialog <el-dialog title="修改密码" :visible.sync="visible" :append-to-body="true">
title="修改密码" <el-form
:visible.sync="visible" :model="dataForm"
:append-to-body="true"> :rules="dataRule"
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px"> ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="80px"
>
<el-form-item label="账号"> <el-form-item label="账号">
<span>{{ userName }}</span> <span>{{ userName }}</span>
</el-form-item> </el-form-item>
@ -58,11 +61,17 @@
}, },
computed: { computed: {
userName: { userName: {
get () { return this.$store.state.user.name } get() {
return this.$store.state.user.name
}
}, },
mainTabs: { mainTabs: {
get () { return this.$store.state.common.mainTabs }, get() {
set (val) { this.$store.commit('common/updateMainTabs', val) } return this.$store.state.common.mainTabs
},
set(val) {
this.$store.commit('common/updateMainTabs', val)
}
} }
}, },
methods: { methods: {
@ -75,10 +84,12 @@
}, },
// //
dataFormSubmit() { dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate(valid => {
if (valid) { if (valid) {
this.$api.password(this.dataForm.password,this.dataForm.newPassword).then(({data}) => { this.$api
if (data && data.code === 0) { .password(this.dataForm.password, this.dataForm.newPassword)
.then(({ data }) => {
if (data && data.success) {
this.$message({ this.$message({
message: '操作成功', message: '操作成功',
type: 'success', type: 'success',
@ -88,7 +99,10 @@
this.$nextTick(() => { this.$nextTick(() => {
this.mainTabs = [] this.mainTabs = []
clearLoginInfo() clearLoginInfo()
this.$router.replace({ name: 'login' }) this.$api.logout().then(({ data }) => {
clearLoginInfo()
this.$router.push({ name: 'login' })
})
}) })
} }
}) })
@ -102,4 +116,3 @@
} }
} }
</script> </script>