This commit is contained in:
daihh
2022-11-22 19:01:47 +08:00
14 changed files with 72 additions and 33 deletions

View File

@@ -142,32 +142,32 @@ const exportPdfPre=function (data){
* */
const exportPdf=function (udata){
// return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',data);
//return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',data);
var url = baseURL + '/xboe/subgroup/m/noteinfo/exportPdf';
axios({
method: 'POST',
url: url,
data:udata,
responseType: 'blob',
headers: { 'XBOE-Access-Token':getToken(),'Content-Type':'application/pdf;charset=utf-8'}
}).then(res => {
//resolveBlob(res, mimeMap.zip);
console.log(res);
const aLink = document.createElement('a')
var blob = new Blob([res.request.response], { type: 'application/pdf' })
return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/expPdf',udata);
// var url = baseURL + '/xboe/subgroup/m/noteinfo/exportPdf';
// axios({
// method: 'POST',
// url: url,
// data:udata,
// responseType: 'blob',
// headers: { 'XBOE-Access-Token':getToken(),'Content-Type':'application/pdf;charset=utf-8'}
// }).then(res => {
// //resolveBlob(res, mimeMap.zip);
// console.log(res);
// const aLink = document.createElement('a')
// var blob = new Blob([res.request.response], { type: 'application/pdf' })
// //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
//var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
//var contentDisposition = decodeURI(res.headers['content-disposition'])
//var result = patt.exec(contentDisposition)
//var fileName = result[1]
//fileName = fileName.replace(/\"/g, '')
aLink.href = URL.createObjectURL(blob)
aLink.setAttribute('download','我的笔记.pdf') // 设置下载文件名称
document.body.appendChild(aLink)
aLink.click()
document.body.removeChild(aLink)
// aLink.href = URL.createObjectURL(blob)
// aLink.setAttribute('download','我的笔记.pdf') // 设置下载文件名称
// document.body.appendChild(aLink)
// aLink.click()
// document.body.removeChild(aLink)
})
// })
}
/**