Răsfoiți Sursa

日志记录

zhangjie 2 ani în urmă
părinte
comite
943f982e58
1 a modificat fișierele cu 12 adăugiri și 9 ștergeri
  1. 12 9
      src/modules/client/components/ScanTaskProcessDialog.vue

+ 12 - 9
src/modules/client/components/ScanTaskProcessDialog.vue

@@ -76,6 +76,8 @@ import {
 import setTimeMixins from "../../../mixins/setTimeMixins";
 import setTimeMixins from "../../../mixins/setTimeMixins";
 import db from "../../../plugins/db";
 import db from "../../../plugins/db";
 import { evokeScanner } from "../../../plugins/scanner";
 import { evokeScanner } from "../../../plugins/scanner";
+import log4js from "@/plugins/logger";
+const logger = log4js.getLogger("scan");
 
 
 export default {
 export default {
   name: "scan-task-dialog",
   name: "scan-task-dialog",
@@ -127,11 +129,13 @@ export default {
       this.realScanCount = 0;
       this.realScanCount = 0;
     },
     },
     visibleChange() {
     visibleChange() {
+      logger.info(`00进入扫描`);
       this.initData();
       this.initData();
     },
     },
     close() {
     close() {
       this.modalIsShow = false;
       this.modalIsShow = false;
       this.$emit("on-close");
       this.$emit("on-close");
+      logger.info(`99退出扫描`);
     },
     },
     open() {
     open() {
       this.modalIsShow = true;
       this.modalIsShow = true;
@@ -159,7 +163,7 @@ export default {
           userId: this.user.id
           userId: this.user.id
         });
         });
       }
       }
-
+      logger.info(`01开始扫描`);
       this.scaningImageList = [];
       this.scaningImageList = [];
       this.scanStatus = "START";
       this.scanStatus = "START";
       this.getInitFile();
       this.getInitFile();
@@ -167,26 +171,28 @@ export default {
       this.evokeScanExe();
       this.evokeScanExe();
     },
     },
     async continueTask() {
     async continueTask() {
+      logger.info(`01继续扫描`);
       this.scanStatus = "START";
       this.scanStatus = "START";
       this.getInitFile();
       this.getInitFile();
 
 
       this.evokeScanExe();
       this.evokeScanExe();
     },
     },
     async evokeScanExe() {
     async evokeScanExe() {
-      console.log("唤起扫描仪");
+      logger.info("02唤起扫描仪");
       // console.log(commandStr);
       // console.log(commandStr);
       await evokeScanner(this.GLOBAL.input).catch(error => {
       await evokeScanner(this.GLOBAL.input).catch(error => {
         console.error(error);
         console.error(error);
       });
       });
-      console.log("扫描仪停止");
       this.scanStatus = "PAUSE";
       this.scanStatus = "PAUSE";
 
 
       // 缓存已扫描的数据
       // 缓存已扫描的数据
       const res = getPreUploadFiles(this.GLOBAL.input);
       const res = getPreUploadFiles(this.GLOBAL.input);
       if (!res.succeed) {
       if (!res.succeed) {
+        logger.error(`03扫描仪停止,故障:${res.errorMsg}`);
         this.$message.error(res.errorMsg);
         this.$message.error(res.errorMsg);
         return;
         return;
       }
       }
+      logger.info(`03扫描仪停止,扫描数:${res.data.length}`);
       this.scaningImageList.push(...res.data);
       this.scaningImageList.push(...res.data);
       // console.log(this.scaningImageList);
       // console.log(this.scaningImageList);
       renamePreUploadJsonFile(this.GLOBAL.input);
       renamePreUploadJsonFile(this.GLOBAL.input);
@@ -196,8 +202,9 @@ export default {
         this.$message.error("当前没有需要保存的数据!");
         this.$message.error("当前没有需要保存的数据!");
         return;
         return;
       }
       }
-
+      logger.info(`04-1开始保存数据`);
       await this.saveScanImage();
       await this.saveScanImage();
+      logger.info(`04-2保存数据结束`);
 
 
       const confirm = await this.$confirm(`是否继续扫描?`, "提示", {
       const confirm = await this.$confirm(`是否继续扫描?`, "提示", {
         type: "warning"
         type: "warning"
@@ -257,15 +264,11 @@ export default {
 
 
         await db.saveUploadInfo(fileInfo).catch(err => {
         await db.saveUploadInfo(fileInfo).catch(err => {
           console.error(err);
           console.error(err);
+          logger.error(`04-1保存数据错误,${err}`);
         });
         });
       }
       }
     },
     },
     clearScanList() {
     clearScanList() {
-      // for (let i = 0; i < this.scaningImageList.length; i++) {
-      //   const item = this.scaningImageList[i];
-      //   fs.unlinkSync(item.frontFile);
-      //   fs.unlinkSync(item.versoFile);
-      // }
       this.scaningImageList = [];
       this.scaningImageList = [];
       clearDir(this.GLOBAL.input);
       clearDir(this.GLOBAL.input);
     }
     }