<template>
|
<el-form
|
ref="editForm"
|
:model="editForm"
|
:rules="editFormRules"
|
label-width="80px"
|
@submit.prevent="onSubmit"
|
style="margin:20px;width:60%;min-width:600px;"
|
|
>
|
<el-form-item label="我的昵称" prop="uRealName">
|
<el-input v-model="editForm.uRealName"></el-input>
|
</el-form-item>
|
|
<el-form-item label="旧密码" prop="uLoginPWD">
|
<el-input v-model="editForm.uLoginPWD" type="text" auto-complete="off"></el-input>
|
</el-form-item>
|
<el-form-item label="新密码" prop="uLoginPWDNew">
|
<el-input v-model="editForm.uLoginPWDNew" show-password auto-complete="off"></el-input>
|
</el-form-item>
|
<el-form-item label="确认密码" prop="uLoginPWDConfirm">
|
<el-input v-model="editForm.uLoginPWDConfirm" show-password auto-complete="off"></el-input>
|
</el-form-item>
|
<!--
|
<el-form-item label="头像">
|
<el-upload
|
class="avatar-uploader"
|
action="/images/Upload/Pic"
|
:show-file-list="false"
|
:headers="token"
|
:data="ruleForm"
|
:on-success="handleAvatarSuccess"
|
:before-upload="beforeAvatarUpload"
|
>
|
<img v-if="editForm.tdLogo" :src="editForm.tdLogo" class="avatar" />
|
<i v-else class="el-icon-plus avatar-uploader-icon plus-sign"></i>
|
</el-upload>
|
</el-form-item> -->
|
|
<el-form-item label="留言/备注">
|
<el-input type="textarea" v-model="editForm.uRemark"></el-input>
|
</el-form-item>
|
<el-form-item>
|
<el-button @click.native="onSubmit" type="primary" :loading="editLoading">更新</el-button>
|
<el-button @click.native.prevent>取消</el-button>
|
</el-form-item>
|
</el-form>
|
</template>
|
|
<script>
|
import {
|
editUserPWD,//修改用户密码接口
|
} from "../../api/api";
|
export default {
|
data() {
|
var validatePass2 = (rule, value, callback) => {
|
if (value === '') {
|
callback(new Error('请再次输入密码'));
|
} else if (value !== this.editForm.uLoginPWDNew) {
|
callback(new Error('两次输入密码不一致!'));
|
} else {
|
callback();
|
}
|
};
|
return {
|
editLoading: false,
|
editForm: {
|
id: 0,
|
uID: 0,
|
RID: 0,
|
uLoginName: "",
|
uRealName: "",
|
uLoginPWDNew:"",
|
uLoginPWD:"",
|
|
},
|
editFormRules:{
|
uRealName:[{ required: true, message: "请输入昵称", trigger: "blur" }],
|
uLoginPWD:[{required: true, message: "请输入旧密码", trigger: "blur"}],
|
uLoginPWDNew:[{required: true, message: "请输入新密码", trigger: "blur"}],
|
uLoginPWDConfirm:[ { validator: validatePass2, trigger: 'blur' }],
|
},
|
token: {
|
Authorization: "Bearer "
|
},
|
ruleForm: {
|
max_ver: "",
|
min_ver: "",
|
enable: ""
|
},
|
beforeAvatarUpload(file) {
|
const isJPG = file.type === "image/jpeg";
|
const isLt1M = file.size / 1024 / 1024 < 1;
|
|
// if (!isJPG) {
|
// this.$message.error('上传头像图片只能是 JPG 格式!')
|
// }
|
if (!isLt1M) {
|
this.$message.error("上传头像图片大小不能超过 1MB!");
|
}
|
return isLt1M;
|
}
|
};
|
},
|
methods: {
|
onSubmit:function() {
|
this.$refs.editForm.validate((valid) => {
|
if(valid){ this.$confirm("确认提交吗?", "提示", {}).then(() => {
|
|
let para = Object.assign({}, this.editForm);
|
editUserPWD(para).then((res) => {
|
|
if (res.data.success) {
|
this.editLoading = false;
|
//NProgress.done();
|
this.$message({
|
message: res.data.msg,
|
type: "success",
|
});
|
this.$refs["editForm"].resetFields();
|
this.editFormVisible = false;
|
// this.getUsers();
|
} else {
|
this.$message({
|
message: res.data.msg,
|
type: "error",
|
});
|
this.editLoading = false;
|
}
|
});
|
});
|
}
|
});
|
// this.$message({
|
// message: "失败!该操作无权限",
|
// type: "error"
|
// });
|
},
|
handleAvatarSuccess(res, file) {
|
this.editForm.tdLogo = "/" + res.response;
|
}
|
},
|
mounted() {
|
let tokenStr = window.localStorage.Token;
|
this.token = {
|
Authorization: "Bearer " + tokenStr
|
};
|
|
var user = JSON.parse(window.localStorage.user);
|
this.editForm.uRealName = user ? user.uRealName : "";
|
}
|
};
|
</script>
|
|
<style>
|
.avatar-uploader .el-upload {
|
border: 1px dashed #d9d9d9;
|
border-radius: 6px;
|
cursor: pointer;
|
position: relative;
|
overflow: hidden;
|
}
|
|
.avatar-uploader .el-upload:hover {
|
border-color: #409EFF;
|
}
|
|
.avatar-uploader-icon {
|
font-size: 28px;
|
color: #8c939d;
|
width: 120px;
|
height: 120px;
|
text-align: center;
|
}
|
.plus-sign{
|
line-height: 120px !important;
|
}
|
.avatar {
|
width: 120px;
|
height: 120px;
|
display: block;
|
}
|
|
.markdown-body{
|
height: 500px !important;
|
}
|
</style>
|