|
@@ -112,22 +112,52 @@ export default {
|
|
|
},
|
|
|
|
|
|
handleGetReportImg(){
|
|
|
- if(this.reportImgUrl){
|
|
|
- this.showReportImg=true
|
|
|
- return
|
|
|
- }
|
|
|
+ // if(this.reportImgUrl){
|
|
|
+ // this.showReportImg=true
|
|
|
+ // return
|
|
|
+ // }
|
|
|
apiSmartReport.getReportImg({
|
|
|
SmartReportId:Number(this.$route.query.id)
|
|
|
}).then(res=>{
|
|
|
if(res.Ret===200){
|
|
|
- this.reportImgUrl=res.Data
|
|
|
- this.showReportImg=true
|
|
|
+ // this.reportImgUrl=res.Data
|
|
|
+ // this.showReportImg=true
|
|
|
+ // 改为直接下载图片不是展示
|
|
|
+ this.saveImg(res.Data)
|
|
|
}else{
|
|
|
if(res.Ret!==403){
|
|
|
this.$message.warning(res.Msg)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+
|
|
|
+ saveImg(imgUrl){
|
|
|
+ let img=new Image()
|
|
|
+ img.setAttribute('crossOrigin', 'anonymous');
|
|
|
+ img.src=imgUrl
|
|
|
+ img.onload=()=>{
|
|
|
+ let canvas = document.createElement("canvas");
|
|
|
+ canvas.width = img.width;
|
|
|
+ canvas.height = img.height;
|
|
|
+ let context = canvas.getContext('2d');
|
|
|
+ context.drawImage(img, 0, 0, img.width, img.height);
|
|
|
+ let dataURL = canvas.toDataURL("image/png", 1);
|
|
|
+ const a=document.createElement('a')
|
|
|
+ a.setAttribute("download",this.reportInfo.Title)
|
|
|
+ a.style.display = "none"
|
|
|
+ a.href=dataURL
|
|
|
+ document.body.appendChild(a);
|
|
|
+ a.click()
|
|
|
+ }
|
|
|
+ img.onerror=(e)=>{
|
|
|
+ console.log(e);
|
|
|
+ this.$message.warning("自动下载图片失败,请手动保存")
|
|
|
+ if(imgUrl){
|
|
|
+ this.reportImgUrl=imgUrl
|
|
|
+ this.showReportImg=true
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
}
|