OfflineExamList.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div class="list">
  3. <table>
  4. <tbody class="list-row">
  5. <tr class="list-header qm-primary-strong-text">
  6. <td>课程</td>
  7. <td>专业</td>
  8. <td>考试开放时间</td>
  9. <td>状态</td>
  10. <td style="max-width: 200px">操作</td>
  11. </tr>
  12. <tr v-for="course in courses" :key="course.examId">
  13. <td>{{ course.courseName }}</td>
  14. <td>{{ course.specialtyName }}</td>
  15. <td>
  16. {{ course.startTime }} <br />
  17. ~ <br />
  18. {{ course.endTime }}
  19. </td>
  20. <td>
  21. <div v-if="course.offlineFileUrl">
  22. <a
  23. @click="() => downloadOfflineFile(course.offlineFileUrl)"
  24. :href="course.offlineFileUrl"
  25. download
  26. >
  27. <i-icon type="ios-cloud-download"></i-icon>下载作答
  28. </a>
  29. </div>
  30. <div v-else>未上传</div>
  31. </td>
  32. <td style="min-width: 180px">
  33. <template v-if="!course.isvalid">
  34. <div v-if="course.paperId" style="display: grid; grid-gap: 10px">
  35. <i-button
  36. class="qm-primary-button"
  37. @click="previewPaper(course)"
  38. >
  39. 查看试卷
  40. </i-button>
  41. <a
  42. class="qm-primary-button"
  43. v-show="!disableDownloadPaperBtn"
  44. @click="() => tempDisableBtnAndDownloadPaper(course)"
  45. href="#"
  46. download
  47. >
  48. 下载试卷
  49. </a>
  50. <i-button
  51. v-if="disableDownloadPaperBtn"
  52. class="qm-primary-button"
  53. >
  54. 下载中
  55. </i-button>
  56. <!-- <i-button class="qm-primary-button">
  57. <a
  58. class="qm-primary-button"
  59. href="https://ecs-static.qmth.com.cn/offline-exam/答题卡.zip"
  60. download
  61. >下载答题卡</a>
  62. </i-button> -->
  63. <ecs-offline-exam-upload
  64. :course="course"
  65. @reloadList="$emit('reloadList')"
  66. ></ecs-offline-exam-upload>
  67. </div>
  68. <div v-else style="display: grid; grid-gap: 10px">
  69. <div
  70. v-if="
  71. new Date(course.startTime) - Date.now() > timeDifference
  72. "
  73. >
  74. 未开始
  75. </div>
  76. <div
  77. v-else-if="
  78. new Date(course.endTime) - Date.now() < timeDifference
  79. "
  80. >
  81. 已结束
  82. </div>
  83. <div v-else>
  84. <i-button
  85. class="qm-primary-button"
  86. @click="enterExam(course)"
  87. >
  88. 抽取试卷
  89. </i-button>
  90. </div>
  91. </div>
  92. </template>
  93. </td>
  94. </tr>
  95. </tbody>
  96. </table>
  97. </div>
  98. </template>
  99. <script>
  100. import { mapState as globalMapState } from "vuex";
  101. import {
  102. TK_SERVER_HTML_URL,
  103. TK_SERVER_API_URL,
  104. } from "@/constants/constants.js";
  105. import OfflineExamUpload from "./OfflineExamUpload.vue";
  106. export default {
  107. name: "EcsOfflineList",
  108. data() {
  109. return {
  110. disableDownloadPaperBtn: false,
  111. };
  112. },
  113. props: {
  114. courses: Array,
  115. },
  116. methods: {
  117. async enterExam(course) {
  118. // 若出错,直接报网络异常
  119. await this.$http.get("/api/ecs_oe_student/offlineExam/startOfflineExam", {
  120. params: { examStudentId: course.examStudentId },
  121. });
  122. this.$emit("reloadList");
  123. },
  124. previewPaper(course) {
  125. window._hmt.push(["_trackEvent", "离线考试页面", "预览"]);
  126. var user = {
  127. loginName: course.examStudentId,
  128. backUrl: window.document.location.href,
  129. isOnlineExam: true,
  130. };
  131. window.name = JSON.stringify(user);
  132. window.location.href =
  133. TK_SERVER_HTML_URL +
  134. "/admin/preview_paper/" +
  135. course.paperId +
  136. "?isback=true";
  137. },
  138. downloadOfflineFile(url) {
  139. window._hmt.push(["_trackEvent", "离线考试页面", "下载作答"]);
  140. window.location.href = url;
  141. },
  142. tempDisableBtnAndDownloadPaper(course) {
  143. window._hmt.push(["_trackEvent", "离线考试页面", "下载试卷"]);
  144. this.disableDownloadPaperBtn = true;
  145. setTimeout(() => (this.disableDownloadPaperBtn = false), 10 * 1000);
  146. window.location.href =
  147. TK_SERVER_API_URL +
  148. "/api/ecs_ques/paper/export/" +
  149. course.paperId +
  150. "/PAPER/" +
  151. this.user.rootOrgName +
  152. "/" +
  153. course.paperId +
  154. "/offLine?$key=" +
  155. this.user.key +
  156. "&$token=" +
  157. this.user.token;
  158. },
  159. },
  160. components: {
  161. "ecs-offline-exam-upload": OfflineExamUpload,
  162. },
  163. computed: {
  164. ...globalMapState(["user", "timeDifference"]),
  165. },
  166. };
  167. </script>
  168. <style scoped>
  169. .list {
  170. border: 1px solid #eeeeee;
  171. border-radius: 6px;
  172. }
  173. .list table {
  174. width: 100%;
  175. border-collapse: collapse !important;
  176. border-spacing: 0;
  177. }
  178. .list td {
  179. border: 1px solid #eeeeee;
  180. border-radius: 6px;
  181. border-collapse: separate !important;
  182. padding: 10px;
  183. }
  184. </style>