|
@@ -68,14 +68,12 @@
|
|
import {
|
|
import {
|
|
getPreUploadFiles,
|
|
getPreUploadFiles,
|
|
getPreUploadFileCount,
|
|
getPreUploadFileCount,
|
|
- saveOutputImage
|
|
|
|
|
|
+ saveOutputImage,
|
|
|
|
+ clearDir
|
|
} from "../../../plugins/imageOcr";
|
|
} from "../../../plugins/imageOcr";
|
|
import setTimeMixins from "../../../mixins/setTimeMixins";
|
|
import setTimeMixins from "../../../mixins/setTimeMixins";
|
|
import db from "../../../plugins/db";
|
|
import db from "../../../plugins/db";
|
|
-const fs = require("fs");
|
|
|
|
-const childProcess = require("child_process");
|
|
|
|
-const util = require("util");
|
|
|
|
-const childProcessExec = util.promisify(childProcess.exec);
|
|
|
|
|
|
+import { evokeScanner } from "../../../plugins/scanner";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "scan-task-dialog",
|
|
name: "scan-task-dialog",
|
|
@@ -166,25 +164,29 @@ export default {
|
|
},
|
|
},
|
|
async evokeScanExe() {
|
|
async evokeScanExe() {
|
|
console.log("唤起扫描仪");
|
|
console.log("唤起扫描仪");
|
|
- const commandStr = `scan -scan -d ${this.GLOBAL.input}`;
|
|
|
|
- const { stdout, stderr } = await childProcessExec(commandStr).catch(
|
|
|
|
- error => {
|
|
|
|
- console.log(error);
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
|
|
+ // console.log(commandStr);
|
|
|
|
+ await evokeScanner(this.GLOBAL.input).catch(error => {
|
|
|
|
+ console.dir(error);
|
|
|
|
+ });
|
|
console.log("扫描仪停止");
|
|
console.log("扫描仪停止");
|
|
this.scanStatus = "PAUSE";
|
|
this.scanStatus = "PAUSE";
|
|
- console.log(stdout, stderr);
|
|
|
|
- },
|
|
|
|
- async confirm() {
|
|
|
|
|
|
+
|
|
|
|
+ // 缓存已扫描的数据
|
|
const res = getPreUploadFiles(this.GLOBAL.input);
|
|
const res = getPreUploadFiles(this.GLOBAL.input);
|
|
if (!res.succeed) {
|
|
if (!res.succeed) {
|
|
this.$message.error(res.errorMsg);
|
|
this.$message.error(res.errorMsg);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ this.scaningImageList.push(...res.data);
|
|
|
|
+
|
|
|
|
+ console.log(this.scaningImageList);
|
|
|
|
+ },
|
|
|
|
+ async confirm() {
|
|
|
|
+ if (!this.scaningImageList.length) {
|
|
|
|
+ this.$message.error("当前没有需要保存的数据!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- this.scaningImageList = res.data;
|
|
|
|
await this.saveScanImage();
|
|
await this.saveScanImage();
|
|
|
|
|
|
const confirm = await this.$confirm(`是否继续扫描?`, "提示", {
|
|
const confirm = await this.$confirm(`是否继续扫描?`, "提示", {
|
|
@@ -249,12 +251,13 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
clearScanList() {
|
|
clearScanList() {
|
|
- for (let i = 0; i < this.scaningImageList.length; i++) {
|
|
|
|
- const item = this.scaningImageList[i];
|
|
|
|
- fs.unlinkSync(item.frontFile);
|
|
|
|
- fs.unlinkSync(item.versoFile);
|
|
|
|
- }
|
|
|
|
|
|
+ // 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|