OnlinePracticeRecordList.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. async created() {
  81. try {
  82. const res = await this.$http.get(
  83. "/api/ecs_oe_student/practice/queryPracticeRecordList?examStudentId=" +
  84. this.$route.query.examStudentId
  85. );
  86. this.recordList = (res.data || []).reverse();
  87. } catch (error) {
  88. this.$Message.error({
  89. content: "查询练习记录列表出错!",
  90. duration: 15,
  91. closable: true
  92. });
  93. }
  94. },
  95. methods: {
  96. async enterPracticeRecordDetail(course) {
  97. this.$router.push(
  98. `/online-practice/exam/${
  99. this.$route.params.examId
  100. }/detail?examRecordDataId=${course.id}`
  101. );
  102. },
  103. formatTime(ms) {
  104. return (ms && moment.utc(ms).format("HH:mm:ss")) || "";
  105. }
  106. },
  107. computed: {
  108. examName() {
  109. return this.$route.query.examName;
  110. },
  111. courseName() {
  112. return this.$route.query.courseName;
  113. },
  114. maxAccuracy() {
  115. if (this.recordList.length === 0) {
  116. return 0;
  117. }
  118. return Math.max(...this.recordList.map(v => v.objectiveAccuracy)).toFixed(
  119. 2
  120. );
  121. },
  122. aveAccuracy() {
  123. if (this.recordList.length === 0) {
  124. return 0;
  125. }
  126. return (
  127. this.recordList.map(v => v.objectiveAccuracy).reduce((a, b) => a + b) /
  128. this.recordList.length
  129. ).toFixed(2);
  130. }
  131. }
  132. };
  133. </script>
  134. <style scoped>
  135. .home {
  136. margin: 20px;
  137. }
  138. .list {
  139. border: 1px solid #eeeeee;
  140. border-radius: 6px;
  141. }
  142. .list table {
  143. width: 100%;
  144. border-collapse: collapse !important;
  145. border-spacing: 0;
  146. }
  147. .list td {
  148. border: 1px solid #eeeeee;
  149. border-radius: 6px;
  150. border-collapse: separate !important;
  151. padding: 10px;
  152. }
  153. </style>