Browse Source

进度计算逻辑优化

dengshaobo 1 month ago
parent
commit
910589379b

+ 103 - 1
src/views/exam/abnormal/abnormal.vue

@@ -67,7 +67,7 @@
                         <div class="header_right el_button">
                             <i class="iconfont icon_nishizhen" @click="AnticlockwiseImage()"></i>
                             <i class="iconfont icon_shunshizhen" @click="ClockwiseImage()"></i>
-                            <el-button type="primary" class="right_button_editor" @click="MarkBlankPage()">标记为空白页</el-button>
+                            <!-- <el-button type="primary" class="right_button_editor" @click="MarkBlankPage()">标记为空白页</el-button> -->
                             <el-button type="primary" class="right_button_editor" style="margin-left: 0px;" @click="SavePositionImage()">保存</el-button>
                         </div>
                     </div>
@@ -714,10 +714,112 @@ const GetCutStudentPosition = (points: any[]) => {
 const AnticlockwiseImage = () => {
     // TODO: 逆时针旋转
     console.log('逆时针旋转')
+    rotationAngle.value -= 90; // 减少90度(逆时针旋转)
+    let rotateValue = rotationAngle.value % 360;
+    // 如果角度为负数,转换为0-360度之间的正值
+    if (rotateValue < 0) {
+        rotateValue += 360;
+    }
+    rotationAngle.value = rotateValue;
+    console.log("打印旋转角度", rotationAngle.value);
+    console.log("打印当前试卷地址", currentPaperUrl.value);
+    SetPaperUrl(rotateValue);
+}
+
+// 设置试卷地址(处理OSS图片旋转参数)
+const SetPaperUrl = (rotateValue: number) => {
+    let newUrl = '';
+    
+    if(rotateValue === 0) {
+        // 如果旋转角度为0,移除所有旋转参数
+        if(currentPaperUrl.value.includes('x-oss-process=image')) {
+            if(currentPaperUrl.value.includes('rotate')) {
+                // 存在旋转参数,移除旋转参数
+                if (currentPaperUrl.value.includes('?')) {
+                    // 如果有多个参数,只移除rotate部分
+                    newUrl = currentPaperUrl.value.replace(/([&?])x-oss-process=image\/rotate,\d+&?/, '$1');
+                    // 清理多余的&符号
+                    newUrl = newUrl.replace(/\?&/, '?').replace(/&&/, '&');
+                    // 如果最后是?或&,则移除
+                    newUrl = newUrl.replace(/[?&]$/, '');
+                    
+                    // 如果移除rotate后只剩下x-oss-process=image,则完全移除整个参数
+                    if(newUrl.includes('x-oss-process=image') && newUrl.split('?')[1] === '') {
+                        newUrl = newUrl.split('?')[0];
+                    }
+                } else {
+                    // 如果只有x-oss-process参数,则完全移除
+                    newUrl = currentPaperUrl.value.split('?')[0];
+                }
+            } else {
+                // 存在x-oss-process=image但不存在旋转参数,直接使用原URL
+                newUrl = currentPaperUrl.value;
+            }
+        } else {
+            // 不存在图片处理参数,直接使用原URL
+            newUrl = currentPaperUrl.value;
+        }
+    } else {
+        // 旋转角度不为0的情况
+        if(currentPaperUrl.value.includes('x-oss-process=image')) {
+            // 存在图片处理参数
+            if(currentPaperUrl.value.includes('rotate')) {
+                // 存在旋转参数,替换旋转参数
+                if (currentPaperUrl.value.includes('?')) {
+                    // 如果有多个参数,只替换rotate部分
+                    newUrl = currentPaperUrl.value.replace(/([&?])x-oss-process=image\/rotate,\d+&?/, '$1');
+                    // 清理多余的&符号
+                    newUrl = newUrl.replace(/\?&/, '?').replace(/&&/, '&');
+                    // 如果最后是?或&,则移除
+                    newUrl = newUrl.replace(/[?&]$/, '');
+                    // 重新添加旋转参数
+                    newUrl = newUrl + '?x-oss-process=image/rotate,' + rotateValue;
+                } else {
+                    // 如果只有x-oss-process参数,则完全移除后重新添加
+                    newUrl = currentPaperUrl.value.split('?')[0];
+                    newUrl = newUrl + '?x-oss-process=image/rotate,' + rotateValue;
+                }
+            } else {
+                // 存在x-oss-process=image但不存在旋转参数,在现有参数基础上追加旋转参数
+                if(currentPaperUrl.value.includes('?')) {
+                    newUrl = currentPaperUrl.value + '&x-oss-process=image/rotate,' + rotateValue;
+                } else {
+                    newUrl = currentPaperUrl.value + '?x-oss-process=image/rotate,' + rotateValue;
+                }
+            }
+        } else {
+            // 不存在图片处理参数,追加参数
+            if(currentPaperUrl.value.includes('?')) {
+                // URL中已存在其他参数
+                newUrl = currentPaperUrl.value + '&x-oss-process=image/rotate,' + rotateValue;
+            } else {
+                // URL中没有参数
+                newUrl = currentPaperUrl.value + '?x-oss-process=image/rotate,' + rotateValue;
+            }
+        }
+    }
+    
+    currentPaperUrl.value = newUrl;
+    console.log("打印旋转后的地址", currentPaperUrl.value);
+    
+    if(currentPaperList.value[currentPaperIndex.value]) {
+        currentPaperList.value[currentPaperIndex.value].recognizeUrl = newUrl;
+        currentPaperList.value[currentPaperIndex.value].rotate = rotateValue;
+    }
 }
 const ClockwiseImage = () => {
     // TODO: 顺时针旋转
     console.log('顺时针旋转')
+    rotationAngle.value += 90; // 增加90度(顺时针旋转)
+    let rotateValue = rotationAngle.value % 360;
+    // 如果角度超过360度,取模
+    if (rotateValue >= 360) {
+        rotateValue = rotateValue % 360;
+    }
+    rotationAngle.value = rotateValue;
+    console.log("打印旋转角度", rotationAngle.value);
+    console.log("打印当前试卷地址", currentPaperUrl.value);
+    SetPaperUrl(rotateValue);
 }
 
 // 10. 标记为空白页

+ 2 - 6
src/views/exam/components/addStudent.vue

@@ -99,7 +99,7 @@
           prop="registrationTypeCode"
         >
           <el-select
-            v-model="addStudentData.registrationTypeCode"
+            v-model="addStudentData.registrationTypeName"
             @change="ChangeStudentType"
             placeholder="请选择"
           >
@@ -452,11 +452,7 @@ defineExpose({
 })
 
 onMounted(() => {
-  if (props.selectSchoolId) {
-    GetClassListData()
-  } else {
-    GetClassListData(0)
-  }
+  GetClassListData()
 })
 </script>
 

+ 1 - 0
src/views/exam/components/scanButton.vue

@@ -34,6 +34,7 @@ const anim = ref(null);
 
 // 格式化进度显示
 const FormatProcess = (process) => {
+    console.log("打印进度值", process, props.quekao, props.yichang);
     if (process === null || process === undefined || isNaN(process) || !isFinite(process)) {
         return 0;
     }

+ 2 - 2
src/views/exam/scanDetail.vue

@@ -418,8 +418,8 @@ const GetScanDetailList = async () => {
 const GetScanDetailImage = async () => {
     const params = {
       examSubjectId: examSubjectId.value,
-      batchNo:paramInfo.value.batchNo,//批次号
-      statusStr:paramInfo.value.statusStr,//状态
+      batchNo: paramInfo.value.batchNo === 'all' ? '' : paramInfo.value.batchNo,//批次号
+      statusStr: paramInfo.value.statusStr === 'all' ? '' : paramInfo.value.statusStr,//状态
       nameCode:paramInfo.value.keyWord,//搜索条件 姓名 考号
       schoolId: 0,//单校 0 
       pageNum:pageInfo.value.pageNum,//当前页码

+ 6 - 7
src/views/exam/scanList.vue

@@ -359,20 +359,20 @@ const scanDataInfo=ref({
 
 });//扫描返回的数据信息
 
-//扫描进度  
-const scanProcess=computed(() => {
 
-    return Math.floor((scanDataInfo.value.scannedNum+scanDataInfo.value.examMissNum)/scanDataInfo.value.examTotal)*100;
+
+const scanProcess= computed(() => {
+    console.log("打印扫描数据",scanDataInfo);
+    return Math.floor(((scanDataInfo.value.scannedNum+scanDataInfo.value.examMissNum)/scanDataInfo.value.examTotal)*100);
 });
 
-//缺考进度
 const scanQuekao=computed(() => {
-    return Math.floor((scanDataInfo.value.examMissNum)/scanDataInfo.value.examTotal)*100;
+    return Math.floor((scanDataInfo.value.examMissNum/scanDataInfo.value.examTotal)*100);
 });
 //异常进度
 const scanYichang=computed(() => {
     
-    return Math.floor((scanDataInfo.value.abnormalNum)/scanDataInfo.value.examTotal)*100;
+    return Math.floor((scanDataInfo.value.abnormalNum/scanDataInfo.value.examTotal)*100);
 });
 //刷新
 const Refresh = () => {
@@ -979,7 +979,6 @@ const GetScanBatchList=async()=>{
 }
 
 
-
 //计算高度的函数
 const CalculateTableHeight = () => {
   // nextTick 确保 DOM 更新后再获取尺寸

+ 1 - 1
src/views/layout/components/header.vue

@@ -159,7 +159,7 @@ const loginOutFn = async () => {
     //增加环境判断 
     if(import.meta.env.MODE == 'development') {
       // window.location.href = 'http://localhost:8080'
-      router.push('/login')
+      router.push('/')
     }
     else if(import.meta.env.MODE == 'test')
     {