浏览代码

feat: 调试正常扫描

zhangjie 10 月之前
父节点
当前提交
9ef5f78150

+ 43 - 1
src/assets/styles/pages.scss

@@ -414,6 +414,7 @@
   .scan-head {
     flex-shrink: 0;
     flex-grow: 0;
+    align-items: center;
   }
 
   .scan-body {
@@ -422,6 +423,7 @@
     display: flex;
     justify-content: space-between;
     align-items: stretch;
+    margin: 0 16px;
 
     .scan-result {
       width: 400px;
@@ -448,7 +450,7 @@
         border-bottom-right-radius: $--border-radius;
       }
 
-      &-table {
+      &-body {
         flex-grow: 2;
         overflow: hidden;
         background-color: #fff;
@@ -468,3 +470,43 @@
     }
   }
 }
+.scan-result-table {
+  .el-table__cell {
+    padding: 5px 0;
+    .cell {
+      padding-left: 5px !important;
+      padding-right: 5px !important;
+    }
+  }
+  .td-checkbox,
+  .td-expand {
+    .cell {
+      padding-left: 0 !important;
+      padding-right: 0 !important;
+    }
+  }
+  td.action-column {
+    padding-left: 5px !important;
+    padding-right: 5px !important;
+  }
+  .el-button--text {
+    font-size: 12px !important;
+  }
+  .el-table__expanded-cell {
+    padding-left: 22px;
+    border-bottom: 0;
+    background-color: $--color-background !important;
+
+    .el-table,
+    tr {
+      background-color: $--color-background !important;
+    }
+
+    .cell {
+      line-height: 18px;
+    }
+    .el-icon-error {
+      font-size: 14px;
+    }
+  }
+}

+ 4 - 2
src/modules/client/components/OcrAreaSetDialog.vue

@@ -49,6 +49,7 @@ import Cropper from "cropperjs";
 import db from "@/plugins/db";
 import { getPreUploadFiles, clearDir } from "../../../plugins/imageOcr";
 import { evokeScanner } from "../../../plugins/scanner";
+import { getStageDir } from "@/plugins/env";
 
 export default {
   name: "ocr-area-set",
@@ -60,6 +61,7 @@ export default {
       spinStyle: {},
       ocrArea: {},
       curImageUrl: "",
+      stageDir: getStageDir(),
     };
   },
   methods: {
@@ -85,7 +87,7 @@ export default {
       const ocrArea = await db.getDict("ocrArea", "").catch(() => {});
       this.ocrArea = ocrArea ? JSON.parse(ocrArea) : {};
 
-      const res = getPreUploadFiles(this.GLOBAL.input);
+      const res = getPreUploadFiles(this.GLOBAL.input, true);
       console.log(res);
       if (!res.succeed) {
         this.$message.error(res.errorMsg);
@@ -145,7 +147,7 @@ export default {
         this.cropper.destroy();
         this.cropper = false;
       }
-      clearDir(this.GLOBAL.input);
+      clearDir(this.stageDir);
     },
   },
   beforeDestroy() {

+ 30 - 11
src/modules/client/components/ScanResultTable.vue

@@ -1,9 +1,18 @@
 <template>
-  <el-table :data="datas" @row-click="studentClickHandle">
-    <el-table-column type="expand">
+  <el-table
+    class="scan-result-table"
+    :data="datas"
+    @row-dblclick="studentClickHandle"
+  >
+    <el-table-column type="expand" class-name="td-expand" width="22">
       <template slot-scope="scope">
-        <el-table :data="scope.row.papers" @row-click="paperClickHandle">
-          <el-table-column width="55" align="center">
+        <el-table
+          :data="scope.row.papers"
+          :show-header="false"
+          class="scan-result-expand-table"
+          @row-dblclick="paperClickHandle"
+        >
+          <el-table-column width="22" class-name="td-checkbox" align="center">
             <template slot-scope="props">
               <el-checkbox
                 v-model="props.row.select"
@@ -14,21 +23,26 @@
           <el-table-column label="文件名">
             <template slot-scope="props"> 第{{ props.$index + 1 }}张 </template>
           </el-table-column>
-          <el-table-column class-name="action-column" label="操作" width="60">
+          <el-table-column
+            class-name="action-column"
+            label="操作"
+            align="center"
+            width="50"
+          >
             <template slot-scope="props">
               <el-button
                 class="btn-danger"
                 type="text"
+                icon="el-icon-error"
                 @click="toDeletePaper(scope.row, props.row)"
               >
-                删除
               </el-button>
             </template>
           </el-table-column>
         </el-table>
       </template>
     </el-table-column>
-    <el-table-column width="55" align="center">
+    <el-table-column width="22" class-name="td-checkbox" align="center">
       <template slot-scope="scope">
         <el-checkbox
           v-model="scope.row.select"
@@ -39,19 +53,24 @@
     <el-table-column
       prop="studentCode"
       label="学号"
-      width="120"
+      :width="isNormalTab ? 120 : undefined"
     ></el-table-column>
     <el-table-column
       v-if="isNormalTab"
       prop="studentName"
       label="姓名"
     ></el-table-column>
-    <el-table-column prop="paperCount" label="张数" width="60">
+    <el-table-column prop="paperCount" align="center" label="张数" width="50">
       <template slot-scope="scope">
         {{ scope.row.papers.length }}
       </template>
     </el-table-column>
-    <el-table-column class-name="action-column" label="操作" width="60">
+    <el-table-column
+      class-name="action-column"
+      align="center"
+      label="操作"
+      width="50"
+    >
       <template slot-scope="scope">
         <el-button
           class="btn-danger"
@@ -87,7 +106,7 @@ export default {
   },
   computed: {
     isNormalTab() {
-      return this.curTab === "normal";
+      return this.tab === "normal";
     },
   },
   methods: {

+ 1 - 0
src/modules/client/views/ScanOther.vue

@@ -171,6 +171,7 @@ export default {
   },
   beforeDestroy() {
     this.stopLoopScaningFile();
+    this.clearFiles();
   },
   methods: {
     initData() {

+ 13 - 11
src/modules/client/views/ScanPaper.vue

@@ -12,7 +12,7 @@
           >清空</el-button
         >
         <el-button
-          :disabled="!canSave || isNormalTab"
+          :disabled="!canSave"
           :loading="saving"
           type="primary"
           @click="toSave"
@@ -21,7 +21,7 @@
         <el-button
           type="primary"
           :loading="scanStatus === 'SCAN'"
-          :disabled="!canScan || isNormalTab"
+          :disabled="!canScan"
           @click="toScan"
         >
           {{ statusDesc[scanStatus] }}
@@ -42,15 +42,15 @@
             size="medium"
             :type="curTab === 'error' ? 'danger' : 'default'"
             @click="switchTab('error')"
-            >异常
-            <span class="color-danger">[{{ errorCount }}]</span></el-button
+            >异常 <span>[{{ errorCount }}]</span></el-button
           >
         </div>
-        <div class="scan-result-table">
+        <div class="scan-result-body">
           <scan-result-table
             v-if="isNormalTab"
             ref="scanResultTableRef"
             :datas="scanStageList"
+            tab="normal"
             @row-click="rowClickHandle"
             @select-change="selectChange"
             @delete-paper="deletePaperHandle"
@@ -59,6 +59,7 @@
             v-else
             ref="scanResultTableRef"
             :datas="errorStageList"
+            tab="error"
             @row-click="rowClickHandle"
             @select-change="selectChange"
             @delete-paper="deletePaperHandle"
@@ -201,6 +202,7 @@ export default {
   },
   beforeDestroy() {
     this.stopLoopScaningFile();
+    this.clearFiles();
   },
   methods: {
     initData() {
@@ -630,10 +632,10 @@ export default {
       this.curPaperIndex = this.curPapers.indexOf(this.curPaper.url);
     },
     // image-preview
-    rowClickHandle({ curPapers, curPagePaperIndex }) {
+    rowClickHandle({ curPapers, curPaperIndex }) {
       this.curPapers = curPapers;
-      this.curPaperIndex = curPagePaperIndex;
-      this.setCurPaper(curPagePaperIndex);
+      this.curPaperIndex = curPaperIndex;
+      this.setCurPaper(curPaperIndex);
     },
     clearViewPapers() {
       this.curPapers = [];
@@ -641,21 +643,21 @@ export default {
       this.curPaper = { url: "" };
     },
     setCurPaper(index) {
-      this.curPaper = { url: this.curPapers[index] };
+      this.curPaper = { url: `file:///${this.curPapers[index]}` };
     },
     toPrevPaper() {
       if (this.curPaperIndex <= 0) {
         this.$message.error("没有上一页了");
         return;
       }
-      this.setCurPaper(this.curPaperIndex - 1);
+      this.setCurPaper(--this.curPaperIndex);
     },
     toNextPaper() {
       if (this.curPaperIndex >= this.curPapers.length - 1) {
         this.$message.error("没有下一页了");
         return;
       }
-      this.setCurPaper(this.curPaperIndex + 1);
+      this.setCurPaper(++this.curPaperIndex);
     },
   },
 };

+ 2 - 2
src/plugins/imageOcr.js

@@ -249,8 +249,8 @@ export function getDirScanFile(dir) {
  */
 
 export function decodeImageCodeMac(imgPath) {
-  // 以400001-1.jpg名称为例
-  return path.basename(imgPath).split("-")[0];
+  // 以400001_1.jpg名称为例
+  return path.basename(imgPath).split("_")[0];
 }
 
 /**