RuoYi
2025-04-27 7b6fdb3a893275ff82ba5c868287a1e12dcd75f1
ruoyi-ui/src/views/system/user/profile/resetPwd.vue
@@ -17,17 +17,17 @@
</template>
<script>
import { updateUserPwd } from "@/api/system/user";
import { updateUserPwd } from "@/api/system/user"
export default {
  data() {
    const equalToPassword = (rule, value, callback) => {
      if (this.user.newPassword !== value) {
        callback(new Error("两次输入的密码不一致"));
        callback(new Error("两次输入的密码不一致"))
      } else {
        callback();
        callback()
      }
    };
    }
    return {
      user: {
        oldPassword: undefined,
@@ -41,28 +41,29 @@
        ],
        newPassword: [
          { required: true, message: "新密码不能为空", trigger: "blur" },
          { min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" }
          { min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" },
          { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }
        ],
        confirmPassword: [
          { required: true, message: "确认密码不能为空", trigger: "blur" },
          { required: true, validator: equalToPassword, trigger: "blur" }
        ]
      }
    };
    }
  },
  methods: {
    submit() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
            this.$modal.msgSuccess("修改成功");
          });
            this.$modal.msgSuccess("修改成功")
          })
        }
      });
      })
    },
    close() {
      this.$tab.closePage();
      this.$tab.closePage()
    }
  }
};
}
</script>