Browse Source

新需求

zhangjie 2 years ago
parent
commit
19659b817b

+ 24 - 7
src/modules/client/components/ScanTaskProcessDialog.vue

@@ -53,13 +53,16 @@
       <el-button
         v-if="scanStatus === 'PAUSE'"
         type="primary"
-        @click="continueTask"
-        >继续扫描</el-button
-      >
-      <el-button v-if="scanStatus === 'PAUSE'" type="primary" @click="confirm"
+        :loading="submiting"
+        @click="confirm"
         >确认</el-button
       >
-      <el-button v-if="scanStatus === 'PAUSE'" @click="cancel">取消</el-button>
+      <el-button
+        v-if="scanStatus === 'PAUSE'"
+        :loading="submiting"
+        @click="cancel"
+        >取消</el-button
+      >
     </div>
   </el-dialog>
 </template>
@@ -96,6 +99,7 @@ export default {
     return {
       modalIsShow: false,
       loading: false,
+      submiting: false,
       user: this.$ls.get("user", { id: "" }),
       scanStatus: "INIT", // INIT:初始状态,START:已开始,PAUSE:已暂停
       modalForm: {
@@ -217,9 +221,20 @@ export default {
         this.$message.error("实扫张数与预扫张数不一致!");
         return;
       }
+      if (this.submiting) return;
+      this.submiting = true;
+
       logger.info(`04-1开始保存数据`);
-      await this.saveScanImage();
+      let res = true;
+      await this.saveScanImage().catch(() => {
+        this.submiting = false;
+        res = false;
+      });
       logger.info(`04-2保存数据结束`);
+      if (!res) {
+        this.$message.error("保存数据错误!");
+        return;
+      }
 
       const confirm = await this.$confirm(`是否继续扫描?`, "提示", {
         type: "warning"
@@ -290,11 +305,13 @@ export default {
           console.log(num);
           fileInfo.examNumber = num || "";
         }
-
+        let res = true;
         await db.saveUploadInfo(fileInfo).catch(err => {
+          res = false;
           console.error(err);
           logger.error(`04-1保存数据错误,${err}`);
         });
+        if (!res) return Promise.reject();
       }
     },
     clearScanList() {

+ 23 - 1
src/modules/client/views/TaskManage.vue

@@ -64,9 +64,18 @@
           label="学生数"
           min-width="100"
         ></el-table-column>
+        <el-table-column
+          prop="studentCount"
+          label="实扫/已上传(采集)"
+          min-width="100"
+        >
+          <span slot-scope="scope">
+            {{ scope.row.scanCount }} / {{ scope.row.uploadCount }}
+          </span>
+        </el-table-column>
         <el-table-column
           prop="scanCount"
-          label="已扫描数量"
+          label="已上传(后台)"
           min-width="100"
         ></el-table-column>
         <el-table-column
@@ -215,11 +224,24 @@ export default {
       const data = await taskListPage(datas);
       this.dataList = data.records;
       this.total = data.total;
+      this.updateTaskCount();
     },
     toPage(page) {
       this.current = page;
       this.getList();
     },
+    async updateTaskCount() {
+      for (let i = 0; i < this.dataList.length; i++) {
+        const task = this.dataList[i];
+        const scanCount = await db.countScanList({ taskId: task.id });
+        this.$set(task, "scanCount", scanCount);
+        const uploadCount = await db.countScanList({
+          taskId: task.id,
+          isUpload: 1
+        });
+        this.$set(task, "uploadCount", uploadCount);
+      }
+    },
     selectMenu(curTab) {
       this.cacheData[this.curTab] = {
         current: this.current,