|
@@ -243,8 +243,56 @@
|
|
|
uploadPath: result[0],
|
|
|
name: param.name
|
|
|
}
|
|
|
+ uni.downloadFile({
|
|
|
+ url:param.url,//调接口返回url
|
|
|
+ success:(res)=>{
|
|
|
+ // uni.hideLoading();
|
|
|
+ if(res.statusCode==200){
|
|
|
+ var tempFilePath = res.tempFilePath;
|
|
|
+ this.saveFile(tempFilePath,param.name);
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ icon:'none',
|
|
|
+ title:'报告下载失败'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail:err=>{
|
|
|
+ uni.hideLoading();
|
|
|
+ uni.showToast({
|
|
|
+ icon:'none',
|
|
|
+ title:'报告下载失败'
|
|
|
+ })
|
|
|
+ reject(err);
|
|
|
+ }
|
|
|
+ })
|
|
|
fileService.download(item).then()
|
|
|
},
|
|
|
+ saveFile(url,name){//保存到本地
|
|
|
+ try{
|
|
|
+ const fileName = name;
|
|
|
+ //new Blob 实例化文件流
|
|
|
+ //let url = fileData
|
|
|
+ //const url = window.URL.createObjectURL(new Blob([fileData],{type:'application/pdf'}))
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.style.display = 'none';
|
|
|
+ link.href = url;
|
|
|
+ link.setAttribute('download',fileName);
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ //下载完成移除元素
|
|
|
+ document.body.removeChild(link);
|
|
|
+ //释放掉blob对象
|
|
|
+ window.URL.revokeObjectURL(url)
|
|
|
+ uni.showToast({
|
|
|
+ title:'下载成功'
|
|
|
+ })
|
|
|
+ }catch(error){
|
|
|
+ uni.showToast({
|
|
|
+ title:'下载失败'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
props: {
|
|
|
isoffice: {
|