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>
@ -25,9 +28,9 @@
</template>
<script>
import { clearLoginInfo } from '@/utils'
export default {
data () {
import { clearLoginInfo } from '@/utils'
export default {
data() {
var validateConfirmPassword = (rule, value, callback) => {
if (this.dataForm.newPassword !== value) {
callback(new Error('确认密码与新密码不一致'))
@ -58,27 +61,35 @@
},
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: {
//
init () {
init() {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
})
},
//
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
dataFormSubmit() {
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' })
})
})
}
})
@ -100,6 +114,5 @@
})
}
}
}
}
</script>