fix: 修改密码
This commit is contained in:
parent
f897bfcbe9
commit
0aa1746679
|
@ -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>
|
||||||
|
@ -25,9 +28,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { clearLoginInfo } from '@/utils'
|
import { clearLoginInfo } from '@/utils'
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data() {
|
||||||
var validateConfirmPassword = (rule, value, callback) => {
|
var validateConfirmPassword = (rule, value, callback) => {
|
||||||
if (this.dataForm.newPassword !== value) {
|
if (this.dataForm.newPassword !== value) {
|
||||||
callback(new Error('确认密码与新密码不一致'))
|
callback(new Error('确认密码与新密码不一致'))
|
||||||
|
@ -58,27 +61,35 @@
|
||||||
},
|
},
|
||||||
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: {
|
||||||
// 初始化
|
// 初始化
|
||||||
init () {
|
init() {
|
||||||
this.visible = true
|
this.visible = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs['dataForm'].resetFields()
|
this.$refs['dataForm'].resetFields()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 表单提交
|
// 表单提交
|
||||||
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' })
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -100,6 +114,5 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue