This commit is contained in:
daihh
2022-11-29 13:48:06 +08:00
2 changed files with 10 additions and 64 deletions

View File

@@ -130,10 +130,6 @@ const exportPdfPre=function (data){
return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/pdf-detail',data); return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/pdf-detail',data);
} }
/** /**
* 导出pdf * 导出pdf
* @param{ * @param{
@@ -141,33 +137,7 @@ const exportPdfPre=function (data){
* } * }
* */ * */
const exportPdf=function (udata){ const exportPdf=function (udata){
// return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',data); return ajax.postPdf(baseURL,'/xboe/subgroup/m/noteinfo/expPdf',udata);
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)
// })
} }
/** /**

View File

@@ -7,7 +7,7 @@
<el-button>导出<i class="el-icon-arrow-down el-icon--right"></i></el-button> <el-button>导出<i class="el-icon-arrow-down el-icon--right"></i></el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<!-- <el-dropdown-item command="1">PDF</el-dropdown-item> --> <el-dropdown-item command="1">PDF</el-dropdown-item>
<el-dropdown-item command="2">Excel</el-dropdown-item> <el-dropdown-item command="2">Excel</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
@@ -351,14 +351,9 @@ export default {
} }
if(this.exportType == '1') { if(this.exportType == '1') {
apiNote.exportPdf(data).then(res=>{ apiNote.exportPdf(data).then(res=>{
console.log("导出pdf完成");
const link = document.createElement('a');// 创建a标签 const link = document.createElement('a');// 创建a标签
// let blob = new Blob([res],{type: 'application/vnd.ms-pdf;charset=UTF-8'}); // 设置文件类型 let blob = new Blob([res],{type: 'application/vnd.ms-pdf;charset=UTF-8'}); // 设置文件类型
let blob = new Blob([res],{type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'}); // 设置文件类型
link.style.display = "none"; link.style.display = "none";
link.href = URL.createObjectURL(blob); // 创建URL link.href = URL.createObjectURL(blob); // 创建URL
link.setAttribute("download", "我的笔记.pdf"); link.setAttribute("download", "我的笔记.pdf");
@@ -367,25 +362,6 @@ export default {
link.remove(); // 一次性的用完就删除a标签 link.remove(); // 一次性的用完就删除a标签
this.dialogVisible = false; this.dialogVisible = false;
}) })
//apiNote.exportPdf(data);
// apiNote.exportPdf(data).then(res=>{
// if(res.status) {
// this.$message.error('导出失败');
// } else {
// const link = document.createElement('a');// 创建a标签
// // let blob = new Blob([res],{type: 'application/vnd.ms-pdf;charset=UTF-8'}); // 设置文件类型
// let blob = new Blob([res],{type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'}); // 设置文件类型
// link.style.display = "none";
// link.href = URL.createObjectURL(blob); // 创建URL
// link.setAttribute("download", "我的笔记.pdf");
// document.body.appendChild(link);
// link.click();
// document.body.removeChild(link);
// this.dialogVisible = false;
// }
// })
} else { } else {
let data = { let data = {
orderType:this.orderType, orderType:this.orderType,