MarkBoardInspect.vue 6.7 KB

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