<template>
  <el-dialog
    :visible.sync="visible"
    title="认证历史记录"
    :append-to-body="true"
    :modal-append-to-body="false"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
  >
    <el-table :data="dataList" border style="width: 100%;">
      <el-table-column
        prop="realName"
        label="姓名"
        header-align="center"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="mobile"
        label="手机号"
        header-align="center"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="address"
        label="居住地址"
        header-align="center"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="authenticatedFlag"
        label="结果"
        header-align="center"
        align="center"
        :formatter="formatterAuthenticatedFlag"
      ></el-table-column>
      <el-table-column
        prop="remark"
        label="备注"
        header-align="center"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="createdTime"
        label="时间"
        header-align="center"
        align="center"
      ></el-table-column>
    </el-table>
    <template slot="footer">
      <el-button @click="visible = false" type="primary">{{
        $t("confirm")
      }}</el-button>
    </template>
  </el-dialog>
</template>

<script>
export default {
  data () {
    return {
      visible: false,
      dataForm: {
        userId: ''
      },
      dataList: []
    }
  },
  methods: {
    init () {
      this.visible = true
      this.$nextTick(() => {
        if (this.dataForm.userId) {
          this.getDataList()
        }
      })
    },
    // 获取数据列表
    getDataList () {
      this.$http
        .get(
          `/app-user/userauthenticatehistory/listUserAuthenticateHistory/${this.dataForm.userId}`
        )
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          }
          this.dataList = res.data
        })
        .catch(() => {})
    },
    // 审核结果转换
    formatterAuthenticatedFlag (row, column) {
      let authenticatedFlag = row.authenticatedFlag
      if (authenticatedFlag === 1) {
        return '通过'
      } else {
        return '未通过'
      }
    }
  }
}
</script>
