<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(() => {
          let data = {
            BaseUrl: `${location.protocol}//${location.host}/login`,
            IdentityUserId: this.userId
          }
          resetPassword(data).then(res => {
            if (res.IsSuccess) {
              let msg = this.$t('system:userlist:message:ResetPassword2')
              msg = msg.replace('xxx', params('userName'))
              msg = msg.replace('yyy', params('email'))
              this.$alert(decodeURIComponent(msg))
            }
          })
        })
    }
  }
}
</script>
