<!--考核列表-->
<template>
  <div class="assessList">
    <div class="assessList-page" v-if="pageType == 1">
      <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="90px" class="form-box">
        <el-col :span="1.5">
          <p class="reset-button-one"
             style="font-weight:700;margin-bottom:20px;"
             @click="backPage"><i class="el-icon-arrow-left"></i>返回</p>
        </el-col>
        <!--<el-form-item label="通过状态" prop="scopeType">-->
          <!--<el-select v-model="queryParams.type" placeholder="请选择通过状态" clearable size="small">-->
            <!--<el-option-->
              <!--v-for="item in scopeTypes"-->
              <!--:key="item.type"-->
              <!--:label="item.value"-->
              <!--:value="item.type"-->
            <!--&gt;-->
            <!--</el-option>-->
          <!--</el-select>-->
        <!--</el-form-item>-->
        <!--<el-form-item>-->
          <!--<p class="inquire-button-one" @click="handleQuery">查询</p>-->
          <!--<p class="reset-button-one" @click="resetQuery">重置</p>-->
        <!--</el-form-item>-->
      </el-form>
      <el-table v-loading="loading" border :data="tableList">
        <el-table-column label="考核名称" align="left" prop="assessName" :show-overflow-tooltip="true"/>
        <el-table-column label="考核时间" align="left" prop="assessTime"  width="200"/>
        <el-table-column label="题目数量" align="left" prop="allQu" width="140"/>
        <el-table-column label="错题数" align="left" prop="errors"  width="140"/>
        <el-table-column label="考核结果" align="left" prop="accuracy" width="140">
          <template slot-scope="scope">{{scope.row.accuracy == 100?'通过':'未通过'}}</template>
        </el-table-column>
        <el-table-column label="获得奖励分" align="left" prop="points"  width="140"/>
        <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="120">
          <template slot-scope="scope">
            <div class="button-box">
              <p class="table-min-button"
                 style="margin-right:10px;"
                 @click="goAssessInfo(scope.row)"
              >查看详情</p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        layout="total, prev, pager, next, sizes, jumper"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
    <assess-info v-if="pageType == 2" :paperId="paperId" :cateTitle="cateTitle" :assessName="assessName"></assess-info>
  </div>
</template>

<script>
  import { assessList } from "@/api/exam/el_course";
  import assessInfo from './assessInfo.vue'
  export default {
    name: 'assessList',
    components: {
      assessInfo
    },
    props:{
      chapterId:{},
      cateTitle:{},
    },
    data() {
      return {
        pageType:1,
        loading:false,
        total:0,
        tableList:[],
        //检索数据
        queryParams:{
          pageNum: 1,
          pageSize: 10,
          type:null
        },
        // 选项数据
        scopeTypes: [
          {
            type: 1,
            value: "通过",
          },
          {
            type: 2,
            value: "未通过",
          }
        ],
        //考核id
        paperId:"",
        //考核名称
        assessName:"",
      }
    },
    created(){

    },
    mounted(){
      this.getList();
    },
    methods:{
      offMinPage(){
        this.pageType = 1;
      },
      //去详情
      goAssessInfo(row){
        this.paperId = row.paperId;
        this.assessName = row.assessName;
        this.pageType = 2;
      },
      //返回
      backPage(){
        this.$parent.offMinPage();
      },
      getList(){
        this.loading = true;
        assessList(this.chapterId).then( response => {
        // assessList(181).then( response => {
          this.tableList =  response.rows;
          this.total =  response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.dateRange=[];
        this.handleQuery();
      },
      /** 查询学习资源列表 */
    }
  }
</script>

<style scoped lang="scss">
  .assessList{
    flex:1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    .assessList-page{
      flex:1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      padding:20px;
    }

  }
</style>
