You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/views/components/passwordDialog.vue

85 lines
2.5 KiB
Vue

<template>
<el-dialog
class="psdDialog"
title="修改密码"
:visible.sync="isShow"
:close-on-click-modal="false"
width="420px"
>
<el-form :model="psdForm" :rules="rules" ref="formInfo" label-position="left" label-width="80px">
<el-form-item label="用户名:">
<el-input v-model="psdForm.userName" autocomplete="off" :disabled="true"></el-input>
</el-form-item>
<!-- <el-form-item label="原密码:">
<el-input v-model="psdForm.originalPsd" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="新密码:">
<el-input v-model="psdForm.newPsd" autocomplete="off"></el-input>
</el-form-item> -->
<el-form-item label="密码:">
<el-input v-model="psdForm.password" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="isShow = false">取 消</el-button>
<el-button type="primary" @click="submitForm"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { updateUserApi } from "@/utils/api/index";
export default {
data() {
return {
isShow:false,
psdForm: {
userName: localStorage.getItem('userName'),
originalPsd: "",
newPsd: "",
password: "",
},
rules: {
userName: [
{ required: true, message: "请输入用户名", trigger: "blur" },
],
password: [
{ required: true, message: "请输入密码", trigger: "blur" },
{ min: 6, max: 8, message: '请输入6-8位字符', trigger: 'blur' }
],
},
};
},
methods: {
// 保存确定操作
submitForm() {
this.$refs.formInfo.validate((valid) => {
if (valid) {
this.$set(this.psdForm,'userId',localStorage.getItem('userid'))
updateUserApi(this.psdForm)
.then((res) => {
if (res.code == 200) {
this.$message.success("修改成功,请重新登录");
this.isShow = false
this.$store.commit("REMOVE_INFO");
this.$router.push("/login");
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {});
} else {
console.log("error submit!!");
return false;
}
});
},
display() {
this.isShow = true;
},
hide() {
this.isShow = false;
},
},
};
</script>