From 61f035af4f1c8ee7cde155f73e249ad1e8db9a8a Mon Sep 17 00:00:00 2001 From: weinan2087 Date: Fri, 14 Oct 2022 20:32:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AC=94=E8=AE=B0=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/user/Mynotes.vue | 50 +++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/views/user/Mynotes.vue b/src/views/user/Mynotes.vue index a7aeca6e..0072cc06 100644 --- a/src/views/user/Mynotes.vue +++ b/src/views/user/Mynotes.vue @@ -138,13 +138,13 @@
-

累计导出{{datalist.length}}条

+

累计导出{{exportPreData.length}}条

导出时间:{{formatDate(new Date())}}

-
+

{{item.courseName}}

{{item.playTime}}
@@ -227,6 +227,7 @@ export default { startTime:'', endTime:'', datalist:[ ], + exportPreData:[ ], thu:true, couresna:[], courseName:'', @@ -251,9 +252,32 @@ export default { methods: { exportCommand(e) { this.exportType = e; - this.dialogVisible = true; + this.dialogVisible = false; + let data = { + orderType:this.orderType, + orderField:this.orderField, + courseId:this.courseId, + type:this.num, + startTime:this.startTime, + endTime:this.endTime, + } + // 获取导出文件前的预览数据 + apiNote.exportExcelPre(data).then(res=>{ + if(res.status != 200){return;} + if(res.result.data.length == 0){ + this.$message.warning('未查询到满足条件的数据') + return; + } + this.exportPreData = res.result.data; + if(res.result.isImage && e == 2){ + this.$message.warning('当前筛选条件下含图片类内容,无法导出Excel!') + return; + } + this.dialogVisible = true; + }) }, exportStart(){ + let ids = this.datalist.map(item=>{ if(item.contentType !=3) { return item.id; @@ -262,7 +286,12 @@ export default { let data = { name:this.userData.name, sign:this.userData.sign, - ids:ids, + orderType:this.orderType, + orderField:this.orderField, + courseId:this.courseId, + type:this.num, + startTime:this.startTime, + endTime:this.endTime, author:this.userData.avatar,//this.userInfo.avatar, } if(this.exportType == '1') { @@ -274,7 +303,7 @@ export default { let blob = new Blob([res],{type: 'application/vnd.ms-pdf;charset=UTF-8'}); // 设置文件类型 link.style.display = "none"; link.href = URL.createObjectURL(blob); // 创建URL - link.setAttribute("download", "我的笔记.xls"); + link.setAttribute("download", "我的笔记.pdf"); document.body.appendChild(link); link.click(); document.body.removeChild(link); @@ -283,7 +312,16 @@ export default { }) } else { - apiNote.exportExcel(ids).then(res=>{ + let data = { + orderType:this.orderType, + orderField:this.orderField, + courseId:this.courseId, + type:this.num, + startTime:this.startTime, + endTime:this.endTime, + } + // apiNote.exportExcel(ids).then(res=>{ + apiNote.exportExcel(data).then(res=>{ if(res.status) { this.$message.error('导出失败'); } else {