detail.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <el-dialog
  3. title="重置密码"
  4. :visible.sync="dialogVisible"
  5. width="33%"
  6. :before-close="handleClose"
  7. >
  8. <el-form :model="number" ref="number" :rules="rules" label-width="100px">
  9. <el-form-item label prop="password">
  10. <template slot="label" class="status"><span>密&#8195;&emsp;码</span>:</template>
  11. <el-input
  12. placeholder="请输入"
  13. v-model.trim="number.password"
  14. minlength="6"
  15. maxlength="18"
  16. ></el-input>
  17. </el-form-item>
  18. </el-form>
  19. <span slot="footer" class="dialog-footer">
  20. <el-button size="small" @click="dialogVisible = false">取 消</el-button>
  21. <el-button
  22. size="small"
  23. style="margin-left: 60px"
  24. type="primary"
  25. @click="submit('number')"
  26. >确 定</el-button
  27. >
  28. </span>
  29. </el-dialog>
  30. </template>
  31. <script>
  32. import * as api from '@/api/api'
  33. export default {
  34. data() {
  35. const validatePass = (rule, value, callback) => {
  36. if (value.length < 6 || value.length > 18) {
  37. callback(new Error('密码不能小于6位,大于18位'))
  38. } else {
  39. callback()
  40. }
  41. }
  42. return {
  43. dialogVisible: false,
  44. number: {
  45. password: ''
  46. },
  47. id: '',
  48. rules: {
  49. password: [{ required: true, trigger: 'blur', validator: validatePass }]
  50. }
  51. }
  52. },
  53. methods: {
  54. handleClose() {
  55. this.number.password = ''
  56. this.dialogVisible = false
  57. this.$parent.search()
  58. },
  59. openClose(val) {
  60. this.dialogVisible = true
  61. this.id = val.id
  62. },
  63. /**
  64. * @method 确定提交
  65. * **/
  66. submit(formName) {
  67. this.$refs[formName].validate(valid => {
  68. if (valid) {
  69. let code = {
  70. id: this.id,
  71. password: this.number.password
  72. }
  73. api.PUT('/user/resetPassword', code).then(res => {
  74. if (res.code == 0) {
  75. this.handleClose()
  76. this.$message.success(res.data)
  77. }
  78. })
  79. }
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="less" scoped>
  86. // .status {
  87. // padding: 0 12px 0 0;
  88. // }
  89. // .status::before {
  90. // content: '*';
  91. // color: #f56c6c;
  92. // margin-right: 4px;
  93. // }
  94. </style>