resetpassword.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <div slot="header" class="clearfix">
  5. <b><!-- 修改密码 -->{{ $t('MainPage.tab_reset_pwd') }}</b>
  6. </div>
  7. <el-form
  8. :model="addForm"
  9. :rules="rules"
  10. label-width="120px"
  11. ref="addForm"
  12. style="width: 500px"
  13. >
  14. <el-form-item :label="$t('ResetPwdPage.label_old_pwd')" prop="OldPwd">
  15. <el-input
  16. type="text"
  17. v-model="addForm.OldPwd"
  18. :placeholder="$t('ResetPwdPage.ph_pwd')"
  19. clearable
  20. autocomplete="new-password"
  21. ></el-input>
  22. </el-form-item>
  23. <el-form-item :label="$t('ResetPwdPage.label_new_pwd')" prop="NewPwd" v-if="visible">
  24. <el-input
  25. type="password"
  26. v-model="addForm.NewPwd"
  27. :placeholder="$t('ResetPwdPage.ph_pwd')"
  28. maxlength="20"
  29. autocomplete="new-password"
  30. >
  31. <i
  32. slot="suffix"
  33. class="el-icon-view el-input__icon"
  34. @click="changePass('show')"
  35. style="cursor: pointer"
  36. ></i>
  37. </el-input>
  38. </el-form-item>
  39. <el-form-item :label="$t('ResetPwdPage.label_new_pwd')" prop="NewPwd" v-else>
  40. <el-input
  41. type="text"
  42. v-model="addForm.NewPwd"
  43. :placeholder="$t('ResetPwdPage.ph_pwd')"
  44. maxlength="20"
  45. autocomplete="new-password"
  46. >
  47. <i
  48. slot="suffix"
  49. class="el-icon-more el-input__icon"
  50. @click="changePass('hide')"
  51. style="cursor: pointer"
  52. ></i>
  53. </el-input>
  54. </el-form-item>
  55. <el-form-item :label="$t('ResetPwdPage.label_ensure_pwd')" prop="twoNewPwd" v-if="twovisible">
  56. <el-input
  57. type="password"
  58. v-model="addForm.twoNewPwd"
  59. :placeholder="$t('ResetPwdPage.ph_pwd')"
  60. maxlength="20"
  61. >
  62. <i
  63. slot="suffix"
  64. class="el-icon-view el-input__icon"
  65. @click="changetwoPass('show')"
  66. style="cursor: pointer"
  67. ></i>
  68. </el-input>
  69. </el-form-item>
  70. <el-form-item :label="$t('ResetPwdPage.label_ensure_pwd')" prop="twoNewPwd" v-else>
  71. <el-input
  72. type="text"
  73. v-model="addForm.twoNewPwd"
  74. :placeholder="$t('ResetPwdPage.ph_pwd')"
  75. maxlength="20"
  76. >
  77. <i
  78. slot="suffix"
  79. class="el-icon-more el-input__icon"
  80. @click="changetwoPass('hide')"
  81. style="cursor: pointer"
  82. ></i>
  83. </el-input>
  84. </el-form-item>
  85. <el-form-item style="text-align: center;">
  86. <el-button type="primary" size="medium" @click.native="addSubmit"
  87. ><!-- 确定 -->{{ $t('Dialog.confirm_btn') }}</el-button
  88. >
  89. <el-button
  90. type="primary"
  91. size="medium"
  92. plain
  93. @click.native="historyBack"
  94. ><!-- 返回 -->{{ $t('Dialog.back_btn') }}</el-button
  95. >
  96. </el-form-item>
  97. </el-form>
  98. </el-card>
  99. </div>
  100. </template>
  101. <script>
  102. import { modifyPwd } from "@/api/api.js";
  103. import http from "@/api/http.js";
  104. import md5 from "@/utils/md5.js";
  105. import{checkPassWord} from '@/utils/commonOptions';
  106. export default {
  107. data() {
  108. return {
  109. visible: true,
  110. twovisible: true,
  111. addForm: {
  112. OldPwd: "",
  113. NewPwd: "",
  114. twoNewPwd: "",
  115. },
  116. rules: {
  117. OldPwd: [
  118. {
  119. required: true,
  120. message: /* "请输入原密码" */ this.$t('ResetPwdPage.vaild_old'),
  121. trigger: "blur",
  122. },
  123. ],
  124. NewPwd: [
  125. {
  126. validator:(rule,value,callback)=>{
  127. if(!checkPassWord(value)){
  128. callback(new Error(/* '密码要求8位及以上,包含数字、大写字母、小写字母、特殊字符中的三个类型' */this.$t('ResetPwdPage.vaild_rule')))
  129. }else{
  130. callback()
  131. }
  132. }
  133. },
  134. {
  135. required: true,
  136. message: /* "请输入确认密码" */this.$t('ResetPwdPage.vaild_new'),
  137. trigger: "blur",
  138. },
  139. ],
  140. twoNewPwd: [
  141. {
  142. required: true,
  143. message: /* "请输入确认密码" */this.$t('ResetPwdPage.vaild_new'),
  144. trigger: "blur",
  145. },
  146. ],
  147. },
  148. };
  149. },
  150. mounted() {},
  151. methods: {
  152. changePass(value) {
  153. this.visible = !(value === "show");
  154. },
  155. changetwoPass(value) {
  156. this.twovisible = !(value === "show");
  157. },
  158. addSubmit() {
  159. this.$refs.addForm.validate((valid) => {
  160. if (valid) {
  161. let that = this;
  162. if (that.addForm.NewPwd != that.addForm.twoNewPwd) {
  163. that.$message.warning(/* "新密码两次输入不一致,请核对!" */this.$t('ResetPwdPage.vaild_same'));
  164. return false;
  165. }
  166. modifyPwd({
  167. OldPwd: md5.hex_md5(that.addForm.OldPwd),
  168. NewPwd: md5.hex_md5(that.addForm.NewPwd),
  169. }).then((res) => {
  170. if (res.Ret == 200) {
  171. that.$message.success(/* "修改密码成功,请重新登录!" */ this.$t('ResetPwdPage.edit_pwd_msg'));
  172. setTimeout(function () {
  173. localStorage.setItem("auth", "");
  174. localStorage.setItem("userName", "");
  175. localStorage.setItem("Role", "");
  176. localStorage.setItem("RoleType", "");
  177. localStorage.setItem("AdminId", "");
  178. localStorage.setItem("AdminName", "");
  179. localStorage.setItem("RoleIdentity", "");
  180. localStorage.setItem("ManageType", "");
  181. localStorage.setItem("loginTime", "");
  182. that.$router.push({ path: "/login" });
  183. }, 1000);
  184. }
  185. });
  186. }
  187. });
  188. },
  189. historyBack() {
  190. //返回上一页
  191. history.back();
  192. },
  193. },
  194. };
  195. </script>
  196. <style scoped lang="scss">
  197. .box-card{
  198. .el-form-item{
  199. margin-bottom: 40px;
  200. }
  201. }
  202. </style>