笔记导出功能

This commit is contained in:
daihh
2022-10-18 13:15:39 +08:00
parent 8a8ab315ef
commit 619546c466
4 changed files with 56 additions and 22 deletions

View File

@@ -153,7 +153,7 @@
<div class="all-content">
<span v-if="item.contentType != 3">{{ item.content }}</span>
<div v-else>
<template v-for="img in item.content">
<template v-for="img in item.imgList">
<img style="max-height:145px;max-width:140px" :src="fileBaseUrl + img" alt=""/>
</template>
</div>
@@ -227,7 +227,7 @@ export default {
startTime:'',
endTime:'',
datalist:[ ],
exportPreData:[ ],
exportPreData:[],
thu:true,
couresna:[],
courseName:'',
@@ -268,11 +268,19 @@ export default {
this.$message.warning('未查询到满足条件的数据')
return;
}
this.exportPreData = res.result.data;
if(res.result.isImage && e == 2){
this.$message.warning('当前筛选条件下含图片类内容无法导出Excel')
return;
}
res.result.data.forEach((item)=>{
if(item.contentType==3){
item.imgList=item.content.split(',');
}else{
item.imgList=[];
}
})
this.exportPreData = res.result.data;
this.dialogVisible = true;
})
},
@@ -295,23 +303,24 @@ export default {
author:this.userData.avatar,//this.userInfo.avatar,
}
if(this.exportType == '1') {
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;
}
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 {
let data = {
orderType:this.orderType,