|
@@ -44,8 +44,8 @@
|
|
<div class="task-body">
|
|
<div class="task-body">
|
|
<div class="task-body-item task-org">
|
|
<div class="task-body-item task-org">
|
|
<scan-area-steps
|
|
<scan-area-steps
|
|
- v-if="curTask.filepath && modalIsShow && curCollectConfig"
|
|
|
|
- :image-url="curTask.filepath"
|
|
|
|
|
|
+ v-if="curTask.originImgPath && modalIsShow && curCollectConfig"
|
|
|
|
+ :image-url="curTask.originImgPath"
|
|
:cur-setting="curCollectConfig"
|
|
:cur-setting="curCollectConfig"
|
|
:key="curTask.key"
|
|
:key="curTask.key"
|
|
@on-finished="finished"
|
|
@on-finished="finished"
|
|
@@ -55,16 +55,13 @@
|
|
<div class="task-body-item task-finally">
|
|
<div class="task-body-item task-finally">
|
|
<div class="task-finally-body">
|
|
<div class="task-finally-body">
|
|
<img
|
|
<img
|
|
- v-if="curTaskImagesPath"
|
|
|
|
|
|
+ v-if="curTask.sliceImgPath"
|
|
class="img-contain"
|
|
class="img-contain"
|
|
- :src="curTaskImagesPath"
|
|
|
|
|
|
+ :src="curTask.sliceImgPath"
|
|
alt="裁切图"
|
|
alt="裁切图"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
- <div
|
|
|
|
- v-if="curTaskImagesPath && !curTask.isFinished"
|
|
|
|
- class="task-action box-justify"
|
|
|
|
- >
|
|
|
|
|
|
+ <div v-if="curTask.sliceImgPath" class="task-action box-justify">
|
|
<h5>处理结果</h5>
|
|
<h5>处理结果</h5>
|
|
<Button
|
|
<Button
|
|
type="primary"
|
|
type="primary"
|
|
@@ -89,10 +86,11 @@ import {
|
|
updateCropperTaskDetail,
|
|
updateCropperTaskDetail,
|
|
updateCropperTaskFinishedCount
|
|
updateCropperTaskFinishedCount
|
|
} from "../../plugins/db";
|
|
} from "../../plugins/db";
|
|
-import { saveCropperImage } from "./taskUtils";
|
|
|
|
|
|
+import { saveCropperImage, downloadOriginImg } from "./taskUtils";
|
|
import { formatDate, randomCode } from "../../plugins/utils";
|
|
import { formatDate, randomCode } from "../../plugins/utils";
|
|
-const path = require("path");
|
|
|
|
-const fs = require("fs");
|
|
|
|
|
|
+import { getPaperInfo } from "./api";
|
|
|
|
+// const path = require("path");
|
|
|
|
+// const fs = require("fs");
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "cropper-task-detail-dialog",
|
|
name: "cropper-task-detail-dialog",
|
|
@@ -119,7 +117,6 @@ export default {
|
|
taskCount: 0,
|
|
taskCount: 0,
|
|
finishedCount: 0,
|
|
finishedCount: 0,
|
|
taskProgress: 0,
|
|
taskProgress: 0,
|
|
- curTaskImagesPath: null,
|
|
|
|
loading: false
|
|
loading: false
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -175,55 +172,56 @@ export default {
|
|
const scrollTop = Math.max(0, taskDom.offsetTop - 84);
|
|
const scrollTop = Math.max(0, taskDom.offsetTop - 84);
|
|
document.getElementById("task-list").scrollTop = scrollTop;
|
|
document.getElementById("task-list").scrollTop = scrollTop;
|
|
},
|
|
},
|
|
- getTaskOutputFilePath(taskPath) {
|
|
|
|
- // TODO:
|
|
|
|
- const paperPath = taskPath.replace(this.cropperTask.inputDir, "");
|
|
|
|
- const types = ["sheet", "images", "thumbs"];
|
|
|
|
- return types.map(item =>
|
|
|
|
- path.join(this.cropperTask.outputDir, item, paperPath)
|
|
|
|
- );
|
|
|
|
|
|
+ async getOriginImg(paperInfo) {
|
|
|
|
+ if (paperInfo.originImgPath) return paperInfo.originImgPath;
|
|
|
|
+
|
|
|
|
+ const pInfo = await getPaperInfo({
|
|
|
|
+ workId: paperInfo.workId,
|
|
|
|
+ subjectId: paperInfo.subjectId,
|
|
|
|
+ examNumber: paperInfo.examNumber
|
|
|
|
+ }).catch(() => {});
|
|
|
|
+ if (!pInfo) {
|
|
|
|
+ this.$Message.error("获取原图失败,请重新尝试!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.curTask.paperId = paperInfo.id;
|
|
|
|
+
|
|
|
|
+ const outputOriginPath = await downloadOriginImg({
|
|
|
|
+ ...paperInfo,
|
|
|
|
+ url: pInfo.imgSrc
|
|
|
|
+ }).catch(() => {});
|
|
|
|
+ if (!outputOriginPath) {
|
|
|
|
+ this.$Message.error("下载原图失败,请重新尝试!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.curTask.originImgPath = outputOriginPath;
|
|
},
|
|
},
|
|
async toDo(task) {
|
|
async toDo(task) {
|
|
- // TODO:操作流程与正常采集过程保持一致,需要点时间整理,数据表需要再调整。
|
|
|
|
- const [sheetPath, imagesPath, thumbsPath] = this.getTaskOutputFilePath(
|
|
|
|
- task.filepath
|
|
|
|
- );
|
|
|
|
this.curTask = {
|
|
this.curTask = {
|
|
...task,
|
|
...task,
|
|
- sheetPath,
|
|
|
|
- imagesPath,
|
|
|
|
- thumbsPath,
|
|
|
|
- key: randomCode(),
|
|
|
|
- compressRate: this.GLOBAL.compressRate
|
|
|
|
|
|
+ key: randomCode()
|
|
};
|
|
};
|
|
- this.curTaskImagesPath = fs.existsSync(this.curTask.imagesPath)
|
|
|
|
- ? this.curTask.imagesPath
|
|
|
|
- : null;
|
|
|
|
|
|
+ await this.getOriginImg(task);
|
|
|
|
|
|
// 在没有裁切图的情况下,自动根据已保存的设置信息生成裁切图。
|
|
// 在没有裁切图的情况下,自动根据已保存的设置信息生成裁切图。
|
|
- if (!this.curTaskImagesPath && this.curCollectConfig["codeArea"]) {
|
|
|
|
- let res = await saveCropperImage(
|
|
|
|
- this.curTask,
|
|
|
|
- this.curCollectConfig
|
|
|
|
- ).catch(() => {
|
|
|
|
- this.loading = false;
|
|
|
|
- });
|
|
|
|
- if (!res) {
|
|
|
|
- this.$Message.error("保存图片失败,请重新尝试!");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.curTaskImagesPath = this.curTask.imagesPath;
|
|
|
|
|
|
+ if (!this.curTask.sliceImgPath && this.curCollectConfig["codeArea"]) {
|
|
|
|
+ this.loading = true;
|
|
|
|
+ let res = await this.saveCurImage().catch(() => {});
|
|
|
|
+ this.loading = false;
|
|
|
|
+ if (!res) return;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async curTaskFinished(setting) {
|
|
async curTaskFinished(setting) {
|
|
await updateCropperTaskDetail({
|
|
await updateCropperTaskDetail({
|
|
id: this.curTask.id,
|
|
id: this.curTask.id,
|
|
cropperSet: JSON.stringify(setting),
|
|
cropperSet: JSON.stringify(setting),
|
|
- sheetPath: this.curTask.sheetPath,
|
|
|
|
- imagesPath: this.curTask.imagesPath,
|
|
|
|
- thumbsPath: this.curTask.thumbsPath,
|
|
|
|
|
|
+ originImgPath: this.curTask.originImgPath,
|
|
|
|
+ formalImgPath: this.curTask.formalImgPath,
|
|
|
|
+ sliceImgPath: this.curTask.sliceImgPath,
|
|
isFinished: 1,
|
|
isFinished: 1,
|
|
|
|
+ isUpload: 0,
|
|
updateTime: formatDate()
|
|
updateTime: formatDate()
|
|
});
|
|
});
|
|
await this.updateProgress();
|
|
await this.updateProgress();
|
|
@@ -233,13 +231,26 @@ export default {
|
|
|
|
|
|
return true;
|
|
return true;
|
|
},
|
|
},
|
|
|
|
+ async saveCurImage() {
|
|
|
|
+ let res = await saveCropperImage(
|
|
|
|
+ this.curTask,
|
|
|
|
+ this.curCollectConfig
|
|
|
|
+ ).catch(() => {});
|
|
|
|
+ if (!res) {
|
|
|
|
+ return Promise.reject();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.curTask.sliceImgPath = res.outputSlicelPath;
|
|
|
|
+ this.curTask.formalImgPath = res.outputFormalPath;
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
async finished(setting) {
|
|
async finished(setting) {
|
|
if (this.loading) return;
|
|
if (this.loading) return;
|
|
this.loading = true;
|
|
this.loading = true;
|
|
|
|
|
|
- this.curTaskImagesPath = null;
|
|
|
|
this.curCollectConfig = setting;
|
|
this.curCollectConfig = setting;
|
|
- let res = await saveCropperImage(this.curTask, setting).catch(() => {
|
|
|
|
|
|
+
|
|
|
|
+ let res = await this.saveCurImage().catch(() => {
|
|
this.loading = false;
|
|
this.loading = false;
|
|
});
|
|
});
|
|
if (!res) {
|
|
if (!res) {
|
|
@@ -247,8 +258,6 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- this.curTaskImagesPath = this.curTask.imagesPath;
|
|
|
|
-
|
|
|
|
res = await this.curTaskFinished(setting).catch(() => {});
|
|
res = await this.curTaskFinished(setting).catch(() => {});
|
|
this.loading = false;
|
|
this.loading = false;
|
|
if (!res) {
|
|
if (!res) {
|
|
@@ -256,19 +265,7 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- this.$Modal.confirm({
|
|
|
|
- content: "操作成功,是否进行下一个任务?",
|
|
|
|
- onOk: () => {
|
|
|
|
- const nextTask = this.taskList.find(item => !item.isFinished);
|
|
|
|
- if (!nextTask) {
|
|
|
|
- this.$Message.success("当前任务已全部结束");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.toDo(nextTask);
|
|
|
|
- this.scrollTaskList(this.curTask.id);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ this.toNextTask();
|
|
},
|
|
},
|
|
async toComfirmAndNext() {
|
|
async toComfirmAndNext() {
|
|
if (this.loading) return;
|
|
if (this.loading) return;
|
|
@@ -283,6 +280,9 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.toNextTask();
|
|
|
|
+ },
|
|
|
|
+ toNextTask() {
|
|
const nextTask = this.taskList.find(item => !item.isFinished);
|
|
const nextTask = this.taskList.find(item => !item.isFinished);
|
|
if (!nextTask) {
|
|
if (!nextTask) {
|
|
this.$Message.success("当前任务已全部结束");
|
|
this.$Message.success("当前任务已全部结束");
|