<template>
  <div class="mark-entrance">
    <div class="part-box part-box-filter part-box-flex">
      <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
        <template v-if="checkPrivilege('condition', 'condition')">
          <secp-select
            v-model="filter"
            defaultSelectExam
            @exam-default="search"
          ></secp-select>
        </template>
        <el-form-item label-width="0px">
          <el-button
            v-if="checkPrivilege('button', 'select')"
            type="primary"
            @click="search"
            >查询</el-button
          >
        </el-form-item>
      </el-form>
      <div class="part-box-action"></div>
    </div>

    <div class="part-box part-box-pad">
      <el-table ref="TableList" :data="dataList">
        <el-table-column
          type="index"
          label="序号"
          width="70"
          :index="indexMethod"
        ></el-table-column>
        <el-table-column prop="courseName" label="课程（代码）" min-width="260">
          <template slot-scope="scope">
            {{ scope.row.courseName }}（{{ scope.row.courseCode }}）
          </template>
        </el-table-column>
        <el-table-column
          prop="openCollege"
          label="开课学院"
          min-width="160"
        ></el-table-column>
        <el-table-column
          prop="paperNumber"
          label="试卷编号"
          width="160"
        ></el-table-column>
        <el-table-column
          prop="groupQuestions"
          label="评阅题目"
          min-width="200"
        ></el-table-column>
        <el-table-column
          prop="markedCount"
          label="已评"
          width="80"
        ></el-table-column>
        <el-table-column
          prop="leftCount"
          label="待评"
          width="80"
        ></el-table-column>
        <el-table-column prop="percent" label="评卷进度" width="100">
          <span slot-scope="scope"> {{ scope.row.percent || 0 }}%</span>
        </el-table-column>
        <el-table-column
          class-name="action-column"
          label="操作"
          width="140"
          fixed="right"
        >
          <template slot-scope="scope">
            <el-button
              v-if="checkPrivilege('link', 'Marking')"
              class="btn-primary"
              type="text"
              @click="toMark(scope.row)"
              >点击评卷</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div class="part-page">
        <el-pagination
          background
          layout="total, sizes, prev, pager, next, jumper"
          :pager-count="5"
          :current-page="current"
          :total="total"
          :page-size="size"
          @current-change="toPage"
          @size-change="pageSizeChange"
        >
        </el-pagination>
      </div>
    </div>
    <div class="tips-info">
      <p>说明：</p>
      <p>1.已评 - 本人在当前评阅题目下已评阅且未进入仲裁的任务数量；</p>
      <p>2.待评 - 当前评阅题目下全部待评及待仲裁的任务数量；</p>
      <p>3.评卷进度 - 当前评阅题目整体评阅进度。</p>
    </div>
  </div>
</template>

<script>
import { markTaskListPage } from "../api";
import markMinxin from "../markMinxin";

export default {
  name: "mark-entrance",
  mixins: [markMinxin],
  data() {
    return {
      filter: {
        semesterId: "",
        examId: "",
        openCollegeId: "",
        courseId: "",
        paperNumber: "",
      },
      current: 1,
      size: this.GLOBAL.pageSize,
      total: 0,
      dataList: [],
      curUserId: this.$ls.get("user", { id: "" }).id,
    };
  },
  methods: {
    async getList() {
      if (!this.checkPrivilege("list", "list")) return;

      const datas = {
        ...this.filter,
        pageNumber: this.current,
        pageSize: this.size,
      };
      const data = await markTaskListPage(datas);
      this.dataList = data.records;
      this.total = data.total;
    },
    toPage(page) {
      this.current = page;
      this.getList();
    },
    search() {
      this.toPage(1);
    },
    toMark(row) {
      this.toMarkMark(row);
    },
  },
};
</script>
