<template>
  <div class="m-right-block fr mh576" style="position: relative;">
    <div class="right-block-bd mt20">

      <div  class="ng-scope">
        <el-table v-loading="listLoading" :data="list" border fit highlight-current-row>
          <el-table-column label="序号" align="center" prop="id" width="70">
          </el-table-column>

          <el-table-column label="考期" align="center" prop="planName" width="120">
          </el-table-column>

          <el-table-column label="测试计划时间" align="center" prop="examAt" min-width="200">
          </el-table-column>


          <el-table-column label="岗位名称" align="center" prop="courseName" width="120">
          </el-table-column>

          <el-table-column label="考试成绩" align="center" prop="score" width="80">
          </el-table-column>

          <el-table-column label="是否通过" align="center" prop="isPass" width="80">
            <template slot-scope="{row}">
              <span>{{row.score>=60?"通过":"未通过"}}</span>
            </template>
          </el-table-column>

          <el-table-column label="证书编号" align="center" prop="rzCode" min-width="160">

          </el-table-column>
        </el-table>

        <el-pagination
            @current-change="handleCurrentChange"
            :current-page="page"
           :page-size="size"
           layout="total, prev,pager, next"
           :total="list.length">
        </el-pagination>

      </div>
    </div>
  </div>
</template>

<script>
  import {httpServer} from "@/components/httpServer/httpServer.js";
  export default {
    name: "Index",
    data() {
      return {
        page:1,
        size:10,
        total: 20,
        list: [],
        listLoading: false
      };
    },
    beforeMount() {
      this.getData()
    },
    methods: {
      getData() {
        this.listLoading = true
        httpServer('User.GetExamScoreList', {}).then( res=>{
            if( res.code == 200){
              this.list = res.data||[]
            }
            this.listLoading = false
        })
      },
      printCert( row  ){
        let mytime = Date.now()
        let printDate = +new Date( row.certificateAt)
        console.log(mytime, printDate )
        if( printDate > mytime){
          this.$message.errorMsg("考试前三天来打印")
          return;
        }

        if( row.getXs < row.totalXs){
          this.$message.errorMsg("还未培训完成")
          return;
        }
        window.open(row.certificateUrl, "_brank" )
      },

      handleCurrentChange: function(page) {
        this.page = page
        this.getData()
      }
    }
  }
</script>

<style>
</style>
