1c2b544db69776b6f4180d5f418373a7ca0c8e13.svn-base 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div>
  3. <a-form-model ref="form" :model="model" :rules="validatorRules" class="password-retrieval-form">
  4. <a-form-model-item label="账号名" v-bind="layout">
  5. <a-input type="text" :value="accountName" disabled/>
  6. </a-form-model-item>
  7. <a-form-model-item prop="password" label="新密码" v-bind="layout" class="stepFormText">
  8. <a-input v-model="model.password" type="password" autocomplete="false"/>
  9. </a-form-model-item>
  10. <a-form-model-item prop="confirmPassword" label="确认密码" v-bind="layout" class="stepFormText">
  11. <a-input v-model="model.confirmPassword" type="password" autocomplete="false"/>
  12. </a-form-model-item>
  13. <a-form-model-item :wrapperCol="{span: 19, offset: 5}">
  14. <a-button style="margin-left: 8px" @click="prevStep">上一步</a-button>
  15. <a-button :loading="loading" type="primary" @click="nextStep" style="margin-left:20px">提交</a-button>
  16. </a-form-model-item>
  17. </a-form-model>
  18. </div>
  19. </template>
  20. <script>
  21. import { getAction } from '@/api/manage'
  22. export default {
  23. name: "Step3",
  24. // components: {
  25. // Result
  26. // },
  27. props: ['userList'],
  28. data () {
  29. return {
  30. model:{},
  31. layout: {
  32. labelCol: { span: 5 },
  33. wrapperCol: { span: 19 },
  34. },
  35. loading: false,
  36. accountName: this.userList.username,
  37. validatorRules: {
  38. password: [{
  39. required: true, pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,.\/]).{8,}$/, message: '密码由8位数字、大小写字母和特殊符号组成!!'
  40. }],
  41. confirmPassword: [
  42. { required: true, message: '密码不能为空!'},
  43. { validator: this.handlePasswordCheck}
  44. ]
  45. }
  46. }
  47. },
  48. methods: {
  49. nextStep () {
  50. let that = this
  51. that.loading = true
  52. that.$refs['form'].validate(success => {
  53. if (success === true) {
  54. let params = {
  55. username: that.userList.username,
  56. password: that.model.password,
  57. smscode: that.userList.smscode,
  58. phone: that.userList.phone,
  59. }
  60. getAction("/sys/user/passwordChange", params).then((res) => {
  61. if (res.success) {
  62. let userList = {
  63. username: that.userList.username
  64. }
  65. console.log(userList);
  66. setTimeout(function() {
  67. that.$emit('nextStep', userList)
  68. }, 1500)
  69. } else {
  70. that.passwordFailed(res.message);
  71. that.loading = false
  72. }
  73. })
  74. } else {
  75. that.loading = false
  76. }
  77. })
  78. },
  79. prevStep () {
  80. this.$emit('prevStep', this.userList)
  81. },
  82. handlePasswordCheck (rule, value, callback) {
  83. let password = this.model['password']
  84. if (value && password && value.trim() !== password.trim()) {
  85. callback(new Error('两次密码不一致'))
  86. }
  87. callback()
  88. },
  89. passwordFailed(err){
  90. this.$notification[ 'error' ]({
  91. message: "更改密码失败",
  92. description:err,
  93. duration: 4,
  94. });
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="less" scoped>
  100. .stepFormText {
  101. margin-bottom: 24px;
  102. }
  103. .ant-form-item-label,
  104. .ant-form-item-control {
  105. line-height: 22px;
  106. }
  107. </style>