Download.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <el-dialog title="个性化提升手册" class="mm_dialog" :visible="visible" width="360px" @close="handleClose">
  3. <div class="box">
  4. <div class="item" :class="{ isAnswer: isAnswer === 1 }" @click="isAnswer = 1">
  5. 有答案解析
  6. <i class="iconfont icon_Check" v-if="isAnswer === 1"></i>
  7. </div>
  8. <div class="item" :class="{ isAnswer: isAnswer === 0 }" @click="isAnswer = 0">
  9. 无答案解析
  10. <i class="iconfont icon_Check" v-if="isAnswer === 0"></i>
  11. </div>
  12. </div>
  13. <span slot="footer" class="dialog-footer">
  14. <el-button @click="handleClose">取 消</el-button>
  15. <el-button type="primary" @click="download">下载</el-button>
  16. </span>
  17. </el-dialog>
  18. </template>
  19. <script>
  20. import { downloadStudentErrorQuestion } from '../../../http/api/errorQuestion';
  21. import { ExtractFilename, DownloadFile, CreateLoadingInstance } from './tools'
  22. export default {
  23. props: {
  24. visible: {
  25. type: Boolean,
  26. default: false
  27. },
  28. examId: {
  29. type: [String, Number],
  30. required: true
  31. },
  32. subjectCode: {
  33. type: [String, Number],
  34. required: true
  35. }
  36. },
  37. data() {
  38. return {
  39. isAnswer: 1
  40. };
  41. },
  42. methods: {
  43. handleClose() {
  44. this.$emit('update:visible', false);
  45. },
  46. download() {
  47. const loadingInstance = CreateLoadingInstance()
  48. downloadStudentErrorQuestion({
  49. examId: this.examId,
  50. subjectCode: this.subjectCode,
  51. isAnswer: this.isAnswer
  52. }).then(response => {
  53. const blob2 = new Blob([response.data], {
  54. type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
  55. });
  56. const contentDisposition = response.headers['content-disposition'];
  57. const fileName = ExtractFilename(contentDisposition)
  58. DownloadFile(blob2, fileName)
  59. }).catch(error => {
  60. this.$message.error('下载失败,请稍后重试');
  61. }).finally(() => {
  62. loadingInstance.close();
  63. });
  64. }
  65. }
  66. };
  67. </script>
  68. <style scoped lang="scss">
  69. .box {
  70. display: flex;
  71. justify-content: space-between;
  72. .item {
  73. width: 150px;
  74. height: 50px;
  75. line-height: 50px;
  76. text-align: center;
  77. font-size: 14px;
  78. color: #909399;
  79. background: #EDEFF6;
  80. border-radius: 4px;
  81. cursor: pointer;
  82. &.isAnswer {
  83. color: #2B65FF;
  84. background: #fff;
  85. border: 2px solid #2B65FF;
  86. box-shadow: 0 2px 6px rgba(43, 101, 255, 0.12);
  87. position: relative;
  88. /* 右下角的蓝色三角与对勾 */
  89. &::after {
  90. content: '';
  91. position: absolute;
  92. right: 0;
  93. bottom: 0;
  94. border: 12px solid #2B65FF;
  95. border-top-color: transparent;
  96. border-left-color: transparent;
  97. }
  98. .iconfont {
  99. position: absolute;
  100. right: 0;
  101. bottom: -18px;
  102. font-size: 16px;
  103. color: #ffffff;
  104. z-index: 1;
  105. }
  106. }
  107. }
  108. }
  109. </style>