<template>
  <div class="app-container">
    <div class="level-title">
      <h1>考试详情</h1>
    </div>
    <el-table
      v-loading="listLoading"
      ref="multipleTable"
      :data="varList"
      :header-cell-style="{
        'font-weight': 'bold',
        'color': '#000'
      }"
      :row-key="getRowKey"
      tooltip-effect="dark"
      border
      fit
      highlight-current-row
    >
      <el-table-column prop="EXAMNAME" label="考试名称">
        <template>
          {{ stageexampaper.EXAMNAME }}
        </template>
      </el-table-column>
      <el-table-column prop="USERNAME" label="参考人" />
      <el-table-column prop="OPERATTIME" label="考试时间" />
      <el-table-column prop="PLAYCOUNT" label="考试类型" >
        <template>
          线上考试
        </template>
      </el-table-column>
      <el-table-column prop="STAGEEXAMSCORE" label="得分">
        <template slot-scope="{row}" >
          <template v-if="row.STAGEEXAMSCORE =='-1' ">未参加</template>
          <template v-else>{{ row.STAGEEXAMSCORE }}</template>
        </template>
      </el-table-column>
      <el-table-column prop="STAGEEXAMSCORE" label="考试结果">
        <template slot-scope="{row}" >
          <template v-if="row.STAGEEXAMSCORE =='-1'">未参加</template>
          <template v-else-if="Number(row.STAGEEXAMSCORE )>= Number(stageexampaper.PASSSCORE) ">通过</template>
          <template v-else>未通过</template>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="340">
        <template slot-scope="{row}">
          <el-button v-if="Number(row.STAGEEXAMSCORE )>= 0" type="primary" icon="el-icon-edit" size="mini" @click="kaoshiInfo(row)">考卷详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="ui-height" />
    <div class="ui-foot">
      <el-button type="primary" @click="goBack">返 回</el-button>
    </div>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import { requestFN } from '@/utils/request'
import SelectTree from '@/components/SelectTree'
import waves from '@/directive/waves' // waves directive
export default {
  components: { Pagination, SelectTree },
  directives: { waves },
  data() {
    return {
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10
      },
      varList: [],
      stageexampaper: {}
    }
  },
  async created() {
    this.getInfo()
  },
  methods: {
    getRowKey(row) {
      return row.STAGESTUDENTRELATION_ID
    },
    getInfo() {
      requestFN(
        '/stagestudentrelation/list?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
        {
          STUDYTASK_ID: this.$parent.STUDYTASK_ID,
          STAGEEXAMPAPER_ID: this.$parent.STAGEEXAMPAPER_ID
        }
      ).then((data) => {
        this.listLoading = false
        this.varList = data.varList
      }).catch((e) => {
        this.listLoading = false
      })
      // 获取开始信息
      requestFN(
        '/stageexampaper/getPageDataByStudyTaskId',
        {
          STUDYTASK_ID: this.$parent.STUDYTASK_ID,
          STAGEEXAMPAPER_ID: this.$parent.STAGEEXAMPAPER_ID
        }
      ).then((data) => {
        this.listLoading = false
        this.stageexampaper = data.varList[0]
      }).catch((e) => {
        this.listLoading = false
      })
    },
    kaoshiInfo(row) {
      this.$parent.STUDYTASK_USERID = row.USER_ID
      this.$parent.activeName = 'KaoshiInfo'
    },
    goBack() {
      this.$parent.activeName = 'Course'
    }

  }
}

</script>
