文件大小限制(MB)、超时时间限制

master
wanglei 1 year ago
parent 6630069d9b
commit 42115b5bd7

@ -8,7 +8,7 @@ export function collectSaves(data) {
'Content-Type': 'multipart/form-data',
repeatSubmit: false
},
timeout: 100000000,
timeout: 120000,
method: 'post',
data: data
})
@ -19,6 +19,7 @@ export function collectRecongnize(data) {
return request({
url: '/dangan/collect/recongnize',
method: 'post',
timeout: 180000,
data: data
})
}

@ -90,7 +90,7 @@
</div>
<div v-show="upload.id" style="width: 360px;margin-left: 20px;">
<el-upload :show-file-list="false" :fileSize="100"
<el-upload :show-file-list="false"
ref="upload"
action="#"
accept="image/*"
@ -101,7 +101,7 @@
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">只能上传图片且不超过100MB</div>
<div class="el-upload__tip" slot="tip">只能上传图片且不超过{{ upload.fileSize }}MB</div>
</el-upload>
<ul class="el-upload-list el-upload-list--text" style="max-height:200px;overflow-y:scroll;padding: 15px;">
@ -254,6 +254,7 @@ export default {
muName: undefined,
//
upload: {
fileSize: 300, //MB
loading: false,
//
open: false,
@ -490,11 +491,20 @@ 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) => {
formData.append('files', this.dataURLtoFile(item.base64Str, item.fileName));
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);
@ -510,17 +520,30 @@ export default {
}).catch(err => {
this.smwj.loading = false;
});
}else {
this.$alert(`上传文件大小不能超过 ${this.upload.fileSize} MB!`, `提示`, {
type: 'warning'
});
}
}else {
this.$alert(`请先开始扫描!`, `提示`, {
type: 'warning'
});
}
}else {
if(this.fileList.length>0){
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);
@ -529,6 +552,7 @@ export default {
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;
@ -536,6 +560,13 @@ export default {
}).catch(err => {
this.upload.loading = false;
});
}else {
this.$alert(`上传文件大小不能超过 ${this.upload.fileSize} MB!`, `提示`, {
type: 'warning'
});
}
}else {
this.$alert(`请先上传图片!`, `提示`, {
type: 'warning'
@ -603,11 +634,21 @@ 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)'
});
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;
@ -688,21 +729,6 @@ export default {
border-radius: 10px;
overflow: hidden;
}
.myProgress{
position: fixed;
top:0;
left:0;
z-index: 10000;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.7);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 20px;
color: white;
}
.sm_col{
display: flex;
justify-content: space-between;

Loading…
Cancel
Save