123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <template>
- <div>
- <el-card class="box-card">
- <div slot="header" class="clearfix">
- <b>修改密码</b>
- </div>
- <el-form
- :model="addForm"
- :rules="rules"
- label-width="120px"
- ref="addForm"
- style="width: 500px"
- >
- <el-form-item label="原密码" prop="OldPwd">
- <el-input
- type="text"
- v-model="addForm.OldPwd"
- placeholder="请输入不超过20个字符"
- clearable
- autocomplete="new-password"
- ></el-input>
- </el-form-item>
- <el-form-item label="新密码" prop="NewPwd" v-if="visible">
- <el-input
- type="password"
- v-model="addForm.NewPwd"
- placeholder="请输入长度不超过20个字符"
- maxlength="20"
- autocomplete="new-password"
- >
- <i
- slot="suffix"
- class="el-icon-view el-input__icon"
- title="显示密码"
- @click="changePass('show')"
- style="cursor: pointer"
- ></i>
- </el-input>
- </el-form-item>
- <el-form-item label="新密码" prop="NewPwd" v-else>
- <el-input
- type="text"
- v-model="addForm.NewPwd"
- placeholder="请输入长度不超过20个字符"
- maxlength="20"
- autocomplete="new-password"
- >
- <i
- slot="suffix"
- class="el-icon-more el-input__icon"
- title="隐藏密码"
- @click="changePass('hide')"
- style="cursor: pointer"
- ></i>
- </el-input>
- </el-form-item>
- <el-form-item label="确认新密码" prop="twoNewPwd" v-if="twovisible">
- <el-input
- type="password"
- v-model="addForm.twoNewPwd"
- placeholder="请输入长度不超过20个字符"
- maxlength="20"
- >
- <i
- slot="suffix"
- class="el-icon-view el-input__icon"
- title="显示密码"
- @click="changetwoPass('show')"
- style="cursor: pointer"
- ></i>
- </el-input>
- </el-form-item>
- <el-form-item label="确认新密码" prop="twoNewPwd" v-else>
- <el-input
- type="text"
- v-model="addForm.twoNewPwd"
- placeholder="请输入长度不超过20个字符"
- maxlength="20"
- >
- <i
- slot="suffix"
- class="el-icon-more el-input__icon"
- title="隐藏密码"
- @click="changetwoPass('hide')"
- style="cursor: pointer"
- ></i>
- </el-input>
- </el-form-item>
- <el-form-item style="text-align: center;">
- <el-button type="primary" size="medium" @click.native="addSubmit"
- >确定</el-button
- >
- <el-button
- type="primary"
- size="medium"
- plain
- @click.native="historyBack"
- >返回</el-button
- >
- </el-form-item>
- </el-form>
- </el-card>
- </div>
- </template>
- <script>
- import { modifyPwd } from "@/api/api.js";
- import http from "@/api/http.js";
- import md5 from "@/utils/md5.js";
- import{checkPassWord} from '@/utils/commonOptions';
- export default {
- data() {
- return {
- visible: true,
- twovisible: true,
- addForm: {
- OldPwd: "",
- NewPwd: "",
- twoNewPwd: "",
- },
- rules: {
- OldPwd: [
- {
- required: true,
- message: "请输入原密码",
- trigger: "blur",
- },
- ],
- NewPwd: [
- {
- validator:(rule,value,callback)=>{
- if(!checkPassWord(value)){
- callback(new Error('密码要求8位及以上,包含数字、大写字母、小写字母、特殊字符中的三个类型'))
- }else{
- callback()
- }
- }
- },
- {
- required: true,
- message: "请输入确认密码",
- trigger: "blur",
- },
- ],
- twoNewPwd: [
- {
- required: true,
- message: "请输入确认密码",
- trigger: "blur",
- },
- ],
- },
- };
- },
- mounted() {},
- methods: {
- changePass(value) {
- this.visible = !(value === "show");
- },
- changetwoPass(value) {
- this.twovisible = !(value === "show");
- },
- addSubmit() {
- this.$refs.addForm.validate((valid) => {
- if (valid) {
- let that = this;
- if (that.addForm.NewPwd != that.addForm.twoNewPwd) {
- that.$message.warning("新密码两次输入不一致,请核对!");
- return false;
- }
- modifyPwd({
- OldPwd: md5.hex_md5(that.addForm.OldPwd),
- NewPwd: md5.hex_md5(that.addForm.NewPwd),
- }).then((res) => {
- if (res.Ret == 200) {
- that.$message.success("修改密码成功,请重新登录!");
- setTimeout(function () {
- localStorage.setItem("auth", "");
- localStorage.setItem("userName", "");
- localStorage.setItem("Role", "");
- localStorage.setItem("RoleType", "");
- localStorage.setItem("AdminId", "");
- localStorage.setItem("AdminName", "");
- localStorage.setItem("RoleIdentity", "");
- localStorage.setItem("ManageType", "");
- localStorage.setItem("loginTime", "");
- that.$router.push({ path: "/login" });
- }, 1000);
- }
- });
- }
- });
- },
- historyBack() {
- //返回上一页
- history.back();
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .box-card{
- .el-form-item{
- margin-bottom: 40px;
- }
- }
- </style>
|