Download.vue 3.7 KB

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