From 61f035af4f1c8ee7cde155f73e249ad1e8db9a8a Mon Sep 17 00:00:00 2001 From: weinan2087 Date: Fri, 14 Oct 2022 20:32:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AC=94=E8=AE=B0?= =?UTF-8?q?=E5=AF=BC=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 { From 2eb23bec897ce8811966dfc37441240850e753f8 Mon Sep 17 00:00:00 2001 From: weinan2087 Date: Fri, 14 Oct 2022 20:32:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/phase2/note.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/api/phase2/note.js b/src/api/phase2/note.js index 8b962c21..7a0777e4 100644 --- a/src/api/phase2/note.js +++ b/src/api/phase2/note.js @@ -104,9 +104,34 @@ const ids=function (data){ * } * */ const exportExcel=function (data){ - return ajax.postJsonToFile(baseURL,'/xboe/subgroup/m/noteinfo/exportExcel',data); + // return ajax.postJsonToFile(baseURL,'/xboe/subgroup/m/noteinfo/exportExcel',data); + return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/exportExcel',data); } +/** + * 导出excel预览 + * @param { + * ids ["",""] + * } + * */ +const exportExcelPre=function (data){ + return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/excel-detail',data); +} + +/** + * 导出pdf预览 + * @param { + * ids ["",""] + * } + * */ +const exportPdfPre=function (data){ + return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/pdf-detail',data); +} + + + + + /** * 导出pdf * @param{ @@ -114,7 +139,8 @@ const exportExcel=function (data){ * } * */ const exportPdf=function (data){ - return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',data); + // return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',data); + return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',data); } /** @@ -146,5 +172,7 @@ export default { restore, ids, exportExcel, - exportPdf + exportPdf, + exportExcelPre, + exportPdfPre }