From 992769362d3042ce2587c676bf4957093036762d Mon Sep 17 00:00:00 2001 From: wanglei Date: Sat, 6 Jul 2024 15:38:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=97=B6=E6=8E=A5=E6=94=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=9C=80=E5=A4=A7=E6=95=B0=E3=80=81=E5=8D=95=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=9B=BE=E7=89=87=E6=9C=80=E5=A4=A7=E6=95=B0=E9=99=90?= =?UTF-8?q?=E5=88=B6=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/dangan/collection/index.vue | 204 ++++++++++-------- 1 file changed, 114 insertions(+), 90 deletions(-) diff --git a/dangan-ui/src/views/dangan/collection/index.vue b/dangan-ui/src/views/dangan/collection/index.vue index c751509..c68bfb5 100644 --- a/dangan-ui/src/views/dangan/collection/index.vue +++ b/dangan-ui/src/views/dangan/collection/index.vue @@ -227,11 +227,13 @@ import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import { getCabinetTree } from "@/api/dangan/cabinet"; import { collectSaves, collectRecongnize, reRecongnize } from "@/api/dangan/collection"; +import { listTask } from "@/api/dangan/task"; import '@/utils/WebScan'; export default { name: "Collection", components: {Treeselect}, + dicts: ['total_task', 'tatal_task_pic'], data() { return { tsVisible: false, @@ -490,87 +492,87 @@ export default { }, // 确认上传文件提交 submitFiles(type) { - if(type===1){ - - if(this.smwj.list.length>0){ - const formData = new FormData(); - let fileSize = 0; - this.smwj.list.forEach((item) => { - item.file = this.dataURLtoFile(item.base64Str, item.fileName); - fileSize += item.file.size; - formData.append('files', item.file); - }); - console.log(22222, fileSize/1024/1024); - - // 文件最大限制 - if(fileSize/1024/1024 < this.upload.fileSize){ - const DaPicturesRecard = {} - DaPicturesRecard.muId = this.dangAnNode.key; - DaPicturesRecard.muPath = this.getAllLabels(this.dangAnNode); - DaPicturesRecard.ywType = this.dangAnNode.data.ywType; - DaPicturesRecard.wlsjId = this.smwj.wlsjNode.key; - DaPicturesRecard.wlsjPath = this.getAllLabels(this.smwj.wlsjNode); - formData.append('picRecard', new Blob([JSON.stringify(DaPicturesRecard)], {type: 'application/json',})); - this.smwj.loading = true; - collectSaves(formData).then(response => { - this.pictureRecard = response.data; - this.smwj.open = false; - this.smwj.loading = false; - }).catch(err => { - this.smwj.loading = false; - }); - }else { - this.$alert(`上传文件大小不能超过 ${this.upload.fileSize} MB!`, `提示`, { - type: 'warning' - }); - } + if (type === 1) { - }else { + if (this.smwj.list.length === 0) { this.$alert(`请先开始扫描!`, `提示`, { type: 'warning' }); + return; } - }else { - if(this.fileList.length>0){ - const formData = new FormData(); - let fileSize = 0; - this.fileList.forEach((file) => { - fileSize += file.size; - formData.append('files', file); - }); + const formData = new FormData(); + let fileSize = 0; + this.smwj.list.forEach((item) => { + item.file = this.dataURLtoFile(item.base64Str, item.fileName); + fileSize += item.file.size; + formData.append('files', item.file); + }); - // 文件最大限制 - if(fileSize/1024/1024 < this.upload.fileSize){ - - const DaPicturesRecard = {} - DaPicturesRecard.muId = this.dangAnNode.key; - DaPicturesRecard.muPath = this.getAllLabels(this.dangAnNode); - DaPicturesRecard.ywType = this.dangAnNode.data.ywType; - DaPicturesRecard.wlsjId = this.upload.wlsjNode.key; - DaPicturesRecard.wlsjPath = this.getAllLabels(this.upload.wlsjNode); - formData.append('picRecard', new Blob([JSON.stringify(DaPicturesRecard)], {type: 'application/json',})); - this.upload.loading = true; - - collectSaves(formData).then(response => { - this.pictureRecard = response.data; - this.upload.open = false; - this.upload.loading = false; - }).catch(err => { - this.upload.loading = false; - }); + // 文件最大限制 + if (fileSize / 1024 / 1024 < this.upload.fileSize) { + const DaPicturesRecard = {} + DaPicturesRecard.muId = this.dangAnNode.key; + DaPicturesRecard.muPath = this.getAllLabels(this.dangAnNode); + DaPicturesRecard.ywType = this.dangAnNode.data.ywType; + DaPicturesRecard.wlsjId = this.smwj.wlsjNode.key; + DaPicturesRecard.wlsjPath = this.getAllLabels(this.smwj.wlsjNode); + formData.append('picRecard', new Blob([JSON.stringify(DaPicturesRecard)], {type: 'application/json',})); + this.smwj.loading = true; + collectSaves(formData).then(response => { + this.pictureRecard = response.data; + this.smwj.open = false; + this.smwj.loading = false; + }).catch(err => { + this.smwj.loading = false; + }); + } else { + this.$alert(`上传文件大小不能超过 ${this.upload.fileSize} MB!`, `提示`, { + type: 'warning' + }); + } - }else { - this.$alert(`上传文件大小不能超过 ${this.upload.fileSize} MB!`, `提示`, { - type: 'warning' - }); - } + } else { - }else { + if (this.fileList.length === 0) { this.$alert(`请先上传图片!`, `提示`, { type: 'warning' }); + return; + } + + const formData = new FormData(); + let fileSize = 0; + this.fileList.forEach((file) => { + fileSize += file.size; + formData.append('files', file); + }); + + // 文件最大限制 + if (fileSize / 1024 / 1024 < this.upload.fileSize) { + + const DaPicturesRecard = {} + DaPicturesRecard.muId = this.dangAnNode.key; + DaPicturesRecard.muPath = this.getAllLabels(this.dangAnNode); + DaPicturesRecard.ywType = this.dangAnNode.data.ywType; + DaPicturesRecard.wlsjId = this.upload.wlsjNode.key; + DaPicturesRecard.wlsjPath = this.getAllLabels(this.upload.wlsjNode); + formData.append('picRecard', new Blob([JSON.stringify(DaPicturesRecard)], {type: 'application/json',})); + this.upload.loading = true; + + collectSaves(formData).then(response => { + this.pictureRecard = response.data; + this.upload.open = false; + this.upload.loading = false; + }).catch(err => { + this.upload.loading = false; + }); + + } else { + this.$alert(`上传文件大小不能超过 ${this.upload.fileSize} MB!`, `提示`, { + type: 'warning' + }); } } }, @@ -617,7 +619,11 @@ export default { this.checkAll = checkAll }, // OCR识别 - OCRRecognition(){ + async OCRRecognition(){ + + let tatal_task_pic = this.dict.type.tatal_task_pic; + let total_task = this.dict.type.total_task; + this.checkLength = 0; let arr = []; let singeOrDouble = 0 @@ -633,33 +639,51 @@ export default { this.checkLength = arr.length; - if(arr.length>0){ - - const loading = this.$loading({ - lock: true, - text: 'Loading', - spinner: 'el-icon-loading', - background: 'rgba(0, 0, 0, 0.7)' + if(arr.length === 0){ + this.$alert(`请先选择需要识别的档案!`, `提示`, { + type: 'warning' }); + return; + } - collectRecongnize(arr).then(response => { - this.pictureRecard = []; - this.checkAll = false; - this.$modal.msgSuccess(response.msg); - loading.close(); - }).catch((err)=>{ - loading.close(); - console.log(123,err); - if(err.taskId){ - this.taskId = err.taskId; - this.tsVisible = true; - } + if(this.checkLength > tatal_task_pic[0].value){ + this.$alert(`单任务图片最大数是【${tatal_task_pic[0].value}】!`, `提示`, { + type: 'warning' }); - }else { - this.$alert(`请先选择需要识别的档案!`, `提示`, { + return; + } + + let total1 = await listTask({status: '1'}).then(response => { + return response.total; + }); + + if(total1 > total_task[0].value || total1 == total_task[0].value){ + this.$alert(`同时接收任务最大数【${total_task[0].value}】,请稍后再试!`, `提示`, { type: 'warning' }); + return; } + + const loading = this.$loading({ + lock: true, + text: 'Loading', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }); + + collectRecongnize(arr).then(response => { + this.pictureRecard = []; + this.checkAll = false; + this.$modal.msgSuccess(response.msg); + loading.close(); + }).catch((err)=>{ + loading.close(); + if(err.taskId){ + this.taskId = err.taskId; + this.tsVisible = true; + } + }); + }, // 暂不处理继续采集 onZbqljxcj(){