瀏覽代碼

模板优化完成

Your Name 1 年之前
父節點
當前提交
13325ca940
共有 4 個文件被更改,包括 139 次插入103 次删除
  1. 8 0
      src/api.js
  2. 2 2
      src/views/papers/Index.vue
  3. 123 100
      src/views/papers/cutPaper.vue
  4. 6 1
      src/views/tasks/Index.vue

+ 8 - 0
src/api.js

@@ -356,4 +356,12 @@ export default {
 			params: params,
 		});
     },
+    // 更新客观题识别信息
+    savePaperTplObjectiveQue: params => {
+	    return axios.put(`${baseURL}/api/admin/papers/tpl/objective/update`, params)
+    },
+    // 更新主观题切片
+    savePaperTplSubjectiveQue: params => {
+        return axios.put(`${baseURL}/api/admin/papers/tpl/subjective/update`, params)
+    }
 }

+ 2 - 2
src/views/papers/Index.vue

@@ -1,4 +1,4 @@
-<style lang="scss">
+<style lang="scss" scoped>
 
 </style>
 <template>
@@ -155,9 +155,9 @@
       },
       handleSuccess(res){
         this.fileList.push({"name":res.data.name,"url":res.data.url})
+        console.log(this.fileList,222222222222222)
       },
       handleRemove(file,fileList){
-        console.log(file,fileList,22222222222)
         this.fileList = fileList
       },
       edit(id) {

+ 123 - 100
src/views/papers/cutPaper.vue

@@ -68,7 +68,7 @@
               <div style="margin-bottom:10px;">
                 <i class="el-icon-delete" @click="ansCardImgList.splice(index,1)"
                   style="float:right;color:red;cursor: pointer;"></i>
-                <i class="el-icon-edit" @click="editAnsCard(item,curPaperId)"
+                <i class="el-icon-edit" @click="editAnsCard(item,curPaperId,index)"
                   style="float:right;color:blue;margin-right:20px;cursor: pointer;"></i>
                 <div class="clear"></div>
               </div>
@@ -108,7 +108,6 @@
     <!-- 客观题设置 -->
     <el-dialog title="客观题设置" :visible.sync="open" width="90%" append-to-body>
       <el-row :gutter="20">
-
         <el-col :span="12">
           <h4>分数设置</h4>
           <!-- <div class="tag-group">
@@ -151,7 +150,7 @@
               </el-form-item>
             </el-form>
 
-            <el-table :data="stdQueList.slice((currentPage-1)*pageSize,currentPage*pageSize)">
+            <el-table :data="curStdQueList.slice((currentPage-1)*pageSize,currentPage*pageSize)">
               <el-table-column label="序号" prop="qno" width="60px"></el-table-column>
               <el-table-column label="题号" prop="qno"></el-table-column>
               <el-table-column label="分数" prop="score"></el-table-column>
@@ -172,7 +171,7 @@
               </el-table-column>
             </el-table>
             <el-pagination background layout="prev, pager, next" :page-sizes="[10,20,30,50]" :page-size="pageSize"
-              @current-change="handleCurrentChange" :current-page.sync="currentPage" :total="stdQueList.length">
+              @current-change="handleCurrentChange" :current-page.sync="currentPage" :total="curStdQueList.length">
             </el-pagination>
           </div>
         </el-col>
@@ -217,28 +216,27 @@
               <div style="margin-top:10px;margin-bottom:10px;" v-if="choiceType==2">
                 <span class="tag-group__title">选项框:</span>
                 <div>
-                  <div v-for="(item,index) in stdChoiceList" style="display:inline-block;position:relative;">
-                    <i class="el-icon-close delChoice" @click="stdChoiceList.splice(index,1)"></i>
+                  <div v-for="(item,index) in curStdChoiceList" style="display:inline-block;position:relative;">
+                    <i class="el-icon-close delChoice" @click="curStdChoiceList.splice(index,1)"></i>
                     <el-image class="choiceImg" :src="item"></el-image>
                   </div>
                 </div>
               </div>
             </el-col>
             <el-col :span="10">
-              <el-button @click="autoSetScore" style="float:right;margin-left:10px;" type="warning" size="mini">设置分值
-              </el-button>
               <el-button style="float:right;" type="primary" @click="tryRecPaper" size="mini">识别测试
               </el-button>
 
             </el-col>
           </el-row>
           <div style="border:1px solid #ddd;position:relative;" v-loading="ansImgLoading">
-            <img v-if="recCurAnsImg || stdChoiceList.length>0" id="ansImage" ref="ansImage" width="100%"
+            <img v-if="recCurAnsImg || stdChoiceList.length>0 && false" id="ansImage" ref="ansImage" width="100%"
               :src="recCurAnsImg" />
-            <img v-else id="ansImage" ref="ansImage" width="100%" :src="curAnsImg" />
+            <img v-else test="11" id="ansImage" ref="ansImage" width="100%" :src="curAnsImg" />
             <!-- 题号 -->
             <!-- <div :style="'display:inline-block;color:red;border:1px solid red;left:'+(item[0].x)+'px;top:'+(item[0].y)+'px;position:absolute;font-size:18px;'" v-for="(item,index) in stdQnoPoints" :key="index">{{item[0].qno}}</div> -->
           </div>
+          <div style="margin:20px 0px;font-size:18px;">共识别出:{{recQueNum}}题,{{recFillNum}}个填涂框</div>
         </el-col>
       </el-row>
       <div slot="footer" class="dialog-footer">
@@ -344,7 +342,9 @@
           score: 0
         },
         stdQueList: [],
+        curStdQueList:[],
         stdQnoPoints: [],
+        curStdQnoPoints:[],
         paperImgs: [],
         curPaperImg: "",
         recCurAnsImg: "",
@@ -364,13 +364,17 @@
         khOpen: false,
         stdPoints: null,
         khPointsCrop: {},
-        ansPointsCrop: {},
+        ansPointsCrop: [],
         subImgList: [],
         activePaper: true,
         curPaperIndex: 0,
         curQueIndex: 0,
         curPressKey: null,
-        drag: false
+        drag: false,
+        curStdChoiceList:[],
+        curAnsIndex:0,
+        recQueNum:0,
+        recFillNum:0
       };
     },
     watch: {
@@ -420,13 +424,24 @@
           this.stdPoints = res.data.data.stdPoints ? JSON.parse(res.data.data.stdPoints) : {};
           this.snoImg = res.data.data.khPoints;
           this.khPointsCrop = res.data.data.khPointsCrop ? JSON.parse(res.data.data.khPointsCrop) : {};
-          this.ansCardImgList = res.data.data.ansPoints ? JSON.parse(res.data.data.ansPoints) : [];
-          this.ansPointsCrop = res.data.data.ansPointsCrop ? [res.data.data.ansPointsCrop] : [];
+          // 客观题
+          this.ansPoints = res.data.data.ansPoints ? JSON.parse(res.data.data.ansPoints) : [];
+          let ansPointsCrop = res.data.data.ansPointsCrop ? JSON.parse(res.data.data.ansPointsCrop) : [];
+          this.ansCardImgList = ansPointsCrop;
+          if (res.data.data.stdChoices) {
+            this.stdChoiceList = JSON.parse(res.data.data.stdChoices);
+          }
+          if (res.data.data.stdQueList) {
+            this.stdQueList = JSON.parse(res.data.data.stdQueList);
+          }
+
           this.khType = res.data.data.khType;
           this.khLength = res.data.data.khLength;
+          // 主观题
           let subQueImgList = [];
           paperPieces.forEach((item, index) => {
             subQueImgList.push({
+              pno:item.paper_no,
               qno: item.qno,
               qimg: item.imgs,
               point: item.imgs_points
@@ -457,29 +472,26 @@
       activeQue(index) {
         this.curQueIndex = index;
       },
-      editAnsCard(item, curPaperId) {
+      editAnsCard(item, curPaperId,index) {
         this.open = true;
         this.curAnsImg = item;
         this.recCurAnsImg = null;
-        this.stdQueList = [];
         this.addQueForm = {};
-        this.stdChoiceList = [];
         this.ansImgLoading = false;
-        this.$api.getPaperInfo({
-          id: curPaperId
-        }).then((res) => {
-          let imgs = JSON.parse(res.data.data.imgs);
-          this.curPaperImg = imgs[0];
-          this.ansCardImgList = res.data.data.ansPoints ? JSON.parse(res.data.data.ansPoints) : [];
-          this.snoImg = res.data.data.khPoints;
-          if (res.data.data.stdChoices) {
-            this.stdChoiceList = JSON.parse(res.data.data.stdChoices);
-          }
-          if (res.data.data.stdQueList) {
-            this.stdQueList = JSON.parse(res.data.data.stdQueList);
-          }
-          this.loading = false;
-        });
+        this.curAnsIndex = index;
+        // 标准识别模板
+        if(this.stdChoiceList.length>index){
+          this.curStdChoiceList = this.stdChoiceList[index];
+        }
+        // 标准客观题数据
+        if(this.stdQueList.length>index){
+          this.curStdQueList = this.stdQueList[index];
+        }
+        // 识别出的标准填涂框
+        if(this.stdQnoPoints.length>index){
+          this.curStdQnoPoints = this.stdQnoPoints[index];
+        }
+
         this.initAnsCropper();
       },
       updatePaperRecInfo() {
@@ -491,53 +503,56 @@
           this.msgError("请标注考号区域!")
           return
         }
-        if (!this.ansCardImgList.length) {
-          this.msgError("请标注客观题区域!")
-          return
-        }
-        let params = {
-          id: this.$route.query.id,
-          stdQnoPoints: this.stdQnoPoints,
-          khPoints: this.snoImg,
-          ansPoints: this.ansCardImgList,
-          stdChoices: this.stdChoiceList,
-          stdQueList: this.stdQueList,
-          khType: this.khType,
-          khLength: this.khLength,
-          ansPointsCrop: this.ansPointsCrop,
-          subImgList: this.subImgList
+        // 主观题保存
+        if(this.stepNum == 4){
+          let params = {
+            paper_id:this.$route.query.id,
+            subImgList:this.subImgList
+          }
+          this.$api.savePaperTplSubjectiveQue(params).then(res=>{
+            if(!res.data.code){
+              this.msgSuccess("成功!");
+            }else{
+              this.msgError(res.data.message);
+            }
+          })
+        }else{
+          let params = {
+            id: this.$route.query.id,
+            stdQnoPoints: this.stdQnoPoints,
+            khPoints: this.snoImg,
+            ansPoints: this.ansPointsCrop,
+            stdChoices: this.stdChoiceList,
+            stdQueList: this.stdQueList,
+            khType: this.khType,
+            khLength: this.khLength,
+            ansPointsCrop: this.ansCardImgList,
+            subImgList: this.subImgList
+          }
+          this.$api.updatePaperInfo(params).then(res => {
+            this.msgSuccess("成功!");
+            this.getData();
+            this.open = false;
+          })
         }
-        this.$api.updatePaperInfo(params).then(res => {
-          this.msgSuccess("成功!");
-          this.getData();
-          this.open = false;
-        })
       },
       updatePaperScore() {
-        if (!this.stdPointImg) {
-          this.msgError("请标注标准点!")
-          return
-        }
-        if (!this.snoImg) {
-          this.msgError("请标注考号区域!")
-          return
-        }
-        if (!this.ansCardImgList.length) {
-          this.msgError("请标注客观题区域!")
-          return
-        }
+        //更新客观题识别信息
+        this.stdChoiceList[this.curAnsIndex]=this.curStdChoiceList;
+        this.stdQueList[this.curAnsIndex] = this.curStdQueList;
+        this.stdQnoPoints[this.curAnsIndex] = this.curStdQnoPoints;
         let params = {
-          id: this.$route.query.id,
+          paper_id: this.$route.query.id,
           stdQnoPoints: this.stdQnoPoints,
-          khPoints: this.snoImg,
-          ansPoints: this.ansCardImgList,
           stdChoices: this.stdChoiceList,
           stdQueList: this.stdQueList,
-          khType: this.khType,
-          khLength: this.khLength,
         }
-        this.$api.updatePaperInfo(params).then(res => {
-          this.msgSuccess("成功!");
+        this.$api.savePaperTplObjectiveQue(params).then(res => {
+          if(!res.data.code){
+            this.msgSuccess("成功!");
+          }else{
+            this.msgError(res.data.message)
+          }
           this.getData();
           this.open = false;
         })
@@ -628,8 +643,9 @@
 
                   khPointsCrop["x"] = khPointsCrop["x"] - that.stdPoints["x"];
                   khPointsCrop["y"] = khPointsCrop["y"] - that.stdPoints["y"];
-                  that.ansPointsCrop = khPointsCrop;
+                  that.ansPointsCrop.push(khPointsCrop);
                   that.ansCardImgList.push(cropperImgData);
+                  console.log(that.ansCardImgList,3333333333333)
                 }
                 // 主观题
                 if (that.stepNum == 4) {
@@ -720,7 +736,8 @@
                 let cropperImgData = this.cropper.getCroppedCanvas({
                   width: 1310
                 }).toDataURL("image/jpeg");
-                that.stdChoiceList.push(cropperImgData)
+                console.log(that.curStdChoiceList,2222222222222222)
+                that.curStdChoiceList.push(cropperImgData)
               }
               that.myAnsCropper.clear()
             },
@@ -738,11 +755,28 @@
           queDir: this.queDir,
           choiceType: this.choiceType,
           threshVal: this.threshVal,
-          stdChoiceList: this.stdChoiceList
+          stdChoiceList: this.curStdChoiceList
         }).then(res => {
           if (!res.data.code) {
             this.recCurAnsImg = res.data.data.recImg;
-            this.stdQnoPoints = res.data.data.ansCnts;
+            this.curStdQnoPoints = res.data.data.ansCnts;
+            // 组装分数设置数值
+            this.curStdQueList = [];
+            this.recFillNum = 0;
+            this.curStdQnoPoints.forEach((item, index) => {
+              let queRow = {
+                qno: item[0].qno,
+                score: null,
+                qtype: "",
+                stdAns: "",
+                points:item
+              }
+              this.curStdQueList.push(queRow)
+              // 填涂框数量
+              this.recFillNum += item.length;
+            })
+            // 识别出的客观题数量
+            this.recQueNum = this.curStdQueList.length;
             this.myAnsCropper.destroy();
             this.initAnsCropper();
           } else {
@@ -756,31 +790,19 @@
         let fQno = parseInt(this.addQueForm.fQno);
         let tQno = parseInt(this.addQueForm.tQno);
         for (var i = fQno; i < tQno + 1; i++) {
-          this.stdQueList.forEach((item, index) => {
+          this.curStdQueList.forEach((item, index) => {
             if (item.qno == String(i)) {
               // item.score = this.addQueForm.score
               // item.qtype = this.addQueForm.qtype
-              this.stdQueList[index].score = this.addQueForm.score
-              this.stdQueList[index].qtype = this.addQueForm.qtype
+              this.curStdQueList[index].score = this.addQueForm.score
+              this.curStdQueList[index].qtype = this.addQueForm.qtype
               // this.stdQueList[index].stdAns = this.addQueForm.stdAns.join(",")
-              this.$set(this.stdQueList[index], "score", this.addQueForm.score)
+              this.$set(this.curStdQueList[index], "score", this.addQueForm.score)
               this.$forceUpdate();
             }
           })
         }
       },
-      autoSetScore() {
-        this.stdQueList = [];
-        this.stdQnoPoints.forEach((item, index) => {
-          let queRow = {
-            qno: item[0].qno,
-            score: null,
-            qtype: "",
-            stdAns: ""
-          }
-          this.stdQueList.push(queRow)
-        })
-      },
       setStdAns(row, item) {
         let orgAns = row.stdAns.split(",")
         orgAns = orgAns.filter((item) => {
@@ -830,7 +852,8 @@
           let params = {
             id: this.$route.query.id,
             khPoints: this.snoImg,
-            khPointsCrop: this.khPointsCrop
+            khPointsCrop: this.khPointsCrop,
+            khType:this.khType
           }
           this.$api.updatePaperInfo(params).then(res => {
             let rst = res.data;
@@ -853,14 +876,14 @@
         }
         // 客观题
         if (this.stepNum == 3) {
-          let params = {
-            id: this.$route.query.id,
-            ansPoints: this.ansCardImgList,
-            khPointsCrop: this.khPointsCrop
-          }
-          this.$api.updatePaperInfo(params).then(res => {
-            this.getData();
-          })
+          // let params = {
+          //   id: this.$route.query.id,
+          //   ansPoints: this.ansCardImgList,
+          //   khPointsCrop: this.khPointsCrop
+          // }
+          // this.$api.updatePaperInfo(params).then(res => {
+          //   this.getData();
+          // })
           this.stepNum += 1
         }
         // 主观题

+ 6 - 1
src/views/tasks/Index.vue

@@ -47,7 +47,7 @@
 	              scope.row.task_id
             )" size="mini" type="success">开始阅卷</el-button>
           <el-button @click="remarkSet(scope.row)" size="mini" type="warning">阅卷设置</el-button>
-          <el-button @click="edit(scope.row.id)" size="mini" type="warning">编辑</el-button>
+          <!--<el-button @click="edit(scope.row)" size="mini" type="warning">编辑</el-button>-->
           <el-button @click="openUploadPaper(scope.row.task_id)" size="mini" type="primary">上传试卷</el-button>
           <el-button @click="del(scope.row.task_id)" size="mini" type="danger">删除</el-button>
         </template>
@@ -331,6 +331,11 @@
       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",