<template>
|
<el-dialog :visible.sync="show" :show-close="false" width="500px" :close-on-click-modal="false" append-to-body>
|
<div class="content">
|
<el-form label-position="left" label-width="120px" ref="form" :model="form" :rules="rules">
|
<div class="title">修改密码 | Change Password</div>
|
<el-row :gutter="20" class="form-row">
|
<el-col :span="24">
|
<el-form-item label="原密码:" prop="oldPassword">
|
<template #label>
|
<div class="form-label">
|
<div>原密码</div>
|
<div class="label-en">Current Password</div>
|
</div>
|
</template>
|
<el-input v-model="form.oldPassword" type="password" placeholder="请输入"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="新密码:" prop="newPassword">
|
<template #label>
|
<div class="form-label">
|
<div>新密码</div>
|
<div class="label-en">New Password</div>
|
</div>
|
</template>
|
<el-input v-model="form.newPassword" type="password" placeholder="请输入"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="确认密码:" prop="confirmPassword">
|
<template #label>
|
<div class="form-label">
|
<div>确认密码</div>
|
<div class="label-en">Confirm Password</div>
|
</div>
|
</template>
|
<el-input v-model="form.confirmPassword" type="password" placeholder="请输入"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<div class="btns">
|
<el-button @click="$emit('close')">取消 | Cancel</el-button>
|
<el-button type="primary" @click="submit">确定 | Confirm</el-button>
|
</div>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { changePwd } from '@/view/service'
|
import CryptoJS from 'crypto-js';
|
|
export default {
|
props: ['show'],
|
data() {
|
return {
|
form: {
|
oldPassword: '',
|
newPassword: '',
|
confirmPassword: ''
|
},
|
rules: {
|
oldPassword: [
|
{ required: true, message: '请输入原密码', trigger: 'change' }
|
],
|
newPassword: [
|
{ required: true, message: '请输入新密码', trigger: 'change' },
|
{ min: 6, message: '密码长度不能小于6位', trigger: 'change' }
|
],
|
confirmPassword: [
|
{ required: true, message: '请确认新密码', trigger: 'change' },
|
{ validator: this.validateConfirmPassword, trigger: 'change' }
|
]
|
}
|
}
|
},
|
methods: {
|
validateConfirmPassword(rule, value, callback) {
|
if (value !== this.form.newPassword) {
|
callback(new Error('两次输入的密码不一致'));
|
} else {
|
callback();
|
}
|
},
|
submit() {
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
let params = {
|
extra: localStorage.getItem('extra'),
|
oldPwd: CryptoJS.MD5(this.form.oldPassword).toString(),
|
newPwd: CryptoJS.MD5(this.form.newPassword).toString(),
|
}
|
|
changePwd(params).then(res => {
|
this.$message.success('密码修改成功')
|
this.$emit('close')
|
})
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="less" scoped>
|
.content {
|
.title {
|
padding: 31px 0;
|
text-align: center;
|
font-size: 18px;
|
font-weight: bold;
|
color: #3B3F56;
|
line-height: 27px;
|
}
|
|
.form-row {
|
padding: 0 20px;
|
}
|
|
.btns {
|
display: flex;
|
justify-content: center;
|
margin-top: 32px;
|
padding-bottom: 33px;
|
|
.el-button {
|
width: 190px;
|
height: 50px;
|
font-size: 20px;
|
margin: 0 10px;
|
}
|
|
.el-button--primary {
|
background-color: #014099;
|
border-color: #014099;
|
}
|
}
|
}
|
|
/deep/ .el-dialog {
|
border-radius: 8px;
|
|
.el-dialog__header {
|
display: none !important;
|
}
|
|
.el-dialog__body {
|
padding: 0 !important;
|
}
|
}
|
|
/deep/ .el-form {
|
.el-form-item__label {
|
font-size: 15px;
|
color: #3B3F56;
|
font-weight: 500;
|
display: flex;
|
}
|
|
.form-label {
|
white-space: normal;
|
line-height: 1.2;
|
display: flex;
|
flex-direction: column;
|
|
.label-en {
|
font-size: 12px;
|
color: #999;
|
white-space: nowrap;
|
}
|
}
|
}
|
</style>
|