<template>
  <el-card class="box-card" style="width: 800px" size="small">
    <!-- <div slot="header" class="clearfix">
      <span>Security</span>
    </div> -->
    <div>
      <el-button type="danger" @click="handleReset">{{
        $t("system:userlist:button:ResetPassword")
      }}</el-button>
    </div>
  </el-card>
</template>
<script>
import { params } from "@/utils/ruoyi";
import { resetPassword } from "@/api/admin";
export default {
  name: "Account",
  props: {
    userId: { type: String, default: "" },
  },
  methods: {
    handleReset() {
      this.$confirm(
        this.$t("system:userlist:message:ResetPassword").replace(
          "xxx",
          params("userName")
        ),
        {
          type: "warning",
          distinguishCancelAndClose: true,
        }
      ).then(() => {
        resetPassword(this.userId).then((res) => {
          if (res.IsSuccess) {
            this.$message({
              message: this.$t("trials:adRules:message:msg7"),
              type: "success",
            });
            let msg = this.$IsCanConnectInternet ? this.$t("system:userlist:message:ResetPassword3") : this.$t("system:userlist:message:ResetPassword2");
            msg = msg.replace("xxx", params("userName"));
            msg = msg.replace("yyy", params("email"));
            this.$alert(decodeURIComponent(msg));
          }
        });
      });
    },
  },
};
</script>
