|
@@ -29,15 +29,20 @@
|
|
|
<div class="scan-image-list">
|
|
|
<div
|
|
|
v-for="item in scanHistoryList"
|
|
|
- :key="item"
|
|
|
+ :key="item.url"
|
|
|
class="scan-image-item"
|
|
|
- @click="toViewPaper(item)"
|
|
|
>
|
|
|
- <img :src="item" />
|
|
|
+ <el-image
|
|
|
+ :src="item.url"
|
|
|
+ fit="contain"
|
|
|
+ lazy
|
|
|
+ @click="toViewPaper(item)"
|
|
|
+ ></el-image>
|
|
|
+ <p v-if="item.name" :title="item.name">{{ item.name }}</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div slot="footer">
|
|
|
+ <div class="text-center" slot="footer">
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
:loading="scanStatus !== 'INIT'"
|
|
@@ -97,6 +102,7 @@ export default {
|
|
|
SCAN: "扫描中",
|
|
|
SAVING: "保存数据中",
|
|
|
},
|
|
|
+ user: this.$ls.get("user", {}),
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -138,17 +144,22 @@ export default {
|
|
|
logger.error(`03扫描仪停止,故障:${res.errorMsg}`);
|
|
|
this.$message.error(res.errorMsg);
|
|
|
this.scanStatus = "INIT";
|
|
|
+ clearDir(this.GLOBAL.input);
|
|
|
return;
|
|
|
}
|
|
|
logger.info(`03扫描仪停止,扫描数:${res.data.length}`);
|
|
|
this.scanStatus = "SAVING";
|
|
|
- await this.saveScanImage(res.data).catch(() => {
|
|
|
+ await this.saveScanImage(res.data).catch((e) => {
|
|
|
+ console.dir(e);
|
|
|
this.$message.error("保存数据失败,请重新扫描!");
|
|
|
logger.error(`保存数据失败,请重新扫描!`);
|
|
|
});
|
|
|
clearDir(this.GLOBAL.input);
|
|
|
this.scanStatus = "INIT";
|
|
|
await this.getScanHistory();
|
|
|
+
|
|
|
+ this.curPaper = {};
|
|
|
+ this.$refs.SimpleImagePreview.close();
|
|
|
},
|
|
|
// scan relate
|
|
|
async getScanHistory() {
|
|
@@ -157,17 +168,22 @@ export default {
|
|
|
isFormal: this.task.isFormal ? 1 : 0,
|
|
|
taskId: this.task.id,
|
|
|
})
|
|
|
- .catch(() => {});
|
|
|
+ .catch((e) => {
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
if (!res) return;
|
|
|
|
|
|
this.scanHistoryList = [];
|
|
|
res.forEach((item) => {
|
|
|
- this.scanHistoryList.push(item.frontOriginImgPath);
|
|
|
- this.scanHistoryList.push(item.versoOriginImgPath);
|
|
|
+ this.scanHistoryList.push({
|
|
|
+ url: "file:///" + item.frontOriginImgPath,
|
|
|
+ name: `${item.studentCode}-1`,
|
|
|
+ });
|
|
|
+ this.scanHistoryList.push({
|
|
|
+ url: "file:///" + item.versoOriginImgPath,
|
|
|
+ name: `${item.studentCode}-2`,
|
|
|
+ });
|
|
|
});
|
|
|
-
|
|
|
- this.curPaper = {};
|
|
|
- this.$refs.SimpleImagePreview.close();
|
|
|
},
|
|
|
async saveScanImage(imageList) {
|
|
|
logger.info(`04-1开始保存数据`);
|
|
@@ -176,12 +192,13 @@ export default {
|
|
|
const ouputImageList = saveOutputImage(
|
|
|
[files.frontFile, files.versoFile],
|
|
|
{
|
|
|
- taskId: this.task.id,
|
|
|
+ courseCode: this.task.courseCode,
|
|
|
}
|
|
|
);
|
|
|
const fileInfo = {
|
|
|
taskId: this.task.id,
|
|
|
schoolId: this.task.schoolId,
|
|
|
+ semesterId: this.task.semesterId,
|
|
|
examId: this.task.examId,
|
|
|
courseCode: this.task.courseCode,
|
|
|
courseName: this.task.courseName,
|
|
@@ -189,6 +206,7 @@ export default {
|
|
|
versoOriginImgPath: ouputImageList[1],
|
|
|
isFormal: this.task.isFormal ? 1 : 0,
|
|
|
studentCode: "",
|
|
|
+ ocrArea: "",
|
|
|
clientUserId: this.user.id,
|
|
|
clientUsername: this.user.loginName,
|
|
|
clientUserLoginTime: this.user.loginTime,
|
|
@@ -202,7 +220,6 @@ export default {
|
|
|
console.error(err);
|
|
|
logger.error(`04-2条码解析失败,${err}`);
|
|
|
});
|
|
|
- console.log(num);
|
|
|
fileInfo.studentCode = num || "";
|
|
|
fileInfo.ocrArea = JSON.stringify(this.ocrArea);
|
|
|
}
|
|
@@ -218,20 +235,20 @@ export default {
|
|
|
logger.info(`04-2保存数据结束`);
|
|
|
},
|
|
|
// image-preview
|
|
|
- toViewPaper(imgUrl) {
|
|
|
- this.curPaper = { url: imgUrl };
|
|
|
+ toViewPaper(imgItem) {
|
|
|
+ this.curPaper = { ...imgItem };
|
|
|
this.$refs.SimpleImagePreview.open();
|
|
|
},
|
|
|
toPrevPaper() {
|
|
|
const curPaperIndex = this.scanHistoryList.findIndex(
|
|
|
- (item) => item === this.curPaper.url
|
|
|
+ (item) => item.url === this.curPaper.url
|
|
|
);
|
|
|
if (curPaperIndex <= 0) return;
|
|
|
this.curPaper = this.scanHistoryList[curPaperIndex - 1];
|
|
|
},
|
|
|
toNextPaper() {
|
|
|
const curPaperIndex = this.scanHistoryList.findIndex(
|
|
|
- (item) => item === this.curPaper.url
|
|
|
+ (item) => item.url === this.curPaper.url
|
|
|
);
|
|
|
if (curPaperIndex >= this.scanHistoryList.length - 1) return;
|
|
|
this.curPaper = this.scanHistoryList[curPaperIndex + 1];
|