<template>
  <div class="resume-info">
    <el-table :data="list" style="margin-top:10px;" size="small">
      <template slot="empty">
        <span></span>
      </template>
      <el-table-column type="index" label="No." width="50" />

      <el-table-column
        prop="FileName"
        label="File Name"
        min-width="60"
        show-overflow-tooltip
      />
      <el-table-column
        prop="Isoffical"
        label="Offical"
        min-width="50"
        :formatter="officalFormatter"
        show-overflow-tooltip
      />
      <el-table-column
        prop="Language"
        label="Language"
        min-width="50"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.Language===1?'CH':scope.row.Language===2?'EN':'' }}
        </template>
      </el-table-column>
      <el-table-column
        prop="CreateTime"
        label="Upload Time"
        min-width="60"
        show-overflow-tooltip
      />
      <el-table-column label="Action" min-width="150">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="preview(scope.$index, scope.row)">Download</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  props: {
    resumeList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      list: []
    }
  },
  created() {
    this.list = this.filterResume(this.resumeList)
  },
  methods: {
    filterResume(arr) {
      var list = []
      if (arr.length > 0) {
        arr.forEach(item => {
          if (item.Type === 'Resume') {
            list.push(item)
          }
        })
      }
      return list
    },
    preview(index, row) {
      const filePath = row.FullPath
      if (filePath) {
        window.open(filePath, '_blank')
      }
    },
    timeFormatter(row) {
      return new Date(row.CreateTime).format('yyyy-MM-dd hh:mm:ss')
    },
    officalFormatter(row, column) {
      if (row.IsOfficial) {
        return 'Yes'
      } else {
        return 'No'
      }
    }
  }
}
</script>

<style lang="scss">
.resume-info{
  padding:5px 15px;
  font-size:13px;
}
</style>
