MarkBoardInspect.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div
  3. v-if="store.currentTask"
  4. class="mark-board-track-container"
  5. :class="[store.isScoreBoardCollapsed ? 'hide' : 'show']"
  6. >
  7. <div class="top-container tw-flex-shrink-0 tw-flex tw-items-center">
  8. <div class="tw-flex tw-flex-col tw-flex-1 tw-text-center">
  9. <div class="tw-flex tw-justify-center">
  10. <img
  11. src="../../mark/images/totalscore.png"
  12. style="width: 13px; height: 16px"
  13. />
  14. </div>
  15. <div>试卷总分</div>
  16. </div>
  17. <div class="tw-flex-1" style="font-size: 40px">
  18. {{ markerScore > 0 ? markerScore : 0 }}
  19. </div>
  20. </div>
  21. <div class="tw-flex-grow tw-overflow-auto tw-my-5" v-if="groups">
  22. <template v-for="(groupNumber, index) in groups" :key="index">
  23. <div class="tw-mb-4 tw-bg-white tw-p-4">
  24. <div
  25. class="
  26. tw-flex tw-justify-between tw-place-items-center
  27. hover:tw-bg-gray-200
  28. "
  29. @mouseover="addFocusTrack(groupNumber, undefined, undefined)"
  30. @mouseleave="removeFocusTrack"
  31. >
  32. <span class="secondary-text">分组 {{ groupNumber }}</span>
  33. <input
  34. class="tw-my-auto"
  35. title="打回"
  36. type="checkbox"
  37. @click="groupClicked(groupNumber)"
  38. :checked="groupChecked(groupNumber)"
  39. />
  40. </div>
  41. <div v-if="questions">
  42. <template v-for="(question, index) in questions" :key="index">
  43. <div
  44. v-if="question.groupNumber === groupNumber"
  45. class="
  46. question
  47. tw-flex tw-place-items-center tw-mb-1 tw-font-bold
  48. hover:tw-bg-gray-200
  49. "
  50. @mouseover="
  51. addFocusTrack(
  52. undefined,
  53. question.mainNumber,
  54. question.subNumber
  55. )
  56. "
  57. @mouseleave="removeFocusTrack"
  58. >
  59. <span class="tw-flex-1">
  60. {{ question.title }} {{ question.mainNumber }}-{{
  61. question.subNumber
  62. }}
  63. </span>
  64. <span class="tw-flex-1 tw-text-center">
  65. {{ question.score === -1 ? "未选做" : question.score || 0 }}
  66. </span>
  67. <input
  68. :disabled="question.score === -1"
  69. title="打回"
  70. type="checkbox"
  71. @change="questionCheckChanged(question)"
  72. :checked="questionChecked(question)"
  73. />
  74. </div>
  75. </template>
  76. </div>
  77. </div>
  78. </template>
  79. </div>
  80. <div class="tw-flex tw-flex-shrink-0 tw-justify-center">
  81. <qm-button
  82. type="primary"
  83. class="full-width-btn undo-btn"
  84. v-if="
  85. store.currentTask.inspectTime && store.currentTask.inspectTime > 0
  86. "
  87. @click="reject"
  88. >
  89. 打回
  90. </qm-button>
  91. <qm-button
  92. v-else-if="checkedQuestions.length === 0"
  93. @click="inspect"
  94. type="primary"
  95. class="full-width-btn"
  96. >
  97. 复核
  98. </qm-button>
  99. <qm-button
  100. v-else
  101. @click="reject"
  102. type="primary"
  103. class="full-width-btn undo-btn"
  104. >打回</qm-button
  105. >
  106. </div>
  107. </div>
  108. </template>
  109. <script setup lang="ts">
  110. import type { Question } from "@/types";
  111. import { message } from "ant-design-vue";
  112. import { reactive, watch } from "vue";
  113. import { store } from "@/store/store";
  114. import {
  115. addFocusTrack,
  116. removeFocusTrack,
  117. } from "@/features/mark/use/focusTracks";
  118. const emit = defineEmits(["inspect", "reject"]);
  119. let checkedQuestions: Question[] = reactive([]);
  120. watch(
  121. () => store.currentTask,
  122. () => {
  123. checkedQuestions.splice(0);
  124. }
  125. );
  126. let groups = $computed(() => {
  127. const gs = store.currentTask?.questionList.map((q) => q.groupNumber);
  128. return [...new Set(gs)].sort((a, b) => a - b);
  129. });
  130. let questions = $computed(() => {
  131. const qs = store.currentTask?.questionList;
  132. return qs;
  133. });
  134. let markerScore = $computed(() => store.currentTask?.markerScore || 0);
  135. function addToCheckedQuestion(question: Question) {
  136. checkedQuestions.push(question);
  137. }
  138. function removeCheckedQuestion(question: Question) {
  139. const idx = checkedQuestions.indexOf(question);
  140. checkedQuestions.splice(idx, 1);
  141. }
  142. function groupChecked(groupNumber: number) {
  143. return (
  144. checkedQuestions.filter((q) => q.groupNumber === groupNumber).length ===
  145. questions?.filter((q) => q.groupNumber === groupNumber).length
  146. );
  147. }
  148. function questionChecked(question: Question) {
  149. return checkedQuestions.includes(question);
  150. }
  151. function questionCheckChanged(question: Question) {
  152. const checked = questionChecked(question);
  153. if (checked) {
  154. removeCheckedQuestion(question);
  155. } else {
  156. addToCheckedQuestion(question);
  157. }
  158. }
  159. function groupClicked(groupNumber: number) {
  160. if (groupChecked(groupNumber)) {
  161. checkedQuestions
  162. .filter((q) => q.groupNumber === groupNumber)
  163. .forEach((q) => {
  164. const idx = checkedQuestions.indexOf(q);
  165. checkedQuestions.splice(idx, 1);
  166. });
  167. } else {
  168. questions
  169. ?.filter((q) => q.groupNumber === groupNumber)
  170. .forEach((q) => {
  171. if (!questionChecked(q)) checkedQuestions.push(q);
  172. });
  173. }
  174. }
  175. function reject() {
  176. if (checkedQuestions.length === 0) {
  177. message.warn({ content: "请先选择试题。" });
  178. return;
  179. }
  180. emit("reject", checkedQuestions);
  181. }
  182. function inspect() {
  183. emit("inspect");
  184. }
  185. </script>
  186. <style scoped>
  187. .mark-board-track-container {
  188. display: flex;
  189. flex-direction: column;
  190. max-width: 290px;
  191. min-width: 290px;
  192. max-height: calc(100vh - 56px);
  193. padding: 20px;
  194. z-index: 1001;
  195. transition: margin-right 0.5s;
  196. color: var(--app-small-header-text-color);
  197. }
  198. .mark-board-track-container.show {
  199. margin-right: 0;
  200. }
  201. .mark-board-track-container.hide {
  202. margin-right: -290px;
  203. }
  204. .top-container {
  205. background-color: var(--app-container-bg-color);
  206. height: 86px;
  207. border-radius: 5px;
  208. color: white;
  209. background-color: var(--app-primary-button-bg-color);
  210. }
  211. .total-score {
  212. color: var(--app-main-text-color);
  213. font-size: 32px;
  214. }
  215. .question {
  216. min-width: 80px;
  217. background-color: var(--app-container-bg-color);
  218. }
  219. .full-width-btn {
  220. width: 100%;
  221. border-radius: 20px;
  222. }
  223. .undo-btn {
  224. background-color: var(--app-undo-button-bg-color);
  225. border-color: var(--app-undo-button-bg-color);
  226. }
  227. </style>