|
@@ -9,6 +9,7 @@
|
|
|
<div class="header-right userinfo">
|
|
|
<!-- <div class="headimg"></div> -->
|
|
|
<div class="username">{{userName}}</div>
|
|
|
+ <el-button type="text" @click="handleModifyPwd">修改密码</el-button>
|
|
|
<el-button type="text" @click="handleLogout">退出</el-button>
|
|
|
</div>
|
|
|
</el-header>
|
|
@@ -46,16 +47,46 @@
|
|
|
</el-main>
|
|
|
</el-container>
|
|
|
</el-container>
|
|
|
+ <el-dialog title="修改密码" :visible.sync="dialogFormVisible" width="600px" @close="close">
|
|
|
+ <el-form :model="form" size="small" :rules="rules" ref="form">
|
|
|
+ <el-form-item label="新密码" prop="password" :label-width="formLabelWidth">
|
|
|
+ <el-input v-model="form.password" placeholder="请输入新密码"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="原密码" prop="oldPassword" :label-width="formLabelWidth">
|
|
|
+ <el-input v-model="form.oldPassword" placeholder="请输入原密码"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button size="small" @click="dialogFormVisible = false">取 消</el-button>
|
|
|
+ <el-button size="small" type="primary" @click="submitPwd" :loading="loading">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { pwdResetPwd } from '@/request/request'
|
|
|
export default {
|
|
|
name: 'Main',
|
|
|
data() {
|
|
|
return {
|
|
|
defaultActive: '/main/user',
|
|
|
- userName: ''
|
|
|
+ userName: '',
|
|
|
+ form: {
|
|
|
+ password: '',
|
|
|
+ oldPassword: ''
|
|
|
+ },
|
|
|
+ formLabelWidth: '80px',
|
|
|
+ dialogFormVisible: false,
|
|
|
+ loading: false,
|
|
|
+ rules: {
|
|
|
+ password: [
|
|
|
+ { required: true, message: '请输入新密码', trigger: 'change' }
|
|
|
+ ],
|
|
|
+ oldPassword: [
|
|
|
+ { required: true, message: '请输入原密码', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -79,10 +110,42 @@ export default {
|
|
|
console.log(index);
|
|
|
},
|
|
|
handleLogout () {
|
|
|
- this.$confirm('确定退出吗?').then( _=> {
|
|
|
+ this.$confirm('确定退出吗?','提示').then( _=> {
|
|
|
sessionStorage.clear()
|
|
|
this.$router.replace('/login')
|
|
|
}).catch(_ => {});
|
|
|
+ },
|
|
|
+ close () {
|
|
|
+ this.form.password = ''
|
|
|
+ this.form.oldPassword = ''
|
|
|
+ this.$refs['form'].clearValidate()
|
|
|
+ },
|
|
|
+ handleModifyPwd () {
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ },
|
|
|
+ submitPwd () {
|
|
|
+ this.$refs['form'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let data = {
|
|
|
+ password: this.form.password,
|
|
|
+ oldPassword: this.form.oldPassword
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ pwdResetPwd(data).then(res => {
|
|
|
+ this.dialogFormVisible = false
|
|
|
+ this.loading = false
|
|
|
+ this.$message({
|
|
|
+ message: '密码修改成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }).catch(e => {
|
|
|
+ this.loading = false
|
|
|
+ console.log(e);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
};
|