diff --git a/src/api/apis/apis.js b/src/api/apis/apis.js index 3860fda..3cbcd28 100644 --- a/src/api/apis/apis.js +++ b/src/api/apis/apis.js @@ -193,6 +193,35 @@ export default { tPaperDetail(data) { return defaltService(setUpUrls.tPaperDetail, data); }, + tPaperDownload(paperId, title) { + return new Promise((resolve, reject) => { + service({ + method: "get", + url: setUpUrls.tPaperDownload + "?id=" + paperId, // 请求地址 + responseType: "blob" // 表明返回服务器返回的数据类型 + }).then( + (response) => { + resolve(response); + console.log(response) + let fileName = title + ".docx"; + if (window.navigator.msSaveOrOpenBlob) { + navigator.msSaveBlob(response, fileName); + } else { + let link = document.createElement("a"); + link.href = window.URL.createObjectURL(response); + link.download = fileName; + link.click(); + window.URL.revokeObjectURL(link.href); + } + }, + (err) => { + reject(err); + } + ); + }); + + // return defaltGetService(setUpUrls.tPaperDownload + "?id=" + paperId); + }, //任课老师-查询管理班级授课科目 tSubjectList(data) { return defaltService(setUpUrls.tSubjectList, data); diff --git a/src/api/urls/apis.js b/src/api/urls/apis.js index 1863662..00c09be 100644 --- a/src/api/urls/apis.js +++ b/src/api/urls/apis.js @@ -78,6 +78,7 @@ export default { tTestExamReport: "/api_html/teaching/testExamReport", //任课老师-查询答题卡详情 tPaperDetail: "/api_html/teaching/paperDetail", + tPaperDownload: "/api_html/teaching/wrongQuestion/download", //任课老师-查询管理班级授课科目 tSubjectList: "/api_html/teaching/subjectList", tListExamReport: "/api_html/teaching/listExamReport", diff --git a/src/utils/index.js b/src/utils/index.js index 2624b57..3882fe8 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -989,8 +989,7 @@ export function paperPrint(paper) { } // size: A4 portrait; // size: A3 landscape; - - printWin.document.title = "中天易教"; + const style = printWin.document.createElement('style'); style.innerHTML = ` @media print @@ -998,7 +997,7 @@ export function paperPrint(paper) { @page { size: A4 portrait; margin-top:0mm; - margin-bottom:10mm; + margin-bottom:8.5mm; margin-left:4mm; margin-right:4mm; } diff --git a/src/views/basic/askTestQuestion/index.vue b/src/views/basic/askTestQuestion/index.vue index c5e639b..c621fc8 100644 --- a/src/views/basic/askTestQuestion/index.vue +++ b/src/views/basic/askTestQuestion/index.vue @@ -72,6 +72,8 @@ @click.native="_detailQ(item.id)">查看 打印 + 下载 修改 复制 @@ -658,7 +660,12 @@ export default { } paperPrint(data); this.$loading.close(); - }) + }) + }, + async _download(item) { + this.$loading.open(); + await this.$request.tPaperDownload(item.id, item.title); + this.$loading.close(); }, _updateQ(item) {