<template>
  <div class="examination-analysis">
    <div class="box">
      <el-card class="box-card" v-for="(item , index) in cardData" :key="index">
        <div slot="header" class="title">
          <span class="weight">{{ item.title }}</span>
        </div>
        <div class="box-content">
          <span class="weight">{{ item.num }}</span>
          {{ item.unit }}
        </div>
      </el-card>
    </div>
    <div class="table">
      <el-table :data="tableData" style="width: 100%" border>
        <el-table-column prop="name" label="考试名" min-width="150" align="center"></el-table-column>
        <el-table-column prop="joinNum" label="参与考试人数" min-width="100" align="center"></el-table-column>
        <el-table-column prop="passNum" label="通过考试人数" min-width="80" align="center"></el-table-column>
        <el-table-column prop="goodNum" label="成绩优秀人数" min-width="80" align="center"></el-table-column>
        <el-table-column prop="startNum" label="成绩合格人数" min-width="80" align="center"></el-table-column>
        <el-table-column label="操作" fixed="right" align="center" min-width="100">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="goPage(scope.row)">查看名单</el-button>
          </template>
        </el-table-column>
        <div slot="empty">
          <div class="table-empty">
            <img src="../../assets/image/no-content1.png">
            <p>没有查询到相关结果</p>
          </div>
        </div>
      </el-table>
    </div>
    <!-- 分页 -->
    <div class="pagination">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="searchParam.pageNo"
        :page-sizes="[10, 30, 50]"
        :page-size="searchParam.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalRows"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { log } from 'util';
import { openLoading, closeLoading } from "../../utils/utils";
import * as commonUtil from "../../utils/utils";
let vm
export default {
  props: {
    formInline: {
      type: Object
    },
    activeName: {
      type: String
    },
    dialogData: {
      type: Object
    },
  },
  data() {
    return {
      tableData: [],
      cardData: [
        {
          title: "项目所有考试数",
          num: 9,
          unit: "门考试"
        },
        {
          title: "项目所有考题数",
          num: 120,
          unit: "道题"
        }
      ],
      totalRows: 0, //数据总数
      searchParam: {
        pageNo: 1, //当前是第几页
        pageSize: 20, //页面总数
      }
    };
  },
  created() {
    vm = this;
    vm.search();
  },
   // 挂载到Dom完成时
  mounted: function() {
    commonUtil.resizeHeight();
  },
  methods: {
    // 搜索列表
    search() {
      vm.tableData= [
        {
          id: 22,
          name: "asd",
          joinNum: 123123,
          passNum: 123,
          goodNum: 12,
          startNum: 111
        }
      ];
    },
    // 跳转查看名单页面
    goPage(data) {
      vm.$router.push("course-training?tableType=2&id="+data.id+"&region="+this.dialogData.region+"&organization="+this.dialogData.organization);
    },
    // 更改数据显示数量
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      vm.searchParam.pageSize = val
      vm.search()
    },
    // 换页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      vm.searchParam.pageNo = value
      vm.search()
    }
  }
};
</script>

<style lang='scss' rel='stylesheet/scss'>
.examination-analysis {
  background: #fff;
  .box {
    overflow: hidden;
  }
  .table {
    margin-top: 30px;
  }
  .box-card {
    width: 49%;
    margin-right: 1%;
  }
}
</style>
