index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div style="margin-top: 10px" class="app-contain">
  3. <a-row :gutter="50">
  4. <a-col :span="18">
  5. <a-table
  6. :loading="listLoading"
  7. :data-source="tableData"
  8. :columns="columns"
  9. row-key="id"
  10. :custom-row="customRow"
  11. :pagination="false"
  12. >
  13. <template #bodyCell="{ column, record }">
  14. <template v-if="column.key === 'status'">
  15. <a-tag :color="statusTagFormatter(record.status)">
  16. {{ statusTextFormatter(record.status) }}
  17. </a-tag>
  18. </template>
  19. <template v-else-if="column.key === 'action'">
  20. <template v-if="record.status === 1">
  21. <router-link :to="{ path: '/student/edit', query: { id: record.id } }" target="_blank">
  22. <a-button type="link" size="small">批改</a-button>
  23. </router-link>
  24. </template>
  25. <template v-else-if="record.status === 2">
  26. <router-link :to="{ path: '/student/read', query: { id: record.id } }" target="_blank">
  27. <a-button type="link" size="small">查看试卷</a-button>
  28. </router-link>
  29. </template>
  30. </template>
  31. </template>
  32. </a-table>
  33. <a-pagination
  34. v-if="total > 0"
  35. :total="total"
  36. :current="queryParam.pageIndex"
  37. :page-size="queryParam.pageSize"
  38. @change="onPageChange"
  39. @showSizeChange="onPageSizeChange"
  40. :show-size-changer="true"
  41. :page-size-options="['10', '20', '50', '100']"
  42. style="margin-top: 20px"
  43. />
  44. </a-col>
  45. <a-col :span="6">
  46. <a-card class="record-answer-info">
  47. <a-descriptions :column="1" bordered size="small">
  48. <a-descriptions-item label="系统判分">{{ selectItem.systemScore }}</a-descriptions-item>
  49. <a-descriptions-item label="最终得分">{{ selectItem.userScore }}</a-descriptions-item>
  50. <a-descriptions-item label="试卷总分">{{ selectItem.paperScore }}</a-descriptions-item>
  51. <a-descriptions-item label="正确题数">{{ selectItem.questionCorrect }}</a-descriptions-item>
  52. <a-descriptions-item label="总题数">{{ selectItem.questionCount }}</a-descriptions-item>
  53. <a-descriptions-item label="用时">{{ selectItem.doTime }}</a-descriptions-item>
  54. </a-descriptions>
  55. </a-card>
  56. </a-col>
  57. </a-row>
  58. </div>
  59. </template>
  60. <script setup>
  61. import { ref, reactive, onMounted } from 'vue'
  62. import { useExamStore } from '@/store/exam'
  63. import examPaperAnswerApi from '@/api/student/examPaperAnswer'
  64. import { parseTime } from '@/utils/exam'
  65. import Footer from "@/views/portal/components/Footer.vue";
  66. import Header from "@/views/portal/components/Header.vue";
  67. import TallList from "@/views/resourceDetails/components/TallList.vue";
  68. import VideoDetails from "@/views/resourceDetails/components/VideoDetails.vue";
  69. const examStore = useExamStore()
  70. const queryParam = reactive({
  71. pageIndex: 1,
  72. pageSize: 10
  73. })
  74. const listLoading = ref(false)
  75. const tableData = ref([])
  76. const total = ref(0)
  77. const selectItem = reactive({
  78. systemScore: '0',
  79. userScore: '0',
  80. doTime: '0',
  81. paperScore: '0',
  82. questionCorrect: 0,
  83. questionCount: 0
  84. })
  85. const columns = [
  86. { title: '序号', dataIndex: 'id', key: 'id', width: 90 },
  87. { title: '名称', dataIndex: 'paperName', key: 'paperName' },
  88. { title: '学科', dataIndex: 'subjectName', key: 'subjectName', width: 70 },
  89. {
  90. title: '状态',
  91. dataIndex: 'status',
  92. key: 'status',
  93. width: 100
  94. },
  95. {
  96. title: '做题时间',
  97. dataIndex: 'createTime',
  98. key: 'createTime',
  99. width: 200,
  100. customRender: ({ text }) => formatDateTime(text)
  101. },
  102. {
  103. title: '',
  104. key: 'action',
  105. align: 'right',
  106. width: 70
  107. }
  108. ]
  109. function formatDateTime(val) {
  110. if (!val) return ''
  111. return parseTime(val, '{y}-{m}-{d} {h}:{i}:{s}')
  112. }
  113. function search() {
  114. listLoading.value = true
  115. const params = { ...queryParam, current: queryParam.pageIndex, size: queryParam.pageSize }
  116. delete params.pageIndex
  117. delete params.pageSize
  118. examPaperAnswerApi
  119. .pageList(params)
  120. .then((data) => {
  121. const re = data
  122. tableData.value = re.records
  123. total.value = re.total
  124. queryParam.pageIndex = re.current
  125. listLoading.value = false
  126. })
  127. .catch(() => {
  128. listLoading.value = false
  129. })
  130. }
  131. function customRow(record) {
  132. return {
  133. onClick: () => itemSelect(record)
  134. }
  135. }
  136. function itemSelect(record) {
  137. Object.assign(selectItem, record)
  138. }
  139. function statusTagFormatter(status) {
  140. return examStore.enumFormat(examStore.exam.examPaperAnswer.statusTag, status)
  141. }
  142. function statusTextFormatter(status) {
  143. return examStore.enumFormat(examStore.exam.examPaperAnswer.statusEnum, status)
  144. }
  145. function onPageChange(page, pageSize) {
  146. queryParam.pageIndex = page
  147. queryParam.pageSize = pageSize
  148. search()
  149. }
  150. function onPageSizeChange(current, size) {
  151. queryParam.pageIndex = 1
  152. queryParam.pageSize = size
  153. search()
  154. }
  155. onMounted(() => {
  156. search()
  157. })
  158. </script>
  159. <style lang="less" scoped>
  160. .app-contain {
  161. // 可根据需要自定义样式
  162. }
  163. .record-answer-info {
  164. margin-top: 20px;
  165. }
  166. </style>