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