<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="200" 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="200">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="go(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="[15, 30, 50, 100, 200, 500, 700, 1000, 1500, 2000]"
        :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 {
  data() {
    return {
      tableData: [
        {
          name: "asd",
          joinNum: 123123,
          passNum: 123,
          goodNum: 12,
          startNum: 111
        }
      ],
      cardData: [
        {
          title: "项目所有考试数",
          num: 9,
          unit: "门考试"
        },
        {
          title: "项目所有考题数",
          num: 120,
          unit: "道题"
        }
      ],
      totalRows: 0, //数据总数
      searchParam: {
        pageNo: 1, //当前是第几页
        pageSize: 20, //页面总数
      }
    };
  },
  created() {
    vm = this
  },
   // 挂载到Dom完成时
  mounted: function() {
    commonUtil.resizeHeight();
  },
  methods: {
    // 搜索列表
    search(flag) {
      if(flag) vm.searchParam.pageNo = 1
      openLoading(vm);
      let params = {};
      vm.GET(url, params).then(res => {
        closeLoading(vm);
        if (res.code == "000000") {
        } else {
          vm.$message.info(res.message);
        }
      });
    },
    // 跳转查看名单页面
    go(row) {
      vm.$router.push('/name-list')
    },
    // 更改数据显示数量
    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;
  }
}
</style>
