Password.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <el-dialog title="修改密码" :visible.sync="show">
  3. <el-form :model="userpsd" :rules="rules" ref="userPsdForm">
  4. <el-form-item label="原密码" label-width="100px" prop="password1">
  5. <el-input type="password" v-model="userpsd.password1" :show-password="true" ></el-input>
  6. </el-form-item>
  7. <el-form-item label="新密码" label-width="100px" prop="password2">
  8. <el-input type="password" v-model="userpsd.password2" :show-password="true" ></el-input>
  9. </el-form-item>
  10. <el-form-item label="重复密码" label-width="100px" prop="password3">
  11. <el-input type="password" v-model="userpsd.password3" :show-password="true" ></el-input>
  12. </el-form-item>
  13. </el-form>
  14. <div slot="footer" class="dialog-footer">
  15. <el-button type="primary" @click="savepsd()">确 定</el-button>
  16. <el-button @click="show = false">取 消</el-button>
  17. </div>
  18. </el-dialog>
  19. </template>
  20. <script>
  21. import { ajax } from "@/common/biConfig";
  22. import $ from "jquery";
  23. export default {
  24. name: "password",
  25. data() {
  26. return {
  27. show: false,
  28. userpsd:{
  29. password1:null,
  30. password2:null,
  31. password3:null
  32. },
  33. rules:{
  34. password1:[
  35. { required: true, message: '必填', trigger: 'blur' },
  36. { min: 6, max: 18, message: '密码长度6到18位', trigger: 'blur' }
  37. ],
  38. password2:[
  39. { required: true, message: '必填', trigger: 'blur' },
  40. { min: 6, max: 18, message: '密码长度6到18位', trigger: 'blur' }
  41. ],
  42. password3:[
  43. { required: true, message: '必填', trigger: 'blur' },
  44. { min: 6, max: 18, message: '密码长度6到18位', trigger: 'blur' }
  45. ]
  46. }
  47. };
  48. },
  49. mounted: function () {
  50. },
  51. methods: {
  52. savepsd:function(){
  53. let ts = this;
  54. this.$refs['userPsdForm'].validate((valid) => {
  55. if (valid) {
  56. if(ts.userpsd.password2 != ts.userpsd.password3){
  57. ts.$notify.error({
  58. title: '两次密码不一致',
  59. offset: 50
  60. });
  61. return false;
  62. }
  63. ajax({
  64. type:"POST",
  65. data: ts.userpsd,
  66. postJSON:false,
  67. url:"frame/chgPsd.action",
  68. success:function(resp){
  69. ts.$notify.success({
  70. title: '密码修改成功',
  71. offset: 50
  72. });
  73. ts.show = false;
  74. }
  75. }, ts);
  76. } else {
  77. return false;
  78. }
  79. });
  80. }
  81. }
  82. };
  83. </script>
  84. <style scoped lang="less">
  85. @import "../style/mixin";
  86. </style>