You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.8 KiB
93 lines
2.8 KiB
|
7 years ago
|
<template>
|
||
|
6 years ago
|
<form-dialog :loading="loading" title="修改密码" :value="value" width="30%" @close="cancel">
|
||
|
6 years ago
|
<abstract-form :model="form" :rules="rules">
|
||
|
|
<el-form-item label="旧密码" prop="oldPwd">
|
||
|
6 years ago
|
<el-input v-model.trim="form.oldPwd" maxlength="100" type="password"/>
|
||
|
6 years ago
|
</el-form-item>
|
||
|
6 years ago
|
<el-form-item label="新密码" prop="newPwd">
|
||
|
6 years ago
|
<el-input v-model.trim="form.newPwd" maxlength="100" type="password"/>
|
||
|
6 years ago
|
</el-form-item>
|
||
|
6 years ago
|
</abstract-form>
|
||
|
6 years ago
|
|
||
|
6 years ago
|
<template v-slot:footer>
|
||
|
6 years ago
|
<el-button plain size="small" @click="closeDialog">取 消</el-button>
|
||
|
6 years ago
|
<el-button size="small" type="primary" @click="confirm">确 定</el-button>
|
||
|
|
</template>
|
||
|
6 years ago
|
</form-dialog>
|
||
|
7 years ago
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
6 years ago
|
import md5 from "js-md5"
|
||
|
6 years ago
|
import dialogMixin from "@/mixin/dialogMixin"
|
||
|
|
import AbstractForm from "@/component/AbstractForm"
|
||
|
|
import FormDialog from '@/component/FormDialog'
|
||
|
6 years ago
|
import {updateUserPwd} from "@/api/account"
|
||
|
6 years ago
|
import {elSuccess} from "@/util/message"
|
||
|
7 years ago
|
|
||
|
6 years ago
|
export default {
|
||
|
|
mixins: [dialogMixin],
|
||
|
6 years ago
|
|
||
|
6 years ago
|
components: {AbstractForm, FormDialog},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
data() {
|
||
|
|
return {
|
||
|
|
loading: false,
|
||
|
|
form: {
|
||
|
|
oldPwd: null,
|
||
|
|
newPwd: null
|
||
|
|
},
|
||
|
|
rules: {
|
||
|
|
oldPwd: [{required: true, message: '请输入原密码', trigger: 'change'}],
|
||
|
|
newPwd: [
|
||
|
|
{required: true, message: '请输入新密码', trigger: 'change'},
|
||
|
|
{
|
||
|
|
validator: (r, v, c) => v !== this.form.oldPwd ? c() : c('新密码不得与旧密码相同'),
|
||
|
|
trigger: 'change'
|
||
|
|
},
|
||
|
|
{
|
||
|
|
min: 6,
|
||
|
|
max: 32,
|
||
|
|
message: '请输入6-32位的密码',
|
||
|
|
trigger: 'change'
|
||
|
|
}
|
||
|
|
]
|
||
|
7 years ago
|
}
|
||
|
6 years ago
|
}
|
||
|
|
},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
props: {
|
||
|
|
value: Boolean
|
||
|
|
},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
methods: {
|
||
|
|
clearForm() {
|
||
|
|
this.form.oldPwd = null
|
||
|
|
this.form.newPwd = null
|
||
|
|
this.$nextTick(() => this.$refs.form.clearValidate())
|
||
|
|
},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
confirm() {
|
||
|
|
if (this.loading) return
|
||
|
|
this.$refs.form.validate(v => {
|
||
|
|
if (!v) return
|
||
|
|
this.loading = true
|
||
|
|
updateUserPwd({
|
||
|
|
oldPwd: md5(this.form.oldPwd),
|
||
|
|
newPwd: md5(this.form.newPwd),
|
||
|
7 years ago
|
})
|
||
|
6 years ago
|
.then(() => elSuccess('修改成功'))
|
||
|
|
.finally(() => {
|
||
|
|
this.loading = false
|
||
|
|
this.closeDialog()
|
||
|
|
})
|
||
|
|
})
|
||
|
|
},
|
||
|
6 years ago
|
|
||
|
6 years ago
|
cancel() {
|
||
|
|
this.closeDialog()
|
||
|
|
this.clearForm()
|
||
|
7 years ago
|
}
|
||
|
|
}
|
||
|
6 years ago
|
}
|
||
|
7 years ago
|
</script>
|