Jelajahi Sumber

feat: 扫描试卷调整

zhangjie 11 bulan lalu
induk
melakukan
d33007760e
2 mengubah file dengan 57 tambahan dan 12 penghapusan
  1. 13 0
      src/modules/client/views/ScanOther.vue
  2. 44 12
      src/modules/client/views/ScanPaper.vue

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

@@ -0,0 +1,13 @@
+<template>
+  <div class="scan-other">scan-other</div>
+</template>
+
+<script>
+export default {
+  name: "scan-other",
+  data() {
+    return {};
+  },
+  methods: {},
+};
+</script>

+ 44 - 12
src/modules/client/views/ScanPaper.vue

@@ -8,11 +8,11 @@
         <el-button :disabled="!hasSelectedData" type="primary" @click="toBind"
           >重新绑定</el-button
         >
-        <el-button :disabled="!canSave" type="danger" @click="clearStage"
+        <el-button :disabled="!canClear" type="danger" @click="clearStage"
           >清空</el-button
         >
         <el-button
-          :disabled="!canSave"
+          :disabled="!canSave || isNormalTab"
           :loading="saving"
           type="primary"
           @click="toSave"
@@ -21,7 +21,7 @@
         <el-button
           type="primary"
           :loading="scanStatus === 'SCAN'"
-          :disabled="!canScan"
+          :disabled="!canScan || isNormalTab"
           @click="toScan"
         >
           {{ statusDesc[scanStatus] }}
@@ -64,7 +64,7 @@
             @delete-paper="deletePaperHandle"
           ></scan-result-table>
         </div>
-        <div class="scan-result-foot">
+        <div v-if="isNormalTab" class="scan-result-foot">
           共{{ studentCount }}人,{{ paperCount }}张图片
         </div>
       </div>
@@ -94,6 +94,7 @@ import {
   getPreUploadFiles,
   saveOutputImage,
   clearDir,
+  deleteFiles,
   decodeImageCode,
   getDirScanFile,
 } from "../../../plugins/imageOcr";
@@ -147,10 +148,17 @@ export default {
   computed: {
     ...mapState("client", ["ocrArea"]),
     canSave() {
-      return this.scanStatus === "FINISH" && this.scanStageList.length;
+      return (
+        this.scanStatus === "FINISH" &&
+        this.normalCount > 0 &&
+        this.errorCount === 0
+      );
     },
     canScan() {
-      return this.scanStageList.length <= this.maxCacheCount;
+      return this.errorCount + this.normalCount <= this.maxCacheCount;
+    },
+    canClear() {
+      return this.studentCount > 0;
     },
     hasSelectedData() {
       return Boolean(this.selectList.length);
@@ -208,7 +216,6 @@ export default {
       logger.info(`99退出扫描`);
     },
     switchTab(tab) {
-      this.$refs.scanResultTableRef.clearSelection();
       this.curTab = tab;
       this.selectList = [];
     },
@@ -543,13 +550,38 @@ export default {
       });
     },
     async clearStage() {
-      const res = await this.$confirm(`确定要清空数据吗?`, "警告", {
-        type: "warning",
-      }).catch(() => {});
+      const name = this.isNormalTab ? "正常" : "异常";
+      const res = await this.$confirm(
+        `确定要清空所有【${name}】数据吗?`,
+        "警告",
+        {
+          type: "warning",
+        }
+      ).catch(() => {});
       if (res !== "confirm") return;
 
-      this.initData();
-      this.clearFiles();
+      if (this.isNormalTab) {
+        const files = this.scanStageList
+          .map((row) =>
+            row.papers.map((p) => [p.frontOriginImgPath, p.versoOriginImgPath])
+          )
+          .flat(2);
+        deleteFiles(files);
+        this.scanStageList = [];
+      } else {
+        const files = this.errorStageList
+          .map((row) =>
+            row.papers.map((p) => [p.frontOriginImgPath, p.versoOriginImgPath])
+          )
+          .flat(2);
+        deleteFiles(files);
+        this.errorStageList = [];
+      }
+
+      this.curPagePapers = [];
+      this.curPagePaperIndex = 0;
+      this.curPagePaper = { url: "" };
+
       logger.info(`99数据清空`);
       this.$message.success("数据已清空!");
     },