list.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div class="grid grid-cols-1 gap-4">
  3. <template v-for="(item, index) in data">
  4. <div
  5. class="question-card overflow-hidden rounded-xl border border-[#e5e7eb] bg-white shadow-sm"
  6. >
  7. <div class="p-4">
  8. <div class="mb-3 flex items-start justify-between">
  9. <div class="text-base font-semibold text-gray-800">
  10. 题目 {{ index + 1 }}
  11. </div>
  12. <div class="flex space-x-1">
  13. <q-btn
  14. round
  15. size="xs"
  16. icon="book"
  17. color="red"
  18. @click="onHistory(item)"
  19. />
  20. </div>
  21. </div>
  22. <!-- 题目的图片 -->
  23. <template v-for="pic in item.questionImages">
  24. <div>
  25. <img :src="pic.imageUrl" alt="题目图片" />
  26. </div>
  27. </template>
  28. <!-- 答案的图片 -->
  29. <template v-for="pic in item.answerImages">
  30. <div>
  31. <img :src="pic.imageUrl" alt="题目图片" />
  32. </div>
  33. </template>
  34. <!-- 视频解析列表 -->
  35. <div v-if="showVideo && item.questionVideos?.length > 0">
  36. <div class="mb-2 text-sm font-medium text-gray-800">视频解析:</div>
  37. <ul class="space-y-2">
  38. <template v-for="video in item.questionVideos">
  39. <li
  40. class="video-item flex items-center justify-between rounded-lg border border-[#e5e7eb] p-2"
  41. >
  42. <span class="text-sm">{{ video.fileName }}</span>
  43. <div
  44. class="play-video bg-subject-color hover:bg-subject-dark rounded-full p-1.5 transition-colors"
  45. @click="onVideo(video)"
  46. >
  47. <i class="fas fa-circle-play text-base"></i>
  48. </div>
  49. </li>
  50. </template>
  51. </ul>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. </div>
  57. <q-dialog v-model="state.video.show" persistent>
  58. <q-card style="width: 90%; max-width: 90%">
  59. <q-card-section>
  60. <div class="text-h6 flex items-center">
  61. 视频解析({{ state.video.name }})
  62. <SvgIcon
  63. name="czr_close"
  64. color="#000000"
  65. class="ml-auto"
  66. @click="state.video.show = false"
  67. />
  68. </div>
  69. </q-card-section>
  70. <q-card-section>
  71. <video class="h-full w-full" :src="state.video.url" controls />
  72. </q-card-section>
  73. </q-card>
  74. </q-dialog>
  75. <q-dialog v-model="state.history.show">
  76. <q-card style="max-width: 60%">
  77. <q-card-section>
  78. <div class="text-h6"></div>
  79. <div class="text-h6 flex w-100 items-center">
  80. 历史做题记录
  81. <SvgIcon
  82. name="czr_close"
  83. color="#000000"
  84. class="ml-auto"
  85. @click="state.history.show = false"
  86. />
  87. </div>
  88. </q-card-section>
  89. <q-card-section>
  90. <div class="px-4">
  91. <template v-for="item in state.history.data">
  92. <q-timeline>
  93. <q-timeline-entry heading>
  94. <div class="text-base">{{ item.date }}</div>
  95. </q-timeline-entry>
  96. <template v-for="son in item.list">
  97. <template v-if="son.isCorrect == 0">
  98. <q-timeline-entry
  99. :subtitle="Hms(son.solvingTime)"
  100. icon="fa-solid fa-xmark "
  101. color="red"
  102. />
  103. </template>
  104. <template v-else-if="son.isCorrect == 1">
  105. <q-timeline-entry
  106. :subtitle="Hms(son.solvingTime)"
  107. icon="fa-solid fa-check "
  108. color="green"
  109. />
  110. </template>
  111. </template>
  112. </q-timeline>
  113. </template>
  114. </div>
  115. </q-card-section>
  116. </q-card>
  117. </q-dialog>
  118. </template>
  119. <script setup lang="ts">
  120. import { reactive } from 'vue'
  121. import { trainingCampPaperQuestionRelIpadHistoryRecords } from '@/api/modules/study'
  122. import { Hms } from '@/utils/czr-util'
  123. import { ElMessage } from 'element-plus'
  124. const props = defineProps({
  125. data: { default: () => [] },
  126. showVideo: { default: false },
  127. })
  128. const state: any = reactive({
  129. history: {
  130. show: false,
  131. data: [],
  132. },
  133. video: {
  134. show: false,
  135. url: '',
  136. name: '',
  137. },
  138. })
  139. const onHistory = (row) => {
  140. trainingCampPaperQuestionRelIpadHistoryRecords(row.questionId)
  141. .then((data: any) => {
  142. if (data?.length > 0) {
  143. // 按年月日分组
  144. const groupedData = data.reduce((acc, item) => {
  145. // 提取年月日部分(格式:YYYY-MM-DD)
  146. const datePart = item.solvingTime.split(' ')[0] // 取日期部分(去掉时间)
  147. // 查找是否已有该日期的分组
  148. const existingGroup = acc.find((group) => group.date === datePart)
  149. if (existingGroup) {
  150. // 如果已有该分组,添加到对应的 list 中
  151. existingGroup.list.push(item)
  152. } else {
  153. // 如果没有该分组,创建新分组
  154. acc.push({
  155. date: datePart,
  156. list: [item],
  157. })
  158. }
  159. return acc
  160. }, [])
  161. state.history.data = groupedData
  162. state.history.show = true
  163. } else {
  164. ElMessage.info('暂无历史做题记录!')
  165. }
  166. })
  167. .finally(() => {})
  168. }
  169. const onVideo = (row) => {
  170. state.video.url = row.aliyunVideoUrl
  171. state.video.name = row.fileName
  172. state.video.show = true
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. .question-card {
  177. transition: all 0.3s ease;
  178. }
  179. .question-card:hover {
  180. transform: translateY(-5px);
  181. box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  182. }
  183. </style>