123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <template>
- <div>
- <el-card class="box-card">
- <div slot="header" class="clearfix">
- <b><!-- 修改密码 -->{{ $t('MainPage.tab_reset_pwd') }}</b>
- </div>
- <el-form
- :model="addForm"
- :rules="rules"
- label-width="120px"
- ref="addForm"
- style="width: 500px"
- >
- <el-form-item :label="$t('ResetPwdPage.label_old_pwd')" prop="OldPwd">
- <el-input
- type="text"
- v-model="addForm.OldPwd"
- :placeholder="$t('ResetPwdPage.ph_pwd')"
- clearable
- autocomplete="new-password"
- ></el-input>
- </el-form-item>
- <el-form-item :label="$t('ResetPwdPage.label_new_pwd')" prop="NewPwd" v-if="visible">
- <el-input
- type="password"
- v-model="addForm.NewPwd"
- :placeholder="$t('ResetPwdPage.ph_pwd')"
- maxlength="20"
- autocomplete="new-password"
- >
- <i
- slot="suffix"
- class="el-icon-view el-input__icon"
- @click="changePass('show')"
- style="cursor: pointer"
- ></i>
- </el-input>
- </el-form-item>
- <el-form-item :label="$t('ResetPwdPage.label_new_pwd')" prop="NewPwd" v-else>
- <el-input
- type="text"
- v-model="addForm.NewPwd"
- :placeholder="$t('ResetPwdPage.ph_pwd')"
- maxlength="20"
- autocomplete="new-password"
- >
- <i
- slot="suffix"
- class="el-icon-more el-input__icon"
- @click="changePass('hide')"
- style="cursor: pointer"
- ></i>
- </el-input>
- </el-form-item>
- <el-form-item :label="$t('ResetPwdPage.label_ensure_pwd')" prop="twoNewPwd" v-if="twovisible">
- <el-input
- type="password"
- v-model="addForm.twoNewPwd"
- :placeholder="$t('ResetPwdPage.ph_pwd')"
- maxlength="20"
- >
- <i
- slot="suffix"
- class="el-icon-view el-input__icon"
- @click="changetwoPass('show')"
- style="cursor: pointer"
- ></i>
- </el-input>
- </el-form-item>
- <el-form-item :label="$t('ResetPwdPage.label_ensure_pwd')" prop="twoNewPwd" v-else>
- <el-input
- type="text"
- v-model="addForm.twoNewPwd"
- :placeholder="$t('ResetPwdPage.ph_pwd')"
- maxlength="20"
- >
- <i
- slot="suffix"
- class="el-icon-more el-input__icon"
- @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"
- ><!-- 确定 -->{{ $t('Dialog.confirm_btn') }}</el-button
- >
- <el-button
- type="primary"
- size="medium"
- plain
- @click.native="historyBack"
- ><!-- 返回 -->{{ $t('Dialog.back_btn') }}</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: /* "请输入原密码" */ this.$t('ResetPwdPage.vaild_old'),
- trigger: "blur",
- },
- ],
- NewPwd: [
- {
- validator:(rule,value,callback)=>{
- if(!checkPassWord(value)){
- callback(new Error(/* '密码要求8位及以上,包含数字、大写字母、小写字母、特殊字符中的三个类型' */this.$t('ResetPwdPage.vaild_rule')))
- }else{
- callback()
- }
- }
- },
- {
- required: true,
- message: /* "请输入确认密码" */this.$t('ResetPwdPage.vaild_new'),
- trigger: "blur",
- },
- ],
- twoNewPwd: [
- {
- required: true,
- message: /* "请输入确认密码" */this.$t('ResetPwdPage.vaild_new'),
- 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(/* "新密码两次输入不一致,请核对!" */this.$t('ResetPwdPage.vaild_same'));
- 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(/* "修改密码成功,请重新登录!" */ this.$t('ResetPwdPage.edit_pwd_msg'));
- 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>
|