OnlinePracticeRecordList.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <main-layout>
  3. <Breadcrumb
  4. style="text-align: left; padding-left: 20px; height: 40px; line-height: 40px;
  5. background-color: #fafafa;"
  6. >
  7. 当前所在位置:
  8. <BreadcrumbItem :to="{ name: 'OnlinePracticeHome' }">
  9. 在线练习
  10. </BreadcrumbItem>
  11. <BreadcrumbItem>练习详情</BreadcrumbItem>
  12. </Breadcrumb>
  13. <div class="home">
  14. <div
  15. style="display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 20px; text-align: left"
  16. >
  17. <div>
  18. 批次: <span>{{ examName }}</span>
  19. </div>
  20. <div>
  21. 科目: <span>{{ courseName }}</span>
  22. </div>
  23. <div>
  24. 平均正确率: <span>{{ aveAccuracy }}%</span>
  25. </div>
  26. <div>
  27. 最高正确率: <span>{{ maxAccuracy }}%</span>
  28. </div>
  29. </div>
  30. <div class="list">
  31. <table>
  32. <tbody class="list-row">
  33. <tr class="list-header qm-primary-strong-text">
  34. <td>练习编号</td>
  35. <td>开始日期</td>
  36. <td>结束日期</td>
  37. <td>练习时长</td>
  38. <td>总题量</td>
  39. <td>正确</td>
  40. <td>错误</td>
  41. <td>未答</td>
  42. <td>正确率</td>
  43. <td style="max-width: 200px">操作</td>
  44. </tr>
  45. <tr v-for="record in recordList" :key="record.examId">
  46. <td>{{ record.id }}</td>
  47. <td>{{ record.startTime }}</td>
  48. <td>{{ record.endTime }}</td>
  49. <td>{{ formatTime(record.usedExamTime) }}</td>
  50. <td>{{ record.totalQuestionCount }}</td>
  51. <td>{{ record.succQuestionNum }}</td>
  52. <td>{{ record.failQuestionNum }}</td>
  53. <td>{{ record.notAnsweredCount }}</td>
  54. <td>{{ record.objectiveAccuracy }}%</td>
  55. <td style="min-width: 120px">
  56. <i-button
  57. class="qm-primary-button"
  58. @click="() => enterPracticeRecordDetail(record)"
  59. >
  60. 查看成绩报告
  61. </i-button>
  62. </td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. </div>
  67. </div>
  68. </main-layout>
  69. </template>
  70. <script>
  71. // import { createNamespacedHelpers } from "vuex";
  72. import moment from "moment";
  73. // import { mapState as globalMapState } from "vuex";
  74. // const { mapMutations } = createNamespacedHelpers("examHomeModule");
  75. export default {
  76. name: "OnlinePracticeRecordList",
  77. data() {
  78. return { recordList: [] };
  79. },
  80. computed: {
  81. examName() {
  82. return this.$route.query.examName;
  83. },
  84. courseName() {
  85. return this.$route.query.courseName;
  86. },
  87. maxAccuracy() {
  88. if (this.recordList.length === 0) {
  89. return 0;
  90. }
  91. return Math.max(...this.recordList.map(v => v.objectiveAccuracy)).toFixed(
  92. 2
  93. );
  94. },
  95. aveAccuracy() {
  96. if (this.recordList.length === 0) {
  97. return 0;
  98. }
  99. return (
  100. this.recordList.map(v => v.objectiveAccuracy).reduce((a, b) => a + b) /
  101. this.recordList.length
  102. ).toFixed(2);
  103. },
  104. },
  105. async created() {
  106. try {
  107. const res = await this.$http.get(
  108. "/api/ecs_oe_student/practice/queryPracticeRecordList?examStudentId=" +
  109. this.$route.query.examStudentId
  110. );
  111. this.recordList = (res.data || []).reverse();
  112. } catch (error) {
  113. this.$Message.error({
  114. content: "查询练习记录列表出错!",
  115. duration: 15,
  116. closable: true,
  117. });
  118. }
  119. },
  120. methods: {
  121. async enterPracticeRecordDetail(course) {
  122. this.$router.push(
  123. `/online-practice/exam/${this.$route.params.examId}/detail?examRecordDataId=${course.id}`
  124. );
  125. },
  126. formatTime(ms) {
  127. return (ms && moment.utc(ms).format("HH:mm:ss")) || "";
  128. },
  129. },
  130. };
  131. </script>
  132. <style scoped>
  133. .home {
  134. margin: 20px;
  135. }
  136. .list {
  137. border: 1px solid #eeeeee;
  138. border-radius: 6px;
  139. }
  140. .list table {
  141. width: 100%;
  142. border-collapse: collapse !important;
  143. border-spacing: 0;
  144. }
  145. .list td {
  146. border: 1px solid #eeeeee;
  147. border-radius: 6px;
  148. border-collapse: separate !important;
  149. padding: 10px;
  150. }
  151. </style>