|
|
@@ -680,10 +680,10 @@
|
|
|
if (waybill.waybill_number===waybill_number){
|
|
|
waybill.url=response.data.data.url;
|
|
|
waybill.suffix=response.data.data.type;
|
|
|
- setTimeout(function () {
|
|
|
+ /*setTimeout(function () {
|
|
|
_this.imgs.push(document.getElementById('img_'+waybill.id));
|
|
|
_this.lazy();
|
|
|
- },1);
|
|
|
+ },1);*/
|
|
|
tempTip.setDuration(3000);
|
|
|
tempTip.showSuccess("上传成功!");
|
|
|
return true;
|
|
|
@@ -1003,9 +1003,33 @@
|
|
|
uploadFiles(event){
|
|
|
let images = event.target.files;
|
|
|
for(let i=0;i<images.length;i++){
|
|
|
- images[i]['src'] = window.URL.createObjectURL(images[i]);
|
|
|
- this.images.push(images[i]);
|
|
|
- this.size += images[i].size;
|
|
|
+ let MAX_HEIGHT = 1000;
|
|
|
+ let image = new Image();
|
|
|
+ image.onload = ()=>{
|
|
|
+ let canvas = document.createElement("canvas");
|
|
|
+ if (image.height > MAX_HEIGHT && image.height >= image.width) {
|
|
|
+ image.width *= MAX_HEIGHT / image.height;
|
|
|
+ image.height = MAX_HEIGHT;
|
|
|
+ }
|
|
|
+ if (image.width > MAX_HEIGHT && image.width > image.height) {
|
|
|
+ image.height *= MAX_HEIGHT / image.width;
|
|
|
+ image.width = MAX_HEIGHT;
|
|
|
+ }
|
|
|
+ let ctx = canvas.getContext("2d");
|
|
|
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
+ canvas.width = image.width;
|
|
|
+ canvas.height = image.height;
|
|
|
+ ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
|
+ let src = canvas.toDataURL("image/jpeg");
|
|
|
+ let size = src.length;
|
|
|
+ this.images.push({
|
|
|
+ src : src,
|
|
|
+ name : images[i]["name"],
|
|
|
+ size : size,
|
|
|
+ });
|
|
|
+ this.size += size;
|
|
|
+ };
|
|
|
+ image.src = window.URL.createObjectURL(images[i]);
|
|
|
}
|
|
|
},
|
|
|
//删除图片
|
|
|
@@ -1019,52 +1043,31 @@
|
|
|
window.tempTip.show("未选择图片");
|
|
|
return;
|
|
|
}
|
|
|
- if (this.size > 10485760){
|
|
|
- window.tempTip.show("上传图片超出10MB,请分开上传");
|
|
|
+ if (this.size > 104857600){
|
|
|
+ window.tempTip.show("上传图片超出100MB,请分开上传");
|
|
|
return;
|
|
|
}
|
|
|
- let formData = new FormData();
|
|
|
- this.images.forEach(image=>{
|
|
|
- formData.append("images[]",image);
|
|
|
- });
|
|
|
- window.tempTip.setIndex(1099);
|
|
|
- window.tempTip.setDuration(9999);
|
|
|
- window.tempTip.waitingTip("上传中,请稍等......");
|
|
|
- window.axios.post('{{url('waybill/batchUploadImages')}}',formData,{
|
|
|
- 'Content-Type':'multipart/form-data'
|
|
|
- }).then(res=>{
|
|
|
- if (res.data.success){
|
|
|
- let result = res.data.data.data;
|
|
|
- let errors = res.data.data.errors;
|
|
|
- if (errors.length>0)this.batchUploadError = errors;
|
|
|
- result.forEach(r=>{
|
|
|
- this.waybills.some(waybill=> {
|
|
|
- if (waybill.id==r.id){
|
|
|
- waybill.url="/storage"+r.upload_file.url;
|
|
|
- waybill.suffix=r.upload_file.type;
|
|
|
- setTimeout(()=> {
|
|
|
- this.imgs.push(document.getElementById('img_'+waybill.id));
|
|
|
- this.lazy();
|
|
|
- },1);
|
|
|
- return true;
|
|
|
- }
|
|
|
- });
|
|
|
- this.size = 0;
|
|
|
+ window.tempTip.postBasicRequest('{{url('waybill/batchUploadImages')}}',{images:this.images},res=>{
|
|
|
+ let result = res.data;
|
|
|
+ let errors = res.errors;
|
|
|
+ if (errors.length>0)this.batchUploadError = errors;
|
|
|
+ result.forEach(r=>{
|
|
|
+ this.waybills.some(waybill=> {
|
|
|
+ if (waybill.id==r.id){
|
|
|
+ waybill.url="/storage"+r.upload_file.url;
|
|
|
+ waybill.suffix=r.upload_file.type;
|
|
|
+ /*setTimeout(()=> {
|
|
|
+ this.imgs.push(document.getElementById('img_'+waybill.id));
|
|
|
+ this.lazy();
|
|
|
+ },1);*/
|
|
|
+ return true;
|
|
|
+ }
|
|
|
});
|
|
|
- this.$forceUpdate();
|
|
|
- window.tempTip.cancelWaitingTip();
|
|
|
- window.tempTip.setDuration(2000);
|
|
|
- window.tempTip.showSuccess("上传成功!");
|
|
|
- return;
|
|
|
- }
|
|
|
- window.tempTip.cancelWaitingTip();
|
|
|
- window.tempTip.setDuration(3000);
|
|
|
- window.tempTip.show(res.data.data);
|
|
|
- }).catch(err=>{
|
|
|
- window.tempTip.cancelWaitingTip();
|
|
|
- window.tempTip.setDuration(3000);
|
|
|
- window.tempTip.show('网络错误:'+err);
|
|
|
- });
|
|
|
+ this.size = 0;
|
|
|
+ });
|
|
|
+ this.$forceUpdate();
|
|
|
+ return "上传成功";
|
|
|
+ },true);
|
|
|
},
|
|
|
},
|
|
|
filters:{
|