Przeglądaj źródła

feat: 试卷扫描测试

zhangjie 10 miesięcy temu
rodzic
commit
eff26cb8bb

+ 21 - 7
src/modules/client/components/ManualBindDialog.vue

@@ -2,11 +2,10 @@
   <el-dialog
     :visible.sync="modalIsShow"
     title="手动输入"
-    top="10vh"
-    width="460px"
+    top="10px"
+    width="500px"
     :close-on-click-modal="false"
     :close-on-press-escape="false"
-    :show-close="false"
     append-to-body
     @open="visibleChange"
   >
@@ -14,7 +13,7 @@
       ref="modalFormComp"
       :model="modalForm"
       :rules="rules"
-      label-width="80px"
+      label-width="100px"
       @submit.native.prevent
     >
       <el-form-item prop="studentCode" label="学号:">
@@ -147,6 +146,12 @@ export default {
         return [];
       },
     },
+    task: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
   },
   data() {
     return {
@@ -289,10 +294,19 @@ export default {
     open() {
       this.modalIsShow = true;
     },
+    checkField(field) {
+      return new Promise((resolve, reject) => {
+        this.$refs.modalFormComp.validateField(field, (unvalid) => {
+          if (unvalid) {
+            reject();
+          } else {
+            resolve(true);
+          }
+        });
+      });
+    },
     async searchStudent() {
-      const valid = await this.$refs.modalFormComp
-        .validateField("studentCode")
-        .catch(() => {});
+      const valid = await this.checkField("studentCode").catch(() => {});
       if (!valid) return;
 
       const res = await getStudentInfo({

+ 34 - 19
src/modules/client/components/ScanResultTable.vue

@@ -13,15 +13,17 @@
           @row-dblclick="paperClickHandle"
         >
           <el-table-column width="22" class-name="td-checkbox" align="center">
-            <template slot-scope="props">
+            <template slot-scope="subScope">
               <el-checkbox
-                v-model="props.row.select"
-                @change="selectionChange"
+                v-model="subScope.row.select"
+                @change="paperSelectionChange(scope.row)"
               ></el-checkbox>
             </template>
           </el-table-column>
           <el-table-column label="文件名">
-            <template slot-scope="props"> 第{{ props.$index + 1 }}张 </template>
+            <template slot-scope="subScope">
+              第{{ subScope.$index + 1 }}张
+            </template>
           </el-table-column>
           <el-table-column
             class-name="action-column"
@@ -29,12 +31,12 @@
             align="center"
             width="50"
           >
-            <template slot-scope="props">
+            <template slot-scope="subScope">
               <el-button
                 class="btn-danger"
                 type="text"
                 icon="el-icon-error"
-                @click="toDeletePaper(scope.row, props.row)"
+                @click="toDeletePaper(scope.row, subScope.row)"
               >
               </el-button>
             </template>
@@ -46,7 +48,7 @@
       <template slot-scope="scope">
         <el-checkbox
           v-model="scope.row.select"
-          @change="selectionChange"
+          @change="rowSelectionChange(scope.row)"
         ></el-checkbox>
       </template>
     </el-table-column>
@@ -90,7 +92,7 @@ import { deleteFiles } from "../../../plugins/imageOcr";
 export default {
   name: "scan-result-table",
   props: {
-    datas: {
+    tableData: {
       type: Array,
       default() {
         return [];
@@ -102,25 +104,38 @@ export default {
     },
   },
   data() {
-    return { selectList: [] };
+    return { selectList: [], datas: [] };
   },
   computed: {
     isNormalTab() {
       return this.tab === "normal";
     },
   },
+  watch: {
+    tableData: {
+      immediate: true,
+      handler(val) {
+        if (val) this.datas = val;
+      },
+    },
+    datas(val) {
+      this.$emit("update:tableData", val);
+    },
+  },
   methods: {
     // table action
-    selectionChange() {
+    rowSelectionChange(row) {
+      row.papers.forEach((p) => (p.select = row.select));
+      this.updateSelectList();
+    },
+    paperSelectionChange(row) {
+      const paperSelected = !row.papers.some((p) => !p.select);
+      row.select = paperSelected;
+      this.updateSelectList();
+    },
+    updateSelectList() {
       const selectList = [];
       this.datas.forEach((row) => {
-        if (row.select) {
-          row.papers.forEach((p) => (p.select = true));
-        } else {
-          const paperSelected = !row.papers.some((p) => !p.select);
-          row.select = paperSelected;
-        }
-
         const selectPapers = row.papers.filter((p) => p.select);
         if (selectPapers.length) {
           selectList.push({
@@ -159,7 +174,7 @@ export default {
         (item) => item.studentCode !== row.studentCode
       );
 
-      this.selectionChange();
+      this.updateSelectList();
       this.$emit("delete-paper", selectedFiles);
     },
     async toDeletePaper(row, paper) {
@@ -181,7 +196,7 @@ export default {
         );
       }
 
-      this.selectionChange();
+      this.updateSelectList();
       this.$emit("delete-paper", selectedFiles);
     },
     studentClickHandle(row) {

+ 5 - 4
src/modules/client/views/ScanPaper.vue

@@ -49,7 +49,7 @@
           <scan-result-table
             v-if="isNormalTab"
             ref="scanResultTableRef"
-            :datas="scanStageList"
+            :table-data.sync="scanStageList"
             tab="normal"
             @row-click="rowClickHandle"
             @select-change="selectChange"
@@ -58,7 +58,7 @@
           <scan-result-table
             v-else
             ref="scanResultTableRef"
-            :datas="errorStageList"
+            :table-data.sync="errorStageList"
             tab="error"
             @row-click="rowClickHandle"
             @select-change="selectChange"
@@ -84,6 +84,7 @@
     <manual-bind-dialog
       ref="ManualBindDialog"
       :datas="selectList"
+      :task="task"
       @confirm="bindConfirm"
     ></manual-bind-dialog>
     <!-- SelectBatchNoDialog -->
@@ -511,7 +512,7 @@ export default {
               ...p,
               studentCode: studentInfo.studentCode,
               studentName: studentInfo.studentName,
-              id: `${stageStudent.studentCode}-${randomCode(16)}`,
+              id: `${studentInfo.studentCode}-${randomCode(16)}`,
             };
           });
         })
@@ -557,7 +558,7 @@ export default {
               ...p,
               studentCode: studentInfo.studentCode,
               studentName: studentInfo.studentName,
-              id: `${stageStudent.studentCode}-${randomCode(16)}`,
+              id: `${studentInfo.studentCode}-${randomCode(16)}`,
             };
           });
         })

+ 1 - 1
src/plugins/pQueue.js

@@ -3,7 +3,7 @@ import { objAssign } from "./utils";
 
 export default function usePQueue(customOption = {}) {
   const defaultOption = {
-    concurrency: 6,
+    concurrency: 5,
     autoStart: true,
   };
   const option = objAssign(defaultOption, customOption);