1
PC-20250623MANY\Administrator
2025-08-16 832a37044afeea095d43535bcec6d2e71c4d2409
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<template>
  <el-form ref="lpform" :model="form" label-width="auto" :rules="rules">
    <el-form-item :label="$t('hj150')" prop="oldPassword">
      <el-input
        v-model="form.oldPassword"
        type="password"
        show-password
      ></el-input>
    </el-form-item>
 
    <el-form-item :label="$t('hj151')" prop="newPassword">
      <el-input
        v-model="form.newPassword"
        type="password"
        show-password
      ></el-input>
    </el-form-item>
 
    <el-form-item :label="$t('hj152')" prop="cirNewPassword">
      <el-input
        v-model="form.cirNewPassword"
        type="password"
        show-password
      ></el-input>
    </el-form-item>
 
    <el-form-item>
      <el-button type="primary" @click="onSubmit" class="submit">
        {{ $t("hj153") }}
      </el-button>
    </el-form-item>
  </el-form>
</template>
 
<script>
import * as api from "@/axios/api";
export default {
  data() {
    let validatePass = (rule, value, callback) => {
      if (value === "") {
        callback(new Error(this.$t("请输入")));
      } else if (value !== this.form.newPassword) {
        callback(new Error(this.$t("两次输入密码不一致")));
      } else {
        callback();
      }
    };
    return {
      form: {
        oldPassword: "",
        newPassword: "",
        cirNewPassword: "",
      },
      rules: {
        oldPassword: [{ required: true, message: this.$t("请输入") }],
        newPassword: [{ required: true, message: this.$t("请输入") }],
        cirNewPassword: [
          { required: true, validator: validatePass, trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    onSubmit() {
      this.$refs["lpform"].validate(async (valid) => {
        if (valid) {
          let opts = {
            oldPwd: this.form.oldPassword,
            newPwd: this.form.newPassword,
          };
          let data = await api.changePassword(opts);
          if (data.status == 0) {
            this.$message.success(this.$t("密码修改成功"));
          }
        } else {
          console.log("changePassword err");
          return false;
        }
      });
    },
  },
};
</script>
 
<style lang="scss" scoped>
::v-deep .el-radio__input.is-checked .el-radio__inner {
  border-color: #c4d600;
  background: #c4d600;
}
 
::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: #c4d600;
}
 
.submit {
  background-color: #c4d600 !important;
  border-color: #c4d600 !important;
}
 
.ts {
  color: #dfb758;
}
</style>