Browse Source

模板切割基本完成

Your Name 1 year ago
parent
commit
827dbb9190
3 changed files with 62 additions and 59 deletions
  1. 5 2
      src/views/papers/canvasDrawer.vue
  2. 57 56
      src/views/papers/cutPaper.vue
  3. 0 1
      src/views/tasks/Index.vue

+ 5 - 2
src/views/papers/canvasDrawer.vue

@@ -38,7 +38,8 @@
         props: {
             srcImg: String,
             curId:String,
-            khType:Number
+            khType:Number,
+            khPoints:String
         },
         data() {
             return {
@@ -400,7 +401,9 @@
                     stdKhList:this.stdKhList,
                     khType:this.khType,
                     khLength:this.khLength,
-                    khPoints:this.srcImg
+                    khPoints:this.khPoints,
+                    khPointsCrop:this.srcImg,
+                    updateType:"stdKh"
                 }
                 this.$api.updatePaperInfo(params).then(res => {
                     this.msgSuccess("成功!");

+ 57 - 56
src/views/papers/cutPaper.vue

@@ -17,8 +17,8 @@
       </el-col>
       <el-col :span="6">
         <el-button size="mini" type="primary" v-if="stepNum > 1" @click="stepNum-=1">上一步</el-button>
-        <el-button size="mini" type="primary" v-if="stepNum < 4" @click="nextStep">下一步</el-button>
-        <el-button size="mini" type="success" @click="updatePaperRecInfo">保存</el-button>
+        <el-button size="mini" type="primary" v-if="stepNum < 4" @click="nextStep(true)">下一步</el-button>
+        <el-button size="mini" type="success" @click="nextStep(false)">保存</el-button>
       </el-col>
     </el-row>
     <el-row>
@@ -49,14 +49,14 @@
               <el-radio v-model="khType" :label="2" :value="2">条码</el-radio>
               <el-radio v-model="khType" :label="1" :value="1">涂点</el-radio>
             </div>
-            <div v-if="snoImg">
+            <div v-if="khPointsCrop">
               <div style="margin-bottom:10px;" v-if="khType==1">
-                <i class="el-icon-edit" @click="editKhCard(snoImg,curPaperId)"
+                <i class="el-icon-edit" @click="editKhCard(khPointsCrop,curPaperId)"
                   style="float:right;color:blue;margin-right:20px;cursor: pointer;"></i>
                 <div class="clear"></div>
               </div>
-              <el-image style="margin-bottom:20px 0px;border:1px solid #ccc;" height="60px" width="100%" :src="snoImg"
-                :preview-src-list="[snoImg]"></el-image>
+              <el-image style="margin-bottom:20px 0px;border:1px solid #ccc;" height="60px" width="100%" :src="khPointsCrop"
+                :preview-src-list="[khPointsCrop]"></el-image>
             </div>
           </el-card>
           <!-- 客观题 -->
@@ -103,7 +103,7 @@
     </el-row>
     <!-- 涂点考号 -->
     <el-dialog title="考号设置" :visible.sync="khOpen" width="65%" append-to-body>
-      <canvasDrawer v-if="khOpen" :srcImg="snoImg" :curId="curPaperId" :khType="khType" @close="khOpen=false" />
+      <canvasDrawer v-if="khOpen" :khPoints="khPoints" :srcImg="khPointsCrop" :curId="curPaperId" :khType="khType" @close="khOpen=false" />
     </el-dialog>
     <!-- 客观题设置 -->
     <el-dialog title="客观题设置" :visible.sync="open" width="90%" append-to-body>
@@ -426,8 +426,11 @@
           this.paperImgs = imgs;
           this.stdPointImg = res.data.data.stdPointsImg;
           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.khPoints = res.data.data.khPoints  ? JSON.parse(res.data.data.khPoints) : {};
+          this.khPointsCrop = res.data.data.khPointsCrop;
+          this.khType = res.data.data.khType;
+          this.khLength = res.data.data.khLength;
           // 客观题
           this.ansPoints = res.data.data.ansPoints ? JSON.parse(res.data.data.ansPoints) : [];
           let ansPointsCrop = res.data.data.ansPointsCrop ? JSON.parse(res.data.data.ansPointsCrop) : [];
@@ -435,12 +438,12 @@
           if (res.data.data.stdChoices) {
             this.stdChoiceList = JSON.parse(res.data.data.stdChoices);
           }
+          if (res.data.data.stdQnoPoints) {
+            this.stdQnoPoints = JSON.parse(res.data.data.stdQnoPoints);
+          }
           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) => {
@@ -520,24 +523,6 @@
               this.msgError(res.data.message);
             }
           })
-        }else{
-          let params = {
-            id: this.$route.query.id,
-            stdQnoPoints: this.stdQnoPoints,
-            khPoints: this.snoImg,
-            ansPoints: this.ansPoints,
-            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;
-          })
         }
       },
       updatePaperScore() {
@@ -633,7 +618,8 @@
                   }
                   khPointsCrop["x"] = khPointsCrop["x"] - that.stdPoints["x"];
                   khPointsCrop["y"] = khPointsCrop["y"] - that.stdPoints["y"];
-                  that.khPointsCrop = khPointsCrop;
+                  that.khPoints = khPointsCrop;
+                  that.khPointsCrop = cropperImgData;
                   that.snoImg = cropperImgData;
                   that.snoImgW = cropData.width;
                   that.snoImgH = cropData.height;
@@ -824,7 +810,7 @@
       handleCurrentChange(val) {
         this.currentPage = val
       },
-      nextStep() {
+      nextStep(nextFlag) {
         if (this.stepNum == 1 && !this.stdPointImg) {
           this.msgError("请框选标准点,一般建议框选试卷标题!");
           return
@@ -838,7 +824,8 @@
           let params = {
             id: this.$route.query.id,
             stdPointsImg: this.stdPointImg,
-            stdPoints: this.stdPoints
+            stdPoints: this.stdPoints,
+            updateType:"stdPoint"
           }
           this.$api.updatePaperInfo(params).then(res => {
             if (!res.data.code && res.data.data.stdPoints) {
@@ -848,7 +835,9 @@
                 return
               } else {
                 this.getData();
-                this.stepNum += 1;
+                if(nextFlag){
+                  this.stepNum += 1;
+                }
               }
             }
           })
@@ -857,9 +846,11 @@
         if (this.stepNum == 2) {
           let params = {
             id: this.$route.query.id,
-            khPoints: this.snoImg,
-            khPointsCrop: this.khPointsCrop,
-            khType:this.khType
+            khPoints:this.khPointsCrop,
+            khPointsCrop:this.snoImg,
+            khType:this.khType,
+            khLength:this.khLength,
+            updateType:"stdKh"
           }
           this.$api.updatePaperInfo(params).then(res => {
             let rst = res.data;
@@ -867,44 +858,54 @@
               let khPointsCrop = JSON.parse(rst.data.khPointsCrop)
               let stdKhList = JSON.parse(rst.data.stdKhList);
               let khLength = rst.data.khLength;
-              // if(khPointsCrop.x < 10 || khPointsCrop.y < 10 ||khPointsCrop.w<50 
-              //   ||khPointsCrop.h<50||stdKhList.length!=khLength){
               if (khPointsCrop.x < 10 || khPointsCrop.y < 10 || khPointsCrop.w < 50 ||
                 khPointsCrop.h < 50) {
                 this.msgError("考号识别错误,请重编辑考号区域!");
                 return
               } else {
                 this.getData();
-                this.stepNum += 1;
+                if(nextFlag){
+                  this.stepNum += 1;
+                }
               }
             }
           })
         }
         // 客观题
         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();
-          // })
-          this.stepNum += 1
-        }
-        // 主观题
-        if (this.stepNum == 4) {
           let params = {
             id: this.$route.query.id,
-            ansPoints: this.ansCardImgList,
-            khPointsCrop: this.khPointsCrop,
-            subImgList: this.subImgList
+            ansPoints: this.ansPoints,
+            ansPointsCrop:this.ansCardImgList,
+            stdChoices:this.stdChoices,
+            stdQnoPoints:this.stdQnoPoints,
+            stdQueList:this.stdQueList,
+            updateType:"stdObjective"
           }
           this.$api.updatePaperInfo(params).then(res => {
             this.getData();
+            if(nextFlag){
+              this.stepNum += 1;
+            }
           })
         }
-      }
+        // 主观题保存
+        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("成功!");
+                this.getData();
+              }else{
+                this.msgError(res.data.message);
+              }
+            })
+          }
+        }
+      
     },
     created() {
       // this.getData();

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

@@ -636,7 +636,6 @@
               image.onload = function(){
                 that.srcImgWidth = image.width;
                 that.srcImgHeight = image.height;
-                console.log(that.srcImgHeight,33333333333333333)
                 that.canvasImgScale = 1000/image.width;
                 that.ctx.drawImage(image, 0, 0, that.srcImgWidth, that.srcImgHeight, 0, 0, that.srcImgWidth*that.canvasImgScale, that
                       .srcImgHeight*that.canvasImgScale)