<template>
  <section class="content">
    <div class="breadcrumb">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item><a href="/">阅卷管理</a></el-breadcrumb-item>
        <el-breadcrumb-item>上传试卷</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!-- 上传试卷 -->
    <el-row :gutter="20">
        <el-col :span="24">
          <!-- <el-row>
            <el-col :span="6">参考人数:{{studentsList.length}}</el-col>
            <el-col :span="6">已上传:{{studentsList.length}}</el-col>
            <el-col :span="6">识别异常:</el-col>
          </el-row> -->
          <el-form :inline="true">
            <el-form-item label="姓名">
              <el-input size="mini" placeholder="请输入姓名/考号" v-model="queryName" clearable></el-input>
            </el-form-item>
            <!--<el-form-item label="识别异常">
              <el-select v-model="queryMarkStatus" size="mini" clearable>
                <el-option v-for="item in $const.recErrorList" :label="item.label" :value="item.value"></el-option>

              </el-select>
            </el-form-item>-->
            <el-form-item>
              <el-button type="primary" size="mini" @click="searchMarkData">搜索</el-button>
              <el-button size="mini" @click="reSetMarkData">重置</el-button>
              <el-button @click="downloadObjectiveResult(curTaskId)" type="warning" size="mini" icon="el-icon-download">
                导出</el-button>
              <el-button @click="reTryMark" size="mini" type="success" icon="el-icon-printer">重新识别</el-button>
            </el-form-item>
            <el-form-item>
              <el-button size="mini" type="warning" icon="el-icon-printer" @click='starScanPaper(curTaskId,"http://test.scxjc.club/api/admin/papers/uploadpaper")'>试卷扫描</el-button>

            </el-form-item>
            <el-form-item>
              <el-upload class="upload-demo" action="http://test.scxjc.club/api/admin/papers/uploadpaper"
                :on-success="handleUploadSuccess" :data="{taskid:taskid}" :on-change="handleChange" list-type="picture"
                multiple>
                <el-button size="mini" type="primary" @click="openTaskImgList">点击上传</el-button>
              </el-upload>
            </el-form-item>
          </el-form>
          <el-row>
            <el-col :span="24">
              <el-tabs v-model="activeName" @tab-click="handleTabClick">
                <el-tab-pane :label="'正确('+recSucTotal+')'" name="1"></el-tab-pane>
                <el-tab-pane :label="'定位异常('+recKhErrTotal+')'" name="-5"></el-tab-pane>
                <el-tab-pane :label="'考号异常('+recKhErrTotal+')'" name="-1"></el-tab-pane>
                <el-tab-pane :label="'考号重复('+recKhErrTotal+')'" name="-3"></el-tab-pane>
                <el-tab-pane :label="'缺考异常('+recKhErrTotal+')'" name="-4"></el-tab-pane>
                <el-tab-pane :label="'客观题异常('+recObjErrTotal+')'" name="-2"></el-tab-pane>
                <el-tab-pane :label="'待上传('+recWaitingErrTotal+')'" name="0"></el-tab-pane>
              </el-tabs>
            </el-col>
          </el-row>
          <el-table v-loading="loading" :data="studentsList" style="width: 100%; margin-top: 10px"
            @selection-change="handleSelectionChange" height="60vh">
            <el-table-column type="selection" width="45" v-if="activeName==100"></el-table-column>
            <el-table-column align="center" prop="student_name" label="姓名" width="80" />
            <el-table-column align="center" prop="student_no" label="考号" width="150">
              <template slot-scope="scope">
                <el-button type="text" @click="showStudentImgs(scope.row)" size="mini">{{scope.row.student_no}}
                </el-button>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="objective_ans_str" label="客观题识别结果"/>
            <el-table-column align="center" prop="objective_score" label="客观题得分" width="100" />
            <el-table-column align="center" prop="mark_status_name" label="识别状态" width="80">
              <template slot-scope="scope">
                <span v-if="scope.row.mark_status<=0" style="color:#f78989;">{{scope.row.mark_status_name}}</span>
                <span v-if="scope.row.mark_status==1" style="color:#85ce61;">正常</span>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="ctime" label="时间" width="140px">
              <template slot-scope="scope">
                <span style="font-size:12px;">{{scope.row.ctime}}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="date" label="操作" fixed="right" width="160px">
              <template slot-scope="scope">
                <!--<el-button v-if="scope.row.mark_status!=0" @click="showCurRecImg(scope.row)" size="mini" type="text">查看
                </el-button>
                <el-button v-if="scope.row.mark_status!=0" @click="showCurRecKhImg(scope.row)" size="mini" type="text">
                  考号</el-button>-->
                <el-button @click="delStudents(scope.row.student_id,scope.$index,'delRec')" size="mini" type="text">删除识别结果
                </el-button>
                <el-button @click="delStudents(scope.row.student_id,scope.$index,'delStudent')" size="mini" type="text">删除学生
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <Page ref="pageButton" :current="recPage" :page_size="recPageSize" :total="recTotal"
            @pageChange="goRecPage" />

        </el-col>
      </el-row>
      <!-- 试卷上传预览 -->
      <el-dialog title="试卷预览" :visible.sync="imgListVisible" width="750px" @close="closeTaskImgDialog" append-to-body>
        <div style="text-align:right;">
          <font>成功上传:{{taskImgTotal}}</font>&nbsp;&nbsp;&nbsp;&nbsp;
          <el-button v-loading="loading" type="primary" size="mini" @click="startRecPaper">开始识别</el-button>
        </div>
        <div style="width:156px;display: inline-block;margin:10px;border:1px solid #ccc;"
          v-for="(item,index) in fileList">
          <el-image width="100px" alt="" :src="item.url" :preview-src-list="[item.url]"></el-image>
        </div>
        <Page ref="pageImgButton" :current="imgForm.page" :page_size="imgForm.page_size" :total="taskImgTotal" @pageChange="goTaskImg" />
      </el-dialog>

    <!-- 预览识别结果 -->
    <el-dialog title="异常处理" :visible.sync="showAnsVisible" width="90%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px" :inline="true">
        <el-row :gutter="20">
          <!--试卷预览-->
          <el-col :span="16" style="border:1px solid #ccc;">
            <img :src="curStudentRecImg" id="myCanvasImg" style="display:none;" />
            <canvas id="myCanvas" ref="myCanvas" :width="srcImgWidth*canvasImgScale" :height="srcImgHeight*canvasImgScale"></canvas>
          </el-col>
          <!--异常处理-->
          <el-col :span="8">
            <!--考号异常-->
            <el-row v-if="activeName==-1">
              <el-col :span="20">
                <el-form-item v-if="activeName==-1" label-width="80">
                  <el-input v-model="curStudentNo" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item v-if="activeName==-1">
                  <el-button type="primary" @click="searchStudents" size="mini">搜索</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <!--客观题异常-->
            <el-row v-if="activeName==-2">
              <div class="kgtContainer">
                <div class="topContainer">
                  <div class="topItem">待处理:2</div>
                  <div class="topItem">
                    <el-button type="primary" size="mini" @click="saveModifQueAns">保存</el-button>
                  </div>
                </div>
                <div class="kgtItem" v-for="oitem in objectiveRecResult">
                  <span class="tag-group__title">{{oitem.qno}}、</span>
                  <el-tag :effect="oitem.fillNum.indexOf(index)!=-1?'dark':'plain'" v-for="(item,index) in oitem.points.length" :key="item.label" type="success"
                    @click="setStdAns(oitem,index)"
                    size="small">
                    {{ $const.ansOptionList[index]["label"] }}
                  </el-tag>&nbsp;&nbsp;&nbsp;&nbsp;
                  <el-tag effect="dark" size="small" :type="oitem.fillNum.length<1?'danger':'plain'">未涂</el-tag>
                  <el-tag effect="dark" size="small" :type="oitem.fillNum.length>1 && oitem.qtype==1?'danger':'plain'">多涂</el-tag>
                </div>
              </div>
            </el-row>
            <el-row style="border:1px solid #ccc;padding:10px;" v-for="(item,index) in searchStudentsData">
              <el-col :span="20">
                <p>{{item.name}}</p>
                <p>{{item.student_no}}</p>
                <p>{{item.school_name}}{{item.grade_name}}{{item.class_name}}</p>
              </el-col>
              <el-col :span="4">
                  <el-button type="primary" @click="saveModifyStudentNo" size="mini">确定</el-button>
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showAnsVisible = false">关 闭</el-button>
      </div>
    </el-dialog>
    <!-- 重新识别 -->
    <el-dialog title="重新识别" :visible.sync="remarkDialogVisible" width="60%" @close="closeRemarkDialog">
      <el-form :inline="true">
        <el-form-item label="考号噪声参数">
          <el-input-number v-model="form.khVoiceNum" :min="1" :max="5"></el-input-number>
        </el-form-item>
        <el-form-item label="考号填涂比例阈值">
          <el-input-number v-model="form.khFillRate" :min="1" :max="5"></el-input-number>
        </el-form-item>
        <el-form-item label="题目噪声参数">
          <el-input-number v-model="form.tmVoiceNum" :min="1" :max="5"></el-input-number>
        </el-form-item>
        <el-form-item label="题目填涂比例阈值">
          <el-input-number v-model="form.tmFillRate" :min="1" :max="5"></el-input-number>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="doReTryMark">确 定</el-button>
      </div>
    </el-dialog>
    <!--阅卷设置-->
    <MarkTaskSetDialog :remarkSetVisible="remarkSetVisible" :paperId="curPaperId" :taskId="curTaskId" @close="closeMarkTaskSet" />
    <!-- 图片预览 -->
    <div id="imgReviewList" style="position:absolute;right:20px;top:0px;width:20%;z-index:10000;height:880px;overflow:scroll;"></div>
  </section>
</template>
<script>
  import Page from "../../components/Page";
  import MarkTaskSetDialog from "./components/MarkTaskSetDialog";
  import OpenDwSource from "../../utils/xscan.js"
  import Cropper from 'cropperjs'
  export default {
    components: {
      Page,
      MarkTaskSetDialog
    },
    data() {
      return {
        loading: false,
        drawerVisible:true,
        queryParams: {
          page: 1,
          page_size: 20
        },
        form: {
          khVoiceNum: 5,
          khFillRate: 3.0,
          tmVoiceNum: 3,
          tmFillRate: 1.8,
          class_list: ["高三一班", "高三二班"],
          checkList: []
        },
        imgForm:{
          page:1,
          page_size:20
        },
        form1: {},
        form2: {},
        list: [{}, {}],
        total: 0,
        imgTotal:0,
        title: "新增用户",
        open: false,
        doctorList: [],
        rules: {},
        uploadDialogVisible: false,
        remarkDialogVisible: false,
        fileList: [],
        papersList: [],
        taskid: null,
        timer: null,
        timer2: null,
        studentsList: [],
        showAnsVisible: false,
        curStudentRecImg: "",
        activeName: "1",
        curTaskId: null,
        curPaperId:null,
        recPage: 1,
        recPageSize: 20,
        recTotal: 0,
        recParams: {},
        recSucTotal: 0,
        recKhErrTotal: 0,
        recObjErrTotal: 0,
        recWaitingErrTotal:0,
        queryName: "",
        queryMarkStatus: null,
        selectException: [],
        checkClassList: [],
        schoolList: [],
        gradeList: [],
        classList: [],
        imgListVisible: false,
        taskImgTotal: 0,
        remarkSetVisible: false,
        activeSetName: "first",
        addQueForm:{},
        objectiveQueList:[],
        subjectiveQueList:[],
        subjectiveMarkTeacherList:[],
        checkList:[],
        srcImgWidth:null,
        srcImgHeight:null,
        canvasImgScale:1,
        ctx:null,
        curStudentNo:null,
        searchStudentsData:[],
        ansOptionList: [{
              label: "A",
              value: "A",
              flag: 0
            },
            {
              label: "B",
              value: "B",
              flag: 0
            },
            {
              label: "C",
              value: "C",
              flag: 0
            },
            {
              label: "D",
              value: "D",
              flag: 0
            },
            {
              label: "E",
              value: "E",
              flag: 0
            },
            {
              label: "F",
              value: "F",
              flag: 0
            },
            {
              label: "G",
              value: "G",
              flag: 0
            }
          ],
        objectiveRecResult:[]
      };
    },
    methods: {
      jump(url, id) {
        id == 2 ? localStorage.setItem("sonNav", 2) : '';
        if (url) {
          this.$router.push(url);
        }
      },
      submitUpload() {
        this.$refs.upload.submit();
      },
      edit(row){
        this.open = true;
        this.form = row;
        this.classList = row.class_id.split(",");
      },
      del(id) {
        this.$confirm("确认删除?", "提示", {
          type: "warning",
        }).then(() => {
          this.$api
            .delMarkTask({
              id: id,
            })
            .then((res) => {
              if (!res.data.code) {
                this.msgSuccess("删除成功");
                this.getData();
              } else {
                this.$msgError(res.data.message);
              }
            });
        });
      },
      gopage(size) {
        if (size) {
          this.queryParams.page_size = size;
        }
        this.queryParams.page = this.$refs.pageButton.page;
        this.getData();
      },
      goTaskImg(page){
        if (page) {
          this.imgForm.page_size = size;
        }
        this.imgForm.page = this.$refs.pageImgButton.page;
        let that = this;
        that.$api.getTaskImgList({
            task_id: that.curTaskId,
            page:that.imgForm.page,
            page_size:that.imgForm.page_size
          }).then(res => {
            that.fileList = res.data.data.list
            that.taskImgTotal = res.data.data.total;
          })
      },
      goRecPage(size) {
        if (size) {
          this.recPageSize = size;
        }
        this.recPage = this.$refs.pageButton.page;
        this.recParams = {
          task_id: this.curTaskId,
          page: this.recPage,
          page_size: this.recPageSize,
          status: this.activeName,
          name: this.queryName,
          err_status: this.queryMarkStatus
        }
        window.clearInterval(this.timer);
        this.getData(this.curTaskId)
      },
      searchMarkData() {
        this.recParams.name = this.queryName;
        this.recParams.errStatus = this.queryMarkStatus;
        window.clearInterval(this.timer);
        this.getData(this.curTaskId);
      },
      reSetMarkData() {
        this.queryName = null;
        this.queryMarkStatus = null;
        this.queryParams.name = null;
        this.queryParams.err_status = null;
        window.clearInterval(this.timer);
        this.getData(this.curTaskId);
      },
      getData() {
        let id = this.$route.query.id;
        this.curTaskId = id
        this.uploadDialogVisible = true
        this.taskid = id
        let that = this;
        this.loading = true;
        this.recParams = {
          task_id: id,
          page: this.recPage,
          page_size: this.recPageSize,
          status: this.activeName,
          name: this.queryName,
          err_status: this.queryMarkStatus
        }
        this.$api.getMarkTaskStudents(this.recParams).then(res => {
          this.studentsList = res.data.data.list;
          this.studentsList.forEach(item => {
            let mark_status = item.mark_status;
            if (mark_status != 1) {
              item.mark_status_name = this.$const.recErrorList.filter((ritem) => {
                return ritem.value == mark_status;
              })[0].label
            } else {
              item.mark_status_name = "正常"
            }
          })
          this.recTotal = res.data.data.total;
          this.recSucTotal = res.data.data.suc_total;
          this.recKhErrTotal = res.data.data.kh_err_total;
          this.recObjErrTotal = res.data.data.obj_err_cnt;
          this.recWaitingErrTotal = res.data.data.waiting_cnt;
          this.loading = false;
        })
        window.clearInterval(this.timer);
        this.timer = setInterval(function () {
          that.$api.getMarkTaskStudents(that.recParams).then(res => {
            that.studentsList = res.data.data.list;
            that.studentsList.forEach(item => {
              let mark_status = item.mark_status;
              if (mark_status != 1) {
                item.mark_status_name = that.$const.recErrorList.filter((ritem) => {
                  return ritem.value == mark_status;
                })[0].label
              } else {
                item.mark_status_name = "正常"
              }
            })
            that.recTotal = res.data.data.total;
            that.recSucTotal = res.data.data.suc_total;
            that.recKhErrTotal = res.data.data.kh_err_total;
            that.recObjErrTotal = res.data.data.obj_err_cnt;
            that.recWaitingErrTotal = res.data.data.waiting_cnt;
          })
        }, 4000)
      },
      closeRemarkDialog() {
        this.remarkDialogVisible = false;
        this.fileList = []
      },
      closeTaskImgDialog() {
        this.imgListVisible = false;
        window.clearInterval(this.timer2);
      },
      handlePreview(file) {
        console.log(file);
      },
      handleChange(file, fileList) {},

      openTaskImgList() {
        let that = this;
        this.imgListVisible = true
        window.clearInterval(this.timer2);
        this.timer2 = setInterval(function () {
          that.$api.getTaskImgList({
            task_id: that.curTaskId,
            page:that.imgForm.page,
            page_size:that.imgForm.page_size
          }).then(res => {
            that.fileList = res.data.data.list
            that.taskImgTotal = res.data.data.total;
          })
        }, 2000)
      },
      handleUploadSuccess(res, file, fileList) {
        if (!res.code) {
          if (fileList.every(item => item.status == "success")) {
            fileList.map(item => {
              item.response && this.fileList.push({
                "url": res.data.url,
                "name": res.data.name
              })
            })
          }
        }
      },
      delStudents(id, index,action) {
        this.$api.delMarkTaskStudents({
          id: id,
          action:action
        }).then(res => {
          this.msgSuccess("删除成功!");
          this.studentsList.splice(index, 1)
        })
      },
      handleRemove(e) {
        console.log(e)
      },
      drawRect(x, y, lineW, lineY) {
          //   开始绘制;
          this.ctx.beginPath();
          //   //设置线条颜色，必须放在绘制之前
          this.ctx.strokeStyle = "red";
          //   console.log("44444444");
          //   // 线宽设置，必须放在绘制之前
          this.ctx.lineWidth = 1;
          //   console.log("5555555555");
          // strokeRect参数：（左上角x坐标，y:左上角y坐标，绘画矩形的宽度，绘画矩形的高度）
          this.ctx.strokeRect(x, y, lineW, lineY);
          //   console.log("66666666666666");
      },
      showStudentImgs(row) {
        this.curStudentRecImg = JSON.parse(row.imgs)[0];
        this.showAnsVisible = true;
        this.curStudentNo = row.student_no;
        this.form.student_no = this.curStudentNo;
        this.searchStudentsData = [];
        let that = this;
        let objective_result = row.objective_result;
        let objective_ans = row.objective_ans;

        // 获取试卷客观题标准填涂
        let paper_id = row.paper_id;
        that.objectiveRecResult = [];
        this.$api.getPaperQueInfo({id:paper_id}).then(res=>{
          let stdQueList = JSON.parse(res.data.data.stdQueList)
          stdQueList.forEach(item=>{
            that.objectiveRecResult = that.objectiveRecResult.concat(item);
            console.log(objective_ans,222222222222222)
            // 补全填涂答案
            let rec_result = {}
            let rec_result_num = {}
            objective_ans.forEach(iitem=>{
              let fillAns = iitem["ans"];
              let fillNum = [];
              fillAns.split(",").forEach(fans=>{
                fillNum.push(this.$const.ansOptionIndex[fans])
              })
              rec_result[iitem["qno"]] = fillAns
              rec_result_num[iitem["qno"]] = fillNum
            })

            that.objectiveRecResult.forEach(orr=>{
              orr["fillAns"] = rec_result[orr["qno"]]?rec_result[orr["qno"]]:""
              orr["fillNum"] = rec_result_num[orr["qno"]]?rec_result_num[orr["qno"]]:[]
            })
          })
        })

        this.$nextTick(function () {
            
              that.canvas = document.getElementById("myCanvas");
              that.ctx = that.canvas.getContext("2d");

              let image = new Image();
              image.src = that.curStudentRecImg;

              image.onload = function(){
                that.srcImgWidth = image.width;
                that.srcImgHeight = image.height;
                that.canvasImgScale = 680/image.width;
                that.ctx.drawImage(image, 0, 0, that.srcImgWidth, that.srcImgHeight, 0, 0, that.srcImgWidth*that.canvasImgScale, that
                      .srcImgHeight*that.canvasImgScale)
                objective_result.forEach(item=>{
                  item.forEach(iitem=>{
                    that.drawRect(iitem.absX*that.canvasImgScale,iitem.absY*that.canvasImgScale,iitem.w*that.canvasImgScale,iitem.h*that.canvasImgScale);
                    that.ctx.font = '12px Arial';
                    that.ctx.fillStyle = 'red';
                    if(iitem.ans){
                      that.ctx.fillText(iitem.ans, iitem.absX*that.canvasImgScale,iitem.absY*that.canvasImgScale);
                    }
                  })
                })
                
              }

        })
      },
      saveModifQueAns(){
        let params = {
            task_id:this.curTaskId,
            student_no:this.curStudentNo
        }
        let objective_ans = [];
        this.objectiveRecResult.forEach(item=>{
          if(item.fillNum.length>0){
            objective_ans.push({
              qno:item.qno,
              ans:item.fillAns
            })
          }
        })
        params.objective_ans = objective_ans;
        let that = this;
        this.$api.saveModifQueAns(params).then(res=>{
          if(!res.data.code){
            this.msgSuccess("保存成功!");
            this.showAnsVisible = false;
          }else{
            this.msgError(res.data.message);
          }
        })
      },
      setStdAns(oitem, index) {
        //oitem表示每一题，index表示每一个选项
        let fillNum = oitem.fillNum; //已识别的填涂选项
        if(fillNum.indexOf(index)==-1){
          fillNum.push(index)
        }else{
          fillNum.splice(fillNum.indexOf(index),1);
        }
        //重新计算fillAns
        let fillAns = [];
        fillNum.forEach(num=>{
          if(num){
            fillAns.push(this.$const.ansOptionIndex[num])
          }
        })
        oitem.fillAns = fillAns.join();
        this.$forceUpdate();
      },
      searchStudents(){
        let params = {
          student_no:this.curStudentNo
        }
        this.$api.searchStudents(params).then(res=>{
          this.searchStudentsData = res.data.data;
        })
      },
      saveModifyStudentNo(){
        let params = {
          student_no:this.curStudentNo,
          task_id:this.curTaskId
        }
        this.$api.saveModifyStudentNo(params).then(res=>{
          console.log(res,1111111111111)
          this.showAnsVisible = false;
        })
      },
      showCurRecImg(row) {
        this.curStudentRecImg = row.ans_imgs.replace(".png", "_draw_ans.png");
        this.showAnsVisible = true;
      },
      showCurRecKhImg(row) {
        let ext = row.ans_imgs.split("/").pop()
        if (ext) {
          ext = "." + ext.split(".")[1]
        }
        this.curStudentRecImg = row.ans_imgs.replace("_ans" + ext, "_sno" + ext);
        this.showAnsVisible = true;
      },

      handleTabClick(tab, event) {
        this.activeName = tab.name;
        this.recPage = 1;
        this.recParams = {
          task_id: this.curTaskId,
          page: this.recPage,
          page_size: this.recPageSize,
          status: this.activeName,
          name: this.queryName,
          err_status: this.queryMarkStatus
        }
        window.clearInterval(this.timer);
        this.getData(this.curTaskId)
      },
      downloadObjectiveResult(task_id) {
        this.$api
          .downloadObjectiveResult({
            task_id: task_id
          })
          .then((res) => {
            var elink = document.createElement("a");
            let blob = new Blob([res.data], {
              type: "application/vnd.ms-excel,charset=UTF-8",
            });
            let objUrl = URL.createObjectURL(blob);
            let file_name = decodeURIComponent(
              res.headers["content-disposition"].split("=")[1]
            );
            elink.download = file_name;
            elink.style.display = "none";
            elink.href = objUrl;
            document.body.appendChild(elink);
            elink.click();
            document.body.removeChild(elink);
            this.download_loading = false;
          });
      },
      handleSelectionChange(val) {
        this.selectException = [];
        if (val.length > 0) {
          val.forEach(item => {
            let task_img = item.task_id + ";;" + item.imgs + ";;" + item.id;
            this.selectException.push(task_img);
          })
          window.clearInterval(this.timer);
        }
      },
      reTryMark() {
        if (this.selectException.length < 1) {
          this.msgError("请选择需要重新识别的答卷!");
        } else {
          this.remarkDialogVisible = true;
        }
      },
      doReTryMark() {
        let urls = []
        this.selectException.forEach(item => {
          item = item + ";;" + String(this.form.khVoiceNum) + ";;" + String(this.form.khFillRate);
          item = item + ";;" + String(this.form.tmVoiceNum) + ";;" + String(this.form.tmFillRate);
          urls.push(item);
        })
        let that = this;
        this.$api.reTryMarkPaper({
          urls: urls
        }).then(res => {
          this.remarkDialogVisible = false;
          this.getData();
          window.clearInterval(this.timer);
          this.timer = setInterval(function () {
            that.$api.getMarkTaskStudents(that.recParams).then(res => {
              that.studentsList = res.data.data.list;
              that.studentsList.forEach(item => {
                let mark_status = item.mark_status;
                if (mark_status != 1) {
                  item.mark_status_name = that.$const.recErrorList.filter((ritem) => {
                    return ritem.value == mark_status;
                  })[0].label
                } else {
                  item.mark_status_name = "正常"
                }
              })
              that.recTotal = res.data.data.total;
              that.recSucTotal = res.data.data.suc_total;
              that.recKhErrTotal = res.data.data.kh_err_total;
              that.recObjErrTotal = res.data.data.obj_err_cnt;
              that.recWaitingErrTotal = res.data.data.waiting_cnt;
            })
          }, 4000)
        })
      },
      startRecPaper() {
        this.loading = true
        this.$api.startRecPaper({
          task_id: this.curTaskId
        }).then(res => {
          this.loading = false
        })
      },
      remarkSet(row) {
        this.remarkSetVisible = true
        this.curTaskId = row.task_id;
        this.curPaperId = row.paper_id;
      },
      closeMarkTaskSet(){
        this.remarkSetVisible = false
      },
      starScanPaper(taskId,remoteHost){
        OpenDwSource(taskId,remoteHost)
      }
    },
    created() {
      this.getData();
      this.getSchoolList();
      this.getGradeList();
      this.getClassList();
    },
  };
</script>
<style lang="scss">
  .el-upload-list {
    display: none !important;
  }

  .el-upload-list--picture .el-upload-list__item {
    width: 150px;
    float: left;
    margin-right: 10px;
    position: relative;
  }

  .el-upload-list--picture .el-upload-list__item.is-success .el-upload-list__item-name {
    position: absolute;
    z-index: 100;
    height: 70px;
    line-height: 130px;
  }

  .el-upload-list--picture .el-upload-list__item-thumbnail {
    width: 125px;
  }

  .prosss_box .el-progress.el-progress--line {
    width: 88px;
    margin: auto 5px auto 0;
  }

  .prosss_box .el-progress-bar {
    padding-right: 0;
  }

  .prosss_box .el-progress__text {
    display: none;
  }

  .prosss_box {
    display: flex;
  }
  .kgtContainer{
    border:1px solid #ccc;
    padding:10px;
    .topContainer{
      display:flex;
      .topItem{
        width:50%;
        flex-direction:column;
      }
      .topItem:last-child{
        width:50%;
        flex-direction:column;
        text-align:right;
      }
    }
    .kgtItem{
      margin:10px;
    }
  }
  
</style>