日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ant design 文件下载

發布時間:2023/12/29 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ant design 文件下载 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文件下載//導出報表 const exportExel = () => {axios({method: 'post',url: '/insMngGjzy/comb/attribution/export',responseType: 'arraybuffer',data: {combId: Number(id),type: tempOthers?.type || 4,startDate: tempOthers?.dateArr?.[0] || '',endDate: tempOthers?.dateArr?.[1] || '',industryCode: tempOthers?.industryCode || infoObj?.hydm || 0},headers: {clientType: 1,accessToken:getCookie('token') ||'DC0956D491D5BCA4B86809D38DD5C5CB2CA3350B6BE7D98DEEF4EBDDF721A92735FE7A58BA18AE7B6EBDACEEFE27DFF845D0158C216718F3'}}).then((res: any) => {getFile(res,`${infoObj.zzmc}-${infoObj.zhmc}業績歸因報表`,'xlsx','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');});};export const getFile = (res: any, title: string, suffix: string, type: string) => {const blob = new Blob([res.data], { type });const reader = new FileReader();reader.readAsDataURL(blob);reader.onload = e => {const a = document.createElement('a');a.download = `${title}.${suffix || 'xls'}`;a.href = e.target.result;document.body.appendChild(a);a.click();document.body.removeChild(a);};};//下載文件const getUrl = () => {dispatch({type: 'combManage/goGetSysUrl',payload: {type: 'STOCK_POOL_IMPORT_MODEL'},callback: (res: any) => {if (res.code === 1008) {downLoadFromUrl(res.data.url);}}});};export const downLoadFromUrl = (url: string) => {if (url) {var x = new XMLHttpRequest();x.open('GET', url, true);x.responseType = 'blob';x.onload = function(e) {download(x.response, url.substr(url.lastIndexOf('/') + 1), 'application/vnd.ms-excel');};x.send();}};//下載圖片const getQqrCode=()=>{axios({method: 'post',url: '/InvestmentAssistant/qrCode/image.do',responseType: 'arraybuffer',data: {type:1},headers: {clientType: 1,}}).then((res: any) => {var data = res.data;let imageUrl ="data:image/png;base64," +btoa(new Uint8Array(data).reduce((data, byte) => data + String.fromCharCode(byte),""));setCode(imageUrl)},()=>{setCode("")});} // 獲取研報并且跳轉 export const getReport = (id: number | string,flag: string,reportTitle: string,callback: () => {} ) => {axios({method: 'get',url: `/insMngGjzy/report/${flag}/${id}`,responseType: 'arraybuffer',headers: {clientType: 1,accessToken:getCookie('token') ||'DC0956D491D5BCA4B86809D38DD5C5CB2CA3350B6BE7D98DEEF4EBDDF721A92735FE7A58BA18AE7B6EBDACEEFE27DFF845D0158C216718F3'}}).then((res: any) => {console.log('resres', res);if (res?.status === 200) {const blob = new Blob([res.data], { type: '' });const reader = new FileReader();reader.readAsDataURL(blob);reader.onload = e => {if (e.target.result) {//docx類型if (res.headers['content-disposition']) {if (res.headers['content-disposition'].indexOf('docx') > -1) {let disposition: { [key: string]: any } = { filename: reportTitle + '.docx' };const headersContent = res.headers['content-disposition'].split(';');headersContent.forEach((item: string) => {const itemArr = item.split('=');if (itemArr.length === 2) {disposition[itemArr[0].trim()] = itemArr[1];}});// 文件流const a = document.createElement('a');a.download = decodeURIComponent(disposition['filename']); //對中文進行解碼decodeURIComponent方法a.href = e.target.result;document.body.appendChild(a);a.click();document.body.removeChild(a);callback();return;}}//pdf類型localStorage.setItem('pdfCtt', e.target.result);window.open(`${window.location.origin}/institute_gjzy/pdf?id=${id}`, '_blank');callback();}};}}); };

總結

以上是生活随笔為你收集整理的ant design 文件下载的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。