Commit 96dbf0ac48b778e134bd0c44fcc5288fe516f28c
1 parent
0f102a24
feat:试卷下载
Showing
4 changed files
with
40 additions
and
4 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
| ... | ... | @@ -989,8 +989,7 @@ export function paperPrint(paper) { |
| 989 | 989 | } |
| 990 | 990 | // size: A4 portrait; |
| 991 | 991 | // size: A3 landscape; |
| 992 | - | |
| 993 | - printWin.document.title = "中天易教"; | |
| 992 | + | |
| 994 | 993 | const style = printWin.document.createElement('style'); |
| 995 | 994 | style.innerHTML = ` |
| 996 | 995 | @media print |
| ... | ... | @@ -998,7 +997,7 @@ export function paperPrint(paper) { |
| 998 | 997 | @page { |
| 999 | 998 | size: A4 portrait; |
| 1000 | 999 | margin-top:0mm; |
| 1001 | - margin-bottom:10mm; | |
| 1000 | + margin-bottom:8.5mm; | |
| 1002 | 1001 | margin-left:4mm; |
| 1003 | 1002 | margin-right:4mm; |
| 1004 | 1003 | } | ... | ... |
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 | ... | ... |