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,6 +193,35 @@ export default { | ||
| 193 | tPaperDetail(data) { | 193 | tPaperDetail(data) { |
| 194 | return defaltService(setUpUrls.tPaperDetail, data); | 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 | tSubjectList(data) { | 226 | tSubjectList(data) { |
| 198 | return defaltService(setUpUrls.tSubjectList, data); | 227 | return defaltService(setUpUrls.tSubjectList, data); |
src/api/urls/apis.js
| @@ -78,6 +78,7 @@ export default { | @@ -78,6 +78,7 @@ export default { | ||
| 78 | tTestExamReport: "/api_html/teaching/testExamReport", | 78 | tTestExamReport: "/api_html/teaching/testExamReport", |
| 79 | //任课老师-查询答题卡详情 | 79 | //任课老师-查询答题卡详情 |
| 80 | tPaperDetail: "/api_html/teaching/paperDetail", | 80 | tPaperDetail: "/api_html/teaching/paperDetail", |
| 81 | + tPaperDownload: "/api_html/teaching/wrongQuestion/download", | ||
| 81 | //任课老师-查询管理班级授课科目 | 82 | //任课老师-查询管理班级授课科目 |
| 82 | tSubjectList: "/api_html/teaching/subjectList", | 83 | tSubjectList: "/api_html/teaching/subjectList", |
| 83 | tListExamReport: "/api_html/teaching/listExamReport", | 84 | tListExamReport: "/api_html/teaching/listExamReport", |
src/utils/index.js
| @@ -614,13 +614,18 @@ export function getBlob(url) { | @@ -614,13 +614,18 @@ export function getBlob(url) { | ||
| 614 | }); | 614 | }); |
| 615 | } | 615 | } |
| 616 | export function fetchHTML(url) { | 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,7 +995,6 @@ export function paperPrint(paper) { | ||
| 990 | // size: A4 portrait; | 995 | // size: A4 portrait; |
| 991 | // size: A3 landscape; | 996 | // size: A3 landscape; |
| 992 | 997 | ||
| 993 | - printWin.document.title = "中天易教"; | ||
| 994 | const style = printWin.document.createElement('style'); | 998 | const style = printWin.document.createElement('style'); |
| 995 | style.innerHTML = ` | 999 | style.innerHTML = ` |
| 996 | @media print | 1000 | @media print |
| @@ -998,7 +1002,7 @@ export function paperPrint(paper) { | @@ -998,7 +1002,7 @@ export function paperPrint(paper) { | ||
| 998 | @page { | 1002 | @page { |
| 999 | size: A4 portrait; | 1003 | size: A4 portrait; |
| 1000 | margin-top:0mm; | 1004 | margin-top:0mm; |
| 1001 | - margin-bottom:10mm; | 1005 | + margin-bottom:8.5mm; |
| 1002 | margin-left:4mm; | 1006 | margin-left:4mm; |
| 1003 | margin-right:4mm; | 1007 | margin-right:4mm; |
| 1004 | } | 1008 | } |
src/views/basic/askTestQuestion/index.vue
| @@ -72,6 +72,8 @@ | @@ -72,6 +72,8 @@ | ||
| 72 | @click.native="_detailQ(item.id)">查看</el-dropdown-item> | 72 | @click.native="_detailQ(item.id)">查看</el-dropdown-item> |
| 73 | <el-dropdown-item v-if="dataType != 1" | 73 | <el-dropdown-item v-if="dataType != 1" |
| 74 | @click.native="_print(item)">打印</el-dropdown-item> | 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 | <el-dropdown-item @click.native="_updateQ(item)">修改</el-dropdown-item> | 77 | <el-dropdown-item @click.native="_updateQ(item)">修改</el-dropdown-item> |
| 76 | <el-dropdown-item @click.native="_copy(item)">复制</el-dropdown-item> | 78 | <el-dropdown-item @click.native="_copy(item)">复制</el-dropdown-item> |
| 77 | <el-dropdown-item> | 79 | <el-dropdown-item> |
| @@ -658,7 +660,12 @@ export default { | @@ -658,7 +660,12 @@ export default { | ||
| 658 | } | 660 | } |
| 659 | paperPrint(data); | 661 | paperPrint(data); |
| 660 | this.$loading.close(); | 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 | _updateQ(item) { | 670 | _updateQ(item) { |
| 664 | 671 |