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

master
wanglei 1 year ago
parent 6630069d9b
commit 42115b5bd7

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

@ -90,7 +90,7 @@
</div> </div>
<div v-show="upload.id" style="width: 360px;margin-left: 20px;"> <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" ref="upload"
action="#" action="#"
accept="image/*" accept="image/*"
@ -101,7 +101,7 @@
> >
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div> <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> </el-upload>
<ul class="el-upload-list el-upload-list--text" style="max-height:200px;overflow-y:scroll;padding: 15px;"> <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, muName: undefined,
// //
upload: { upload: {
fileSize: 300, //MB
loading: false, loading: false,
// //
open: false, open: false,
@ -490,52 +491,82 @@ export default {
// //
submitFiles(type) { submitFiles(type) {
if(type===1){ if(type===1){
if(this.smwj.list.length>0){ if(this.smwj.list.length>0){
const formData = new FormData(); const formData = new FormData();
let fileSize = 0;
this.smwj.list.forEach((item) => { 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;
const DaPicturesRecard = {} formData.append('files', item.file);
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;
}); });
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'
});
}
}else { }else {
this.$alert(`请先开始扫描!`, `提示`, { this.$alert(`请先开始扫描!`, `提示`, {
type: 'warning' type: 'warning'
}); });
} }
}else { }else {
if(this.fileList.length>0){ if(this.fileList.length>0){
const formData = new FormData(); const formData = new FormData();
let fileSize = 0;
this.fileList.forEach((file) => { this.fileList.forEach((file) => {
fileSize += file.size;
formData.append('files', file); formData.append('files', file);
}); });
const DaPicturesRecard = {}
DaPicturesRecard.muId = this.dangAnNode.key; //
DaPicturesRecard.muPath = this.getAllLabels(this.dangAnNode); if(fileSize/1024/1024 < this.upload.fileSize){
DaPicturesRecard.ywType = this.dangAnNode.data.ywType;
DaPicturesRecard.wlsjId = this.upload.wlsjNode.key; const DaPicturesRecard = {}
DaPicturesRecard.wlsjPath = this.getAllLabels(this.upload.wlsjNode); DaPicturesRecard.muId = this.dangAnNode.key;
formData.append('picRecard', new Blob([JSON.stringify(DaPicturesRecard)],{ type: 'application/json', })); DaPicturesRecard.muPath = this.getAllLabels(this.dangAnNode);
this.upload.loading = true; DaPicturesRecard.ywType = this.dangAnNode.data.ywType;
collectSaves(formData).then(response => { DaPicturesRecard.wlsjId = this.upload.wlsjNode.key;
this.pictureRecard = response.data; DaPicturesRecard.wlsjPath = this.getAllLabels(this.upload.wlsjNode);
this.upload.open = false; formData.append('picRecard', new Blob([JSON.stringify(DaPicturesRecard)], {type: 'application/json',}));
this.upload.loading = false; this.upload.loading = true;
}).catch(err=>{
this.upload.loading = false; 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'
});
}
}else { }else {
this.$alert(`请先上传图片!`, `提示`, { this.$alert(`请先上传图片!`, `提示`, {
type: 'warning' type: 'warning'
@ -603,11 +634,21 @@ export default {
this.checkLength = arr.length; this.checkLength = arr.length;
if(arr.length>0){ 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 => { collectRecongnize(arr).then(response => {
this.pictureRecard = []; this.pictureRecard = [];
this.checkAll = false; this.checkAll = false;
this.$modal.msgSuccess(response.msg); this.$modal.msgSuccess(response.msg);
loading.close();
}).catch((err)=>{ }).catch((err)=>{
loading.close();
console.log(123,err); console.log(123,err);
if(err.taskId){ if(err.taskId){
this.taskId = err.taskId; this.taskId = err.taskId;
@ -688,21 +729,6 @@ export default {
border-radius: 10px; border-radius: 10px;
overflow: hidden; 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{ .sm_col{
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

Loading…
Cancel
Save