Prechádzať zdrojové kódy

feat: 试卷类型修改

zhangjie 8 mesiacov pred
rodič
commit
813157d04e

+ 4 - 6
src/render/store/modules/dataCheck/index.ts

@@ -61,8 +61,8 @@ export const useDataCheckStore = defineStore("dataCheck", {
       const params = {
         examId: this.curPage.examId,
         examNumber: this.curStudent.examNumber,
-        paperNumber: this.curPage.paperNumber,
-        pageIndex: this.curPage.pageIndex + 1,
+        paperNumber: data.field === "PAPER_TYPE" ? 1 : this.curPage.paperNumber,
+        pageIndex: data.field === "PAPER_TYPE" ? 1 : this.curPage.pageIndex + 1,
         subjectCode: this.curStudent.subjectCode,
         ...data,
       };
@@ -81,12 +81,10 @@ export const useDataCheckStore = defineStore("dataCheck", {
         this.curPage.sheetUri = uri;
       }
     },
-    modifyPaperType(data: UpdatePaperType) {
+    modifyPaperType(paperType: string) {
       if (!this.curStudent) return;
-      const { paperType, pageIndex, paperIndex } = data;
       this.curStudent.paperType = paperType || "#";
-      this.curStudent.papers[paperIndex].pages[pageIndex].paperType.result =
-        paperType;
+      this.curStudent.papers[0].pages[0].paperType.result = paperType;
     },
   },
   persist: {

+ 4 - 0
src/render/views/AbsentCheck/CheckAction.vue

@@ -300,6 +300,10 @@ function onExport() {
     message.error("请选择科目");
     return;
   }
+  if (!searchModel.examStatus || searchModel.examStatus === "OK") {
+    message.error("请选择异常条件");
+    return;
+  }
   exportTypeDialogRef.value?.open();
 }
 

+ 5 - 1
src/render/views/DataCheck/CheckAction.vue

@@ -131,7 +131,7 @@
                 <a-button class="m-r-8px" type="primary" @click="onCustomSearch"
                   >查询</a-button
                 >
-                <a-button @click="onExport('custom')">导出</a-button>
+                <!-- <a-button @click="onExport('custom')">导出</a-button> -->
               </a-form-item>
             </a-col>
           </a-row>
@@ -430,6 +430,10 @@ function onExport(type: string) {
     message.error("请选择科目");
     return;
   }
+  if (!searchDataCheckType.value) {
+    message.error("请选择条件");
+    return;
+  }
   actionType.value = type;
   exportTypeDialogRef.value?.open();
 }

+ 23 - 27
src/render/views/DataCheck/ModifyPaperType.vue

@@ -9,16 +9,11 @@
     <template #title> 更改卷型号 </template>
 
     <a-form ref="formRef" :label-col="{ style: { width: '90px' } }">
+      <a-form-item label="最终结果">
+        <span class="color-brand">{{ areaResultDisplay }}</span>
+      </a-form-item>
       <a-form-item label="识别结果">
-        <a-input
-          v-if="editing"
-          v-model:value="paperType"
-          style="width: 100px"
-        />
-        <span v-else class="color-brand">{{ areaResult || "#" }}</span>
-        <qm-button class="ml-15px" @click="toggleEditing">{{
-          editing ? "取消" : "编辑"
-        }}</qm-button>
+        <span class="color-brand">{{ ocrResult }}</span>
       </a-form-item>
       <a-form-item label="识别图片">
         <div class="paper-type-img">
@@ -41,6 +36,12 @@
           >
             {{ item }}
           </li>
+          <li
+            :class="['type-item', { 'is-active': paperType === '?' }]"
+            @click="selectPaperType('?')"
+          >
+            异常
+          </li>
         </ul>
       </a-form-item>
     </a-form>
@@ -48,7 +49,7 @@
 </template>
 
 <script setup lang="ts">
-import { onMounted, ref, watch } from "vue";
+import { computed, onMounted, ref, watch } from "vue";
 import { message } from "ant-design-vue";
 
 import { getBaseDataConfig } from "@/ap/baseDataConfig";
@@ -60,7 +61,6 @@ defineOptions({
 });
 
 const dataCheckStore = useDataCheckStore();
-const editing = ref(false);
 /* modal */
 const { visible, open, close } = useModal();
 defineExpose({ open, close });
@@ -68,6 +68,7 @@ defineExpose({ open, close });
 const props = defineProps<{
   areaImg: string;
   areaResult: string;
+  ocrResult: string;
 }>();
 
 const emit = defineEmits(["confirm"]);
@@ -76,9 +77,14 @@ const paperTypeBarcodeContent = ref<string[]>([]);
 const userStore = useUserStore();
 const paperType = ref("");
 
+const areaResultDisplay = computed(() => {
+  if (props.areaResult === "#") return "空";
+  if (props.areaResult === "?") return "异常";
+  return props.areaResult;
+});
+
 async function getConfig() {
   const res = await getBaseDataConfig({ examId: userStore.curExam.id });
-  // paperTypeBarcodeContent.value = res.paperTypeBarcodeContent || [];
   paperTypeBarcodeContent.value =
     (res.paperTypeBarcodeContent || []).find((item: any) => {
       return item.code == dataCheckStore.curStudent?.subjectCode;
@@ -88,23 +94,13 @@ async function getConfig() {
 function selectPaperType(val: string) {
   paperType.value = val;
 }
-let oldPaperType: string = "";
-const toggleEditing = () => {
-  if (!editing.value) {
-    oldPaperType = paperType.value;
-  } else {
-    paperType.value = oldPaperType;
-  }
-  editing.value = !editing.value;
-};
+
 function confirm() {
-  // if (!paperType.value) {
-  //   message.error("请选择卷型");
-  //   return;
-  // }
+  if (!paperType.value) {
+    message.error("请选择卷型");
+    return;
+  }
   emit("confirm", paperType.value);
-  editing.value = false;
-  oldPaperType = "";
   close();
 }
 

+ 40 - 26
src/render/views/DataCheck/QuestionPanel.vue

@@ -15,12 +15,10 @@
       </a-descriptions-item>
       <a-descriptions-item label="卷型号" :span="6">
         <template v-if="simple">
-          {{ info.paperType || "#" }}
+          {{ paperTypeDisplay }}
         </template>
         <template v-else>
-          <a-button class="ant-gray m-r-4px">{{
-            info.paperType || "#"
-          }}</a-button>
+          <a-button class="ant-gray m-r-4px">{{ paperTypeDisplay }}</a-button>
           <a-button v-if="paperTypeArea && editable" @click="onEditPaperType">
             <template #icon><SwapOutlined /></template>
           </a-button>
@@ -95,6 +93,7 @@
     ref="modifyPaperTypeRef"
     :area-img="paperTypeImg"
     :area-result="paperTypeResult"
+    :ocr-result="paperTypeOrcResult"
     @confirm="paperTypeModified"
   />
 </template>
@@ -230,50 +229,56 @@ const modifyPaperTypeRef = ref();
 const paperTypeArea = ref<AreaSize | null>(null);
 const paperTypeImg = ref("");
 const paperTypeResult = ref("");
-async function onEditPaperType() {
+const paperTypeOrcResult = ref("");
+const paperTypeType = ref("");
+const paperTypeDisplay = computed(() => {
+  if (paperTypeResult.value === "#") return "空";
+  if (paperTypeResult.value === "?") return "异常";
+  return paperTypeResult.value;
+});
+function onEditPaperType() {
   if (!dataCheckStore.curPage) return;
-
-  if (paperTypeArea.value) {
-    paperTypeImg.value = await getSliceFileUrl(
-      dataCheckStore.curPage.sheetUri,
-      paperTypeArea.value
-    );
-    paperTypeResult.value = dataCheckStore.curPage.paperType.result;
-  } else {
-    paperTypeImg.value = "";
-  }
   modifyPaperTypeRef.value?.open();
 }
 const curPage = computed(() => dataCheckStore.curPage);
 async function paperTypeModified(paperType: string) {
-  if (!dataCheckStore.curPage) return;
-  dataCheckStore.modifyPaperType({
-    paperIndex: curPage.value?.paperIndex as number,
-    pageIndex: curPage.value?.pageIndex as number,
-    paperType: paperType || "#",
-  });
+  if (!dataCheckStore.curStudent) return;
+
   await dataCheckStore.updateField({
     field: "PAPER_TYPE",
     value: JSON.stringify({
-      ...dataCheckStore.curPage.paperType,
+      type: paperTypeType.value,
       result: paperType || "#",
     }),
   });
-  dataCheckStore.curPage.paperType.result = paperType;
+  dataCheckStore.modifyPaperType(paperType);
+  paperTypeResult.value = paperType;
 }
 
 watch(
-  () => dataCheckStore.curPage?.recogData,
-  (val) => {
+  () => dataCheckStore.curStudent,
+  async (val) => {
     paperTypeArea.value = null;
     if (!val) return;
 
-    const regdata = parseRecogData(val);
+    // 只取第一张第一页的数据
+    const curStudentFirstPage = val.papers[0]?.pages[0];
+    if (!curStudentFirstPage) return;
+
+    paperTypeResult.value = curStudentFirstPage.paperType.result;
+    paperTypeType.value = curStudentFirstPage.paperType.type;
+    const recogData = curStudentFirstPage.recogData;
+    const regdata = parseRecogData(recogData);
     if (!regdata) return;
 
+    // console.log(regdata);
+    paperTypeOrcResult.value = regdata.paperType.content;
+    if (!paperTypeOrcResult.value) paperTypeOrcResult.value = "空";
+
     const rect = regdata.paperType.rect || null;
     if (!rect) {
       paperTypeArea.value = null;
+      paperTypeImg.value = "";
       return;
     }
 
@@ -286,6 +291,15 @@ watch(
           h: rect[3],
         }
       : null;
+
+    if (paperTypeArea.value) {
+      paperTypeImg.value = await getSliceFileUrl(
+        curStudentFirstPage.sheetUri,
+        paperTypeArea.value
+      );
+    } else {
+      paperTypeImg.value = "";
+    }
   },
   {
     immediate: true,