Commit e83854d1589fa899ad5fa9f5fab15592e8ba12cf
Merge branch 'ezTeach-2.0.0.0.release' of http://120.78.57.84/baoman/Ezquiz_Plat…
…form into ezTeach-2.0.0.0.release
Showing
4 changed files
with
51 additions
and
10 deletions
src/api/apis/apis.js
... | ... | @@ -193,6 +193,35 @@ export default { |
193 | 193 | tPaperDetail(data) { |
194 | 194 | return defaltService(setUpUrls.tPaperDetail, data); |
195 | 195 | }, |
196 | + tPaperDownload(paperId, title) { | |
197 | + return new Promise((resolve, reject) => { | |
198 | + service({ | |
199 | + method: "get", | |
200 | + url: setUpUrls.tPaperDownload + "?id=" + paperId, // 请求地址 | |
201 | + responseType: "blob" // 表明返回服务器返回的数据类型 | |
202 | + }).then( | |
203 | + (response) => { | |
204 | + resolve(response); | |
205 | + console.log(response) | |
206 | + let fileName = title + ".docx"; | |
207 | + if (window.navigator.msSaveOrOpenBlob) { | |
208 | + navigator.msSaveBlob(response, fileName); | |
209 | + } else { | |
210 | + let link = document.createElement("a"); | |
211 | + link.href = window.URL.createObjectURL(response); | |
212 | + link.download = fileName; | |
213 | + link.click(); | |
214 | + window.URL.revokeObjectURL(link.href); | |
215 | + } | |
216 | + }, | |
217 | + (err) => { | |
218 | + reject(err); | |
219 | + } | |
220 | + ); | |
221 | + }); | |
222 | + | |
223 | + // return defaltGetService(setUpUrls.tPaperDownload + "?id=" + paperId); | |
224 | + }, | |
196 | 225 | //任课老师-查询管理班级授课科目 |
197 | 226 | tSubjectList(data) { |
198 | 227 | return defaltService(setUpUrls.tSubjectList, data); | ... | ... |
src/api/urls/apis.js
... | ... | @@ -78,6 +78,7 @@ export default { |
78 | 78 | tTestExamReport: "/api_html/teaching/testExamReport", |
79 | 79 | //任课老师-查询答题卡详情 |
80 | 80 | tPaperDetail: "/api_html/teaching/paperDetail", |
81 | + tPaperDownload: "/api_html/teaching/wrongQuestion/download", | |
81 | 82 | //任课老师-查询管理班级授课科目 |
82 | 83 | tSubjectList: "/api_html/teaching/subjectList", |
83 | 84 | tListExamReport: "/api_html/teaching/listExamReport", | ... | ... |
src/utils/index.js
... | ... | @@ -614,13 +614,18 @@ export function getBlob(url) { |
614 | 614 | }); |
615 | 615 | } |
616 | 616 | export function fetchHTML(url) { |
617 | - var xhr = new XMLHttpRequest(); | |
618 | - xhr.open("GET", url, false); | |
619 | - xhr.send(); | |
620 | - if (xhr.status === 200) { | |
621 | - return xhr.responseText; | |
622 | - } else { | |
623 | - return null; | |
617 | + try { | |
618 | + var xhr = new XMLHttpRequest(); | |
619 | + xhr.open("GET", url, false); | |
620 | + xhr.send(); | |
621 | + if (xhr.status === 200) { | |
622 | + return xhr.responseText; | |
623 | + } else { | |
624 | + return ""; | |
625 | + } | |
626 | + } | |
627 | + catch (e) { | |
628 | + return ""; | |
624 | 629 | } |
625 | 630 | } |
626 | 631 | /** |
... | ... | @@ -990,7 +995,6 @@ export function paperPrint(paper) { |
990 | 995 | // size: A4 portrait; |
991 | 996 | // size: A3 landscape; |
992 | 997 | |
993 | - printWin.document.title = "中天易教"; | |
994 | 998 | const style = printWin.document.createElement('style'); |
995 | 999 | style.innerHTML = ` |
996 | 1000 | @media print |
... | ... | @@ -998,7 +1002,7 @@ export function paperPrint(paper) { |
998 | 1002 | @page { |
999 | 1003 | size: A4 portrait; |
1000 | 1004 | margin-top:0mm; |
1001 | - margin-bottom:10mm; | |
1005 | + margin-bottom:8.5mm; | |
1002 | 1006 | margin-left:4mm; |
1003 | 1007 | margin-right:4mm; |
1004 | 1008 | } | ... | ... |
src/views/basic/askTestQuestion/index.vue
... | ... | @@ -72,6 +72,8 @@ |
72 | 72 | @click.native="_detailQ(item.id)">查看</el-dropdown-item> |
73 | 73 | <el-dropdown-item v-if="dataType != 1" |
74 | 74 | @click.native="_print(item)">打印</el-dropdown-item> |
75 | + <el-dropdown-item v-if="dataType != 1" | |
76 | + @click.native="_download(item)">下载</el-dropdown-item> | |
75 | 77 | <el-dropdown-item @click.native="_updateQ(item)">修改</el-dropdown-item> |
76 | 78 | <el-dropdown-item @click.native="_copy(item)">复制</el-dropdown-item> |
77 | 79 | <el-dropdown-item> |
... | ... | @@ -658,7 +660,12 @@ export default { |
658 | 660 | } |
659 | 661 | paperPrint(data); |
660 | 662 | this.$loading.close(); |
661 | - }) | |
663 | + }) | |
664 | + }, | |
665 | + async _download(item) { | |
666 | + this.$loading.open(); | |
667 | + await this.$request.tPaperDownload(item.id, item.title); | |
668 | + this.$loading.close(); | |
662 | 669 | }, |
663 | 670 | _updateQ(item) { |
664 | 671 | ... | ... |