Kaynağa Gözat

下载时,增加了校验

wangguoxi 2 ay önce
ebeveyn
işleme
d9ca6dbb40

+ 1 - 1
src/App.vue

@@ -18,7 +18,7 @@ export default {
     },
     methods: {
         SubmitLogin() {
-            const username = '5000715069857';
+            const username = '4305962347220710';
             const password = '123456';
             // const type = '1';
             const schoolType = sessionStorage.getItem('schoolType');

+ 1 - 1
src/http/api/errorQuestion.js

@@ -8,4 +8,4 @@ function url(url) {
 export const queryStudentErrorQuestion = (data) => get(url("/api/v1/studentError/queryStudentErrorQuestion"), data);
 export const markStudentErrorQuestion = (data) => get(url("/api/v1/studentError/markStudentErrorQuestion"), data);
 export const downloadStudentErrorQuestion = (data) => downLoadByBlob(url("/api/v1/studentError/downloadStudentErrorQuestion"), data);
-
+export const findStudentCard = (data) => get(url("/api/v1/studentData/findStudentCard"), data);

+ 158 - 97
src/utils/common.js

@@ -1,3 +1,5 @@
+import { MessageBox, Message } from 'element-ui';
+
 // 写一个防抖函数
 export function debounce(fn, delay) {
     let timer = null
@@ -36,7 +38,7 @@ export function throttle(fn, delay) {
 //         arrDPI[1] = window.screen.deviceYDPI;
 
 //     } else {
-        
+
 
 //         var tmpNode = document.createElement("DIV");
 
@@ -61,7 +63,7 @@ export function throttle(fn, delay) {
  */
 function getDPI() {
     return window.devicePixelRatio * 96; // 通常情况下,1英寸 = 96像素
-  }
+}
 
 
 //毫米转px
@@ -101,7 +103,7 @@ export function fixNumber(num) {
 
 export function pxToMm(px) {
 
-   if (px) {
+    if (px) {
         // 获取设备像素比
         const devicePixelRatio = window.devicePixelRatio || 1;
         // 标准DPI为96,考虑设备像素比进行调整
@@ -132,20 +134,18 @@ export function pxToMm(px) {
 
 // 保留整数 小数 四舍五入
 export function mmToPx(num) {
-    if(num)
-    {
+    if (num) {
         // console.log("num",num);
         // console.log("转换后",Math.round(1754/297*num));
         // let scale=1754/297;
         // let result=(scale*num).toFixed(4);
         // console.log("scale",scale,result);
-        let scale=1754/297;
-        return  parseFloat((scale*num).toFixed(4)); //高 150dpi 1754  96dpi:1120         1754*2480
+        let scale = 1754 / 297;
+        return parseFloat((scale * num).toFixed(4)); //高 150dpi 1754  96dpi:1120         1754*2480
         // return Math.round(1754/297*num)
     }
-    else
-    {
-        console.log("num",num);
+    else {
+        console.log("num", num);
         return 0;
     }
 }
@@ -168,101 +168,162 @@ export function mmToPx(num) {
 //     }
 // }
 
- //获取显示的状态
- export function getStateName(scannedStatus,studentStatus)
- {
-     // console.log(scannedStatus,studentStatus);
-     let result='正常';
-     if(scannedStatus==1)
-     {
-         result='正常'
-
-     }else if(scannedStatus==2)
-     {
-         result='缺考'
-
-     }else if(scannedStatus==3)
-     {
-         //异常分类
-         if(studentStatus==2)
-         {
-             result='定位异常'
-
-         }else if(studentStatus==3)
-         {
-             result='考号异常'
-
-         }else if(studentStatus==4)
-         {
-             result='客观题异常'
-
-         }else if(studentStatus==5)
-         {
-             result='选做题异常'
-
-         }else if(studentStatus==6)
-         {
-             result='空白卷异常'
-
-         }else if(studentStatus==7)
-         {
-             result='考号重复'
-         }
-     }
-     return result;
- }
-
-
- //获取百分比  type  progress 表示进度条使用
- export function getPercentage(num1,num2,type)
- {
-   
-    let result=0;
-    let percentage=0;
-    if(num1 && num2)
-    {
-        percentage=(parseFloat(num1)/parseFloat(num2)).toFixed(2);
+//获取显示的状态
+export function getStateName(scannedStatus, studentStatus) {
+    // console.log(scannedStatus,studentStatus);
+    let result = '正常';
+    if (scannedStatus == 1) {
+        result = '正常'
+
+    } else if (scannedStatus == 2) {
+        result = '缺考'
+
+    } else if (scannedStatus == 3) {
+        //异常分类
+        if (studentStatus == 2) {
+            result = '定位异常'
+
+        } else if (studentStatus == 3) {
+            result = '考号异常'
+
+        } else if (studentStatus == 4) {
+            result = '客观题异常'
+
+        } else if (studentStatus == 5) {
+            result = '选做题异常'
+
+        } else if (studentStatus == 6) {
+            result = '空白卷异常'
+
+        } else if (studentStatus == 7) {
+            result = '考号重复'
+        }
+    }
+    return result;
+}
+
+
+//获取百分比  type  progress 表示进度条使用
+export function getPercentage(num1, num2, type) {
+
+    let result = 0;
+    let percentage = 0;
+    if (num1 && num2) {
+        percentage = (parseFloat(num1) / parseFloat(num2)).toFixed(2);
 
     }
 
-    result= Math.round(percentage*100);
+    result = Math.round(percentage * 100);
     // console.log("num1,num2",num1,num2,percentage,result);
-    if(type=='progress')
-    {
-        
+    if (type == 'progress') {
+
         //进度条的值不能超100%
-        if(result>100)
-        {
-        result=100;
+        if (result > 100) {
+            result = 100;
         }
-        
+
     }
-    if(result<0)
-    {
-        result=0;
+    if (result < 0) {
+        result = 0;
     }
-  
-//    console.log("打印结果",result);
-   return result;
- }
-
-  //获取考试背景颜色值
-  export function getExamBackgroundColor(type)
-  {
-    const examTypesColor={
-        "1": {color:'#F56C6C',background:'#F56C6C'},//期末
-        "2": {color:'#3ba272',background:'#3ba272'},//期中
-        "3": {color:'#ea7acb',background:'#ea7acb'},//模拟
-        "4": {color:'#fac858',background:'#fac858'},//月考
-        "5": {color:'#995fb3',background:'#995fb3'},//周测
-        "6": {color:'#72C0DD',background:'#72C0DD'},//平时
+
+    //    console.log("打印结果",result);
+    return result;
+}
+
+//获取考试背景颜色值
+export function getExamBackgroundColor(type) {
+    const examTypesColor = {
+        "1": { color: '#F56C6C', background: '#F56C6C' },//期末
+        "2": { color: '#3ba272', background: '#3ba272' },//期中
+        "3": { color: '#ea7acb', background: '#ea7acb' },//模拟
+        "4": { color: '#fac858', background: '#fac858' },//月考
+        "5": { color: '#995fb3', background: '#995fb3' },//周测
+        "6": { color: '#72C0DD', background: '#72C0DD' },//平时
     };
-    const result=examTypesColor[type].background;
-    
+    const result = examTypesColor[type].background;
+
     return result;
-  }
-  //获取当前接口地址名称
-  export function getApiName(){
+}
+//获取当前接口地址名称
+export function getApiName() {
     const schoolType = sessionStorage.getItem('schoolType') ?? 1;//1:单校  2:联校
-    return schoolType==1?'schoolReport':'jointSchoolReport'
-  }
+    return schoolType == 1 ? 'schoolReport' : 'jointSchoolReport'
+}
+
+
+/**
+* 显示确认对话框
+* @param {string} title - 对话框标题
+* @param {function} successCallback - 确认按钮回调函数
+* @param {function|string} [cancelCallback='已取消操作'] - 取消按钮回调函数或提示信息
+*/
+export function confirm(title, successCallback, cancelCallback = '已取消操作') {
+    MessageBox.confirm(title, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+        customClass: 'page_dialog',
+    }).then(successCallback).catch(() => {
+        const type = typeof cancelCallback;
+        if (type === 'function') {
+            cancelCallback();
+            return;
+        } else {
+            info(cancelCallback);
+        }
+    });
+}
+
+
+
+/**
+ * 显示成功消息
+ * @param {string} message - 消息内容
+*/
+export function success(message) {
+    Message({
+        message,
+        type: 'success',
+        duration: 2000
+    });
+}
+
+
+/**
+ * 显示错误消息
+ * @param {string} message - 消息内容
+*/
+export function error(message) {
+    Message({
+        message,
+        type: 'error',
+        duration: 2000
+    });
+}
+
+
+/**
+ * 显示信息消息
+ * @param {string} message - 消息内容
+*/
+export function info(message) {
+    Message({
+        message,
+        type: 'info',
+        duration: 2000
+    });
+}
+
+
+/**
+ * 显示警告消息
+ * @param {string} message - 消息内容
+*/
+export function warning(message) {
+    Message({
+        message,
+        type: 'warning',
+        duration: 2000
+    });
+}

+ 82 - 23
src/views/analysisReport/wrongQuestion/index.vue

@@ -13,12 +13,11 @@
             <div class="right_btn" v-if="errorType !== 1">
                 <el-button size="medium" disabled
                     @click="downloadDialogVisible = true; isVariation = 0">下载错题本</el-button>
-                <el-button type="primary" size="medium"
-                    @click="downloadDialogVisible = true; isVariation = 1">下载个性化提升手册</el-button>
+                <el-button type="primary" size="medium" @click="downLoadPapers">下载个性化提升手册</el-button>
             </div>
 
             <Download :visible.sync="downloadDialogVisible" :examId="examId" :subjectCode="subjectCode"
-                :isVariation="isVariation" />
+                :isVariation="isVariation" :questionList="questionList" />
 
             <template v-if="questionList.length > 0">
                 <div v-for="(question, index) in questionList" :key="question.questionId">
@@ -128,11 +127,19 @@
                                 <div class="flex">
                                     <div class="flex_left">【答&nbsp;&nbsp;&nbsp;&nbsp;案】</div>
                                     <div class="flex_right">
-                                        <template v-if="question.questionData?.answer || question.answerImg">
-                                            <Preview :type="question.sourceType"
-                                                :content="question.questionData?.answer"
-                                                :imgBase64="question.answerImg" />
+                                        <template
+                                            v-if="question.questionData?.answer || question.answerImg || question.answer">
+                                            <template v-if="question.isObjective === 1">
+                                                <div>{{ question.answer }}</div>
+                                            </template>
+
+                                            <template v-else>
+                                                <Preview :type="question.sourceType"
+                                                    :content="question.questionData?.answer"
+                                                    :imgBase64="question.answerImg" />
+                                            </template>
                                         </template>
+
                                         <template v-else>
                                             <div>暂无数据</div>
                                         </template>
@@ -154,16 +161,16 @@
                                 </div>
                             </div>
 
-                            <div class="content" v-if="question.answerShow && !question.parseShow">
-                                <template v-if="question.sourceType === 1 || question.sourceType === 2">
-                                    <template v-if="question.studentAnswer || question.studentAnswerImg">
-                                        <Preview :type="question.sourceType" :content="question.studentAnswer"
-                                            :imgBase64="question.studentAnswerImg" />
-                                    </template>
+                            <div class="content" style="height: 300px;"
+                                v-if="question.answerShow && !question.parseShow">
+                                <template v-if="question.isObjective === 1">
+                                    <div v-if="question.studentAnswer">{{ question.studentAnswer }}</div>
+                                    <div v-else>暂无数据</div>
                                 </template>
 
                                 <template v-else>
-                                    <div>暂无数据</div>
+                                    <PaperImage :imageIndex="index" :scoreFontSize="20" :rtOrWrSize="10"
+                                        :paperImgUrl="picUrl" :drawData="questionVOS" />
                                 </template>
                             </div>
                         </div>
@@ -228,6 +235,7 @@ import {
     queryStudentErrorQuestion,
     markStudentErrorQuestion,
     downloadStudentErrorQuestion,
+    findStudentCard
 } from '../../../http/api/errorQuestion';
 import Download from './Download.vue';
 import { mergeImage } from './loadImg.js'
@@ -235,6 +243,8 @@ import { Loading } from 'element-ui';
 import NoData from './NoData/NoData.vue';
 import KnowledgePoint from './KnowledgePoint.vue';
 import Preview from './Preview.vue';
+import PaperImage from '@/components/PaperImage.vue';
+import { confirm } from '../../../utils/common.js'
 
 export default {
     components: {
@@ -242,6 +252,7 @@ export default {
         NoData,
         KnowledgePoint,
         Preview,
+        PaperImage,
 
     },
 
@@ -267,6 +278,9 @@ export default {
 
             downloadDialogVisible: false,
             isVariation: 0,
+            picUrl: null,
+            questionVOS: [],
+
         };
     },
 
@@ -336,8 +350,34 @@ export default {
 
         ShowAnserAndParse(type, question) {
             if (type === 1) {
-                question.answerShow = !question.answerShow;
-                question.parseShow = false
+                if (question.isObjective === 1) {
+                    question.answerShow = !question.answerShow;
+                    question.parseShow = false
+                    return;
+                }
+
+                findStudentCard({
+                    examId: this.examId,
+                    subjectCode: this.subjectCode,
+                    questionId: question.questionId,
+                }).then(res => {
+                    if (res.code === 200) {
+                        // question.studentAnswer = res.data.studentAnswer;
+                        const data = res.data.pageVOS[0]
+                        this.picUrl = data.picUrl;
+                        this.questionVOS = data.questionVOS.map(item => {
+                            return {
+                                ...item,
+                                samplingPosition: '{"x":195,"y":247,"page":1}'
+                            }
+                        });
+
+                        console.log('questionVOS', this.questionVOS, this.picUrl);
+
+                        question.answerShow = !question.answerShow;
+                        question.parseShow = false
+                    }
+                })
             }
 
             if (type === 2) {
@@ -366,28 +406,23 @@ export default {
                 const processedQuestions = await Promise.all(questionList.map(async (q) => {
                     q.answerShow = false;
                     q.parseShow = false;
-                    const { sourceType, titleCoordinates, answerCoordinates, parseCoordinates, paintingPosition } = q;
+                    const { sourceType, titleCoordinates, answerCoordinates, parseCoordinates } = q;
 
                     if (sourceType === 2) {
                         try {
-                            const [questionImg, answerImg, parseImg, studentAnswerImg] = await Promise.all([
+                            const [questionImg, answerImg, parseImg] = await Promise.all([
                                 mergeImage(this.uploadPaperUrls, titleCoordinates),
                                 mergeImage(this.answerUrls, answerCoordinates),
                                 mergeImage(this.answerUrls, parseCoordinates),
-                                mergeImage(this.answerUrls, paintingPosition),
                             ]);
-
                             q.questionImg = questionImg || '';
                             q.answerImg = answerImg || '';
                             q.parseImg = parseImg || '';
-                            q.studentAnswerImg = studentAnswerImg || '';
                         } catch (e) {
                             // 如果合并过程中某张图失败,记录空字符串并继续,避免阻塞全部渲染
                             q.questionImg = q.questionImg || '';
                             q.answerImg = q.answerImg || '';
                             q.parseImg = q.parseImg || '';
-                            q.studentAnswerImg = q.studentAnswerImg || '';
-                            console.error('mergeImage error', e);
                         }
                     }
 
@@ -434,6 +469,30 @@ export default {
             this.pageParam.pageNum = page;
             await this._queryStudentErrorQuestion();
         },
+
+        hasTuozhan() {
+            // 查看题目中第一个 变式题为空 的题目
+            const questionWithVariation = this.questionList.find(q => !q.variationQuestion);
+
+            if (questionWithVariation) {
+                return false; // 存在题目没有变式题
+            }
+
+            return true; // 所有题目都有变式题
+        },
+
+        downLoadPapers() {
+            const hasVariation = this.hasTuozhan();
+            if (!hasVariation) {
+                confirm('教师还未确认变式题,是否继续下载?', () => {
+                    this.downloadDialogVisible = true;
+                    this.isVariation = 1;
+                })
+            } else {
+                this.downloadDialogVisible = true;
+                this.isVariation = 1;
+            }
+        }
     },
 }
 </script>