exam-stats-card.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <teleport to="body">
  4. <!-- #endif -->
  5. <!-- #ifdef MP-WEIXIN -->
  6. <root-portal externalClass="theme-ie">
  7. <!-- #endif -->
  8. <uv-popup ref="popupRef" mode="bottom" :close-on-click-overlay="true" :closeable="false" :round="16">
  9. <view class="theme-ie w-auto box-border bg-white">
  10. <view class="popup-header">
  11. <view class="popup-header-left">
  12. <uv-icon name="calendar" size="26" />
  13. <view class="popup-header-left-title">
  14. <text>答题卡</text>
  15. <view class="ml-20">
  16. <text class="text-30 text-primary">{{ doneCount }}</text>
  17. <text>/</text>
  18. <text class="text-30 text-fore-light">{{ virtualTotalCount }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="popup-header-right">
  23. <block v-if="!readonly">
  24. <view class="stats-dot stats-dot-done">已答</view>
  25. <view class="stats-dot stats-dot-not-done">未答</view>
  26. <view class="stats-dot stats-dot-not-know">不会</view>
  27. </block>
  28. <block v-else>
  29. <view class="stats-dot stats-dot-correct">答对</view>
  30. <view class="stats-dot stats-dot-incorrect">答错</view>
  31. <view class="stats-dot stats-dot-not-done">未答</view>
  32. </block>
  33. </view>
  34. </view>
  35. <view class="popup-content">
  36. <view class="flex-1 min-h-1">
  37. <scroll-view class="h-full" scroll-y>
  38. <view v-for="(item, i) in groupedQuestionList" :key="i" class="">
  39. <template v-if="item.list.length > 0">
  40. <view class="h-70 bg-back px-20 leading-70 text-fore-subcontent sticky top-0 z-1">
  41. {{ questionTypeDesc[item.type] }}
  42. </view>
  43. <view class="grid grid-cols-5 place-items-center gap-x-20 gap-y-30 p-30 relative z-0">
  44. <view v-for="(qs, j) in item.list" :key="j" class="aspect-square flex items-center justify-center"
  45. @click="hanadleNavigate(qs.question, qs.index)">
  46. <view
  47. class="w-74 h-74 rounded-full flex items-center justify-center bg-white border border-solid border-border relative"
  48. :class="{
  49. 'is-done': !isViewMode && qs.question.isDone,
  50. 'is-not-know': !isViewMode && qs.question.isNotKnow,
  51. 'is-mark': !isViewMode && qs.question.isMark,
  52. 'is-correct': isViewMode && qs.question.isCorrect,
  53. 'is-incorrect': isViewMode && !qs.question.isCorrect,
  54. }">
  55. <text class="z-1 font-bold text-32">{{ qs.index + 1 }}</text>
  56. <ie-image v-if="qs.question.isMark" src="/pagesStudy/static/image/icon-mark-active.png"
  57. custom-class="absolute -top-12 left-14 w-28 h-28 z-1" mode="aspectFill" />
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. </view>
  63. </scroll-view>
  64. </view>
  65. <view v-if="!isViewMode" class="h-150 bg-white flex items-center gap-x-120 px-40">
  66. <view class="flex flex-col items-center gap-x-10" @click="handleReset">
  67. <uv-icon name="reload" size="20" :color="doneCount > 0 ? '#999' : '#cccccc'" />
  68. <text class="mt-4 text-20 text-subcontent" :class="{ 'text-fore-light': doneCount <= 0 }">重新作答</text>
  69. </view>
  70. <view class="flex-1 py-20 text-center rounded-full bg-primary text-white" @click="handleSubmit">交卷</view>
  71. </view>
  72. </view>
  73. </view>
  74. </uv-popup>
  75. <!-- #ifdef MP-WEIXIN -->
  76. </root-portal>
  77. <!-- #endif -->
  78. <!-- #ifdef H5 -->
  79. </teleport>
  80. <!-- #endif -->
  81. </template>
  82. <script lang="ts" setup>
  83. import { useExam } from '@/composables/useExam';
  84. import { Study, Transfer } from '@/types';
  85. import { EXAM_DATA } from '@/types/injectionSymbols';
  86. import { EXAM_PAGE_OPTIONS } from '@/types/injectionSymbols';
  87. const props = defineProps<{
  88. readonly?: boolean;
  89. }>();
  90. const examData = inject(EXAM_DATA) || {} as ReturnType<typeof useExam>;
  91. const { doneCount, virtualTotalCount, groupedQuestionList, questionTypeDesc, reset, startTiming, stopTiming, changeIndex, setSubQuestionIndex } = examData;
  92. const examPageOptions = inject(EXAM_PAGE_OPTIONS) || {} as Transfer.ExamAnalysisPageOptions;
  93. const isViewMode = computed(() => {
  94. return examPageOptions?.readonly || false;
  95. });
  96. const popupRef = ref();
  97. const open = () => {
  98. popupRef.value.open();
  99. }
  100. const close = () => {
  101. popupRef.value.close();
  102. }
  103. defineExpose({
  104. open,
  105. close
  106. });
  107. const handleReset = () => {
  108. if (doneCount.value <= 0) {
  109. return;
  110. }
  111. stopTiming();
  112. uni.$ie.showModal({
  113. title: '重新作答',
  114. content: '是否确认清空全部作答数据?',
  115. }).then(confirm => {
  116. if (confirm) {
  117. close();
  118. reset();
  119. setTimeout(() => {
  120. startTiming();
  121. }, 300);
  122. } else {
  123. startTiming();
  124. }
  125. });
  126. }
  127. const emit = defineEmits<{
  128. (e: 'submit'): void;
  129. }>();
  130. const handleSubmit = () => {
  131. emit('submit');
  132. }
  133. const hanadleNavigate = (question: Study.Question, index: number) => {
  134. if (question.isSubQuestion) {
  135. changeIndex(question.parentIndex || 0, question.subIndex || 0);
  136. } else {
  137. changeIndex(index);
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .popup-header {
  143. @apply px-30 h-120 flex items-center justify-between;
  144. }
  145. .popup-header-left {
  146. @apply flex items-center;
  147. }
  148. .popup-header-left-title {
  149. @apply flex items-center text-30 text-fore-title font-bold;
  150. }
  151. .popup-header-right {
  152. @apply flex items-center gap-x-60;
  153. }
  154. .stats-dot {
  155. @apply relative text-22 text-fore-light;
  156. &::before {
  157. @apply content-[''] absolute top-6 -left-30 w-18 h-18 rounded-full;
  158. }
  159. &.stats-dot-done {
  160. &::before {
  161. @apply bg-primary;
  162. }
  163. }
  164. &.stats-dot-not-done {
  165. &::before {
  166. @apply w-14 h-14 border-2 border-solid border-back;
  167. }
  168. }
  169. &.stats-dot-not-know {
  170. &::before {
  171. @apply bg-back;
  172. }
  173. }
  174. &.stats-dot-correct {
  175. &::before {
  176. @apply bg-[#2CC6A0];
  177. }
  178. }
  179. &.stats-dot-incorrect {
  180. &::before {
  181. @apply bg-[#FF5B5C];
  182. }
  183. }
  184. }
  185. .popup-content {
  186. @apply h-[48vh] flex flex-col;
  187. }
  188. .scroll-view {
  189. @apply h-full;
  190. }
  191. .is-done {
  192. @apply text-primary border-[#EBF9FF] bg-[#EBF9FF];
  193. }
  194. .is-not-know {
  195. @apply text-fore-title border-[#F2F2F2] bg-[#F2F2F2];
  196. }
  197. .is-correct {
  198. @apply text-[#2CC6A0] border-[#E7FCF8] bg-[#E7FCF8];
  199. }
  200. .is-incorrect {
  201. @apply text-[#FF5B5C] border-[#FEEDE9] bg-[#FEEDE9];
  202. }
  203. </style>