jinlin
2024-07-26 1b765e3dfdf8ab0d38e587a0a8beaee47a60e32c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<template>
  <zt-dialog ref="dialog" title="修改密码" @confirm="formSubmit" column="1" append-to-body>
    <el-form :model="dataForm" ref="dataForm" :rules="dataRule"  label-width="120px">
      <zt-form-item prop="userName" :label="$t('user.username')" rules="required">
        <el-input v-model="dataForm.userName" :placeholder="$t('user.username')"></el-input>
      </zt-form-item>
      <zt-form-item prop="oldPassword" label="旧密码" rules="required">
        <el-input v-model="dataForm.oldPassword" type="password" :placeholder="旧密码"></el-input>
      </zt-form-item>
      <zt-form-item prop="password" label="新密码" rules="required">
        <el-input v-model="dataForm.password" type="password" :placeholder="新密码"></el-input>
      </zt-form-item>
      <zt-form-item prop="confirmPassword" label="确认密码" rules="required">
        <el-input v-model="dataForm.confirmPassword" type="password" :placeholder="确认密码"></el-input>
      </zt-form-item>
    </el-form>
  </zt-dialog>
</template>
 
<script>
 
  export default {
    data() {
      return {
        dataForm: {
          userName: '',
          oldPassword: '',
          password: '',
          confirmPassword: '',
        }
      }
    },
 
    methods: {
      init() {
      },
      // 表单提交
      async formSubmit() {
        // this.$refs.dataForm.validate((valid) => {
        //   if (!valid) {
        //     this.$alert('输入错误', '提示', {
        //       confirmButtonText: '确定'
        //     })
        //     return false
        //   }
        // })
        if (this.dataForm.password != this.dataForm.confirmPassword) {
          this.$alert('密码输入不一致', '提示', {
            confirmButtonText: '确定'
          })
          return false
        }
        console.log(this.dataForm, 'this.dataForm')
        let res = await this.$http['put']('/sys/userChangePassword', this.dataForm)
        if (res.success) {
          if (res.data === 'OK') {
            this.$alert('修改密码成功', '提示', {
              confirmButtonText: '确定'
            })
            this.$refs.dialog.close()
            this.$emit('refreshDataList')
          }
          else{
            this.$alert(res.data , '提示', {
              confirmButtonText: '确定'
            })
          }
        }
      }
    }
  }
</script>