MarkBoardInspect.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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="question-list tw-flex-grow tw-overflow-auto">
  22. <template
  23. v-for="({ groupNumber, selectiveIndex }, index) in groups"
  24. :key="index"
  25. >
  26. <div class="question-item tw-mb-4 tw-bg-white tw-p-4 tw-pl-5 tw-pr-3">
  27. <div v-if="selectiveIndex" class="question-item-select-group">
  28. {{ selectiveIndex }}
  29. </div>
  30. <div
  31. class="tw-flex tw-justify-between tw-place-items-center hover:tw-bg-gray-200"
  32. @mouseover="addFocusTrack(groupNumber, undefined, undefined)"
  33. @mouseleave="removeFocusTrack"
  34. >
  35. <span class="secondary-text">分组 {{ groupNumber }}</span>
  36. <input
  37. class="tw-my-auto"
  38. title="打回"
  39. type="checkbox"
  40. :checked="groupChecked(groupNumber)"
  41. @click="groupClicked(groupNumber)"
  42. />
  43. </div>
  44. <div v-if="questions">
  45. <template v-for="(question, index2) in questions" :key="index2">
  46. <div
  47. v-if="question.groupNumber === groupNumber"
  48. class="question tw-flex tw-place-items-center tw-mb-1 tw-font-bold hover:tw-bg-gray-200"
  49. :class="{ uncalculate: question.uncalculate }"
  50. @mouseover="
  51. addFocusTrack(
  52. undefined,
  53. question.mainNumber,
  54. question.subNumber
  55. )
  56. "
  57. @mouseleave="removeFocusTrack"
  58. >
  59. <a-tooltip placement="left">
  60. <template #title>
  61. <span>未计入总分</span>
  62. </template>
  63. <MinusCircleFilled class="uncalculate-icon" />
  64. </a-tooltip>
  65. <span class="question-title">
  66. {{ question.title }} {{ question.mainNumber }}-{{
  67. question.subNumber
  68. }}
  69. </span>
  70. <span class="tw-text-center question-score">
  71. {{ question.score === -1 ? "未选做" : question.score || 0 }}
  72. </span>
  73. <input
  74. :disabled="question.score === -1"
  75. title="打回"
  76. type="checkbox"
  77. :checked="questionChecked(question)"
  78. @change="questionCheckChanged(question)"
  79. />
  80. </div>
  81. </template>
  82. </div>
  83. </div>
  84. </template>
  85. </div>
  86. <div class="tw-flex tw-flex-shrink-0 tw-justify-center">
  87. <qm-button
  88. v-if="
  89. store.currentTask.inspectTime && store.currentTask.inspectTime > 0
  90. "
  91. type="primary"
  92. class="full-width-btn undo-btn"
  93. @click="reject"
  94. >
  95. 打回
  96. </qm-button>
  97. <qm-button
  98. v-else-if="checkedQuestions.length === 0"
  99. type="primary"
  100. class="full-width-btn"
  101. @click="inspect"
  102. >
  103. 复核
  104. </qm-button>
  105. <qm-button
  106. v-else
  107. type="primary"
  108. class="full-width-btn undo-btn"
  109. @click="reject"
  110. >打回</qm-button
  111. >
  112. </div>
  113. </div>
  114. <review-return-dialog
  115. v-model:visible="reviewReturnVisible"
  116. @confirmReturn="onConfirmReturn"
  117. />
  118. </template>
  119. <script setup lang="ts">
  120. import type { Question } from "@/types";
  121. import { message } from "ant-design-vue";
  122. import { MinusCircleOutlined, MinusCircleFilled } from "@ant-design/icons-vue";
  123. import { reactive, watch } from "vue";
  124. import { store } from "@/store/store";
  125. import {
  126. addFocusTrack,
  127. removeFocusTrack,
  128. } from "@/features/mark/use/focusTracks";
  129. import ReviewReturnDialog from "@/features/library/inspect/ReviewReturnDialog.vue";
  130. const emit = defineEmits(["inspect", "reject"]);
  131. let checkedQuestions: Question[] = reactive([]);
  132. let reviewReturnVisible = $ref(false);
  133. watch(
  134. () => store.currentTask,
  135. () => {
  136. checkedQuestions.splice(0);
  137. }
  138. );
  139. const groups = $computed(() => {
  140. const gs = store.currentTaskEnsured.questionList.reduce((gs, q) => {
  141. if (!gs[q.groupNumber]) {
  142. gs[q.groupNumber] = {
  143. groupNumber: q.groupNumber,
  144. selectiveIndex: q.selectiveIndex,
  145. };
  146. }
  147. return gs;
  148. }, {} as Record<number, { groupNumber: number; selectiveIndex: number | null }>);
  149. return Object.values(gs);
  150. });
  151. const questions = $computed(() => {
  152. const qs = store.currentTaskEnsured.questionList;
  153. return qs;
  154. });
  155. const markerScore = $computed(() => store.currentTaskEnsured.markerScore || 0);
  156. function addToCheckedQuestion(question: Question) {
  157. checkedQuestions.push(question);
  158. }
  159. function removeCheckedQuestion(question: Question) {
  160. const idx = checkedQuestions.indexOf(question);
  161. checkedQuestions.splice(idx, 1);
  162. }
  163. function groupChecked(groupNumber: number) {
  164. return (
  165. checkedQuestions.filter((q) => q.groupNumber === groupNumber).length ===
  166. questions?.filter((q) => q.groupNumber === groupNumber).length
  167. );
  168. }
  169. function questionChecked(question: Question) {
  170. return checkedQuestions.includes(question);
  171. }
  172. function questionCheckChanged(question: Question) {
  173. const checked = questionChecked(question);
  174. if (checked) {
  175. removeCheckedQuestion(question);
  176. } else {
  177. addToCheckedQuestion(question);
  178. }
  179. }
  180. function groupClicked(groupNumber: number) {
  181. if (groupChecked(groupNumber)) {
  182. checkedQuestions
  183. .filter((q) => q.groupNumber === groupNumber)
  184. .forEach((q) => {
  185. const idx = checkedQuestions.indexOf(q);
  186. checkedQuestions.splice(idx, 1);
  187. });
  188. } else {
  189. questions
  190. ?.filter((q) => q.groupNumber === groupNumber)
  191. .forEach((q) => {
  192. if (!questionChecked(q)) checkedQuestions.push(q);
  193. });
  194. }
  195. }
  196. function reject() {
  197. if (checkedQuestions.length === 0) {
  198. void message.warn({ content: "请先选择试题。" });
  199. return;
  200. }
  201. reviewReturnVisible = true;
  202. // emit("reject", checkedQuestions);
  203. }
  204. function inspect() {
  205. emit("inspect");
  206. }
  207. function onConfirmReturn(reason: string) {
  208. emit("reject", { questions: checkedQuestions, reason });
  209. }
  210. </script>
  211. <style scoped>
  212. .mark-board-track-container {
  213. display: flex;
  214. flex-direction: column;
  215. max-width: 290px;
  216. min-width: 290px;
  217. max-height: calc(100vh - 56px);
  218. z-index: 1001;
  219. transition: margin-right 0.5s;
  220. color: var(--app-small-header-text-color);
  221. }
  222. .mark-board-track-container.show {
  223. margin-right: 0;
  224. }
  225. .mark-board-track-container.hide {
  226. margin-right: -290px;
  227. }
  228. .top-container {
  229. background-color: var(--app-container-bg-color);
  230. height: 86px;
  231. border-radius: 5px;
  232. margin: 20px;
  233. margin-bottom: 0;
  234. color: white;
  235. background-color: var(--app-primary-button-bg-color);
  236. }
  237. .question-list {
  238. padding: 20px;
  239. }
  240. .question-item {
  241. border-radius: 5px;
  242. position: relative;
  243. }
  244. /** 选做题分组 */
  245. .question-item-select-group {
  246. position: absolute;
  247. left: -12px;
  248. top: -12px;
  249. width: 24px;
  250. height: 24px;
  251. background: #d3d9e6;
  252. border-radius: 12px 12px 4px 12px;
  253. color: #435488;
  254. text-align: center;
  255. line-height: 24px;
  256. font-size: 12px;
  257. font-weight: bold;
  258. }
  259. .total-score {
  260. color: var(--app-main-text-color);
  261. font-size: 32px;
  262. }
  263. .question {
  264. min-width: 80px;
  265. background-color: var(--app-container-bg-color);
  266. }
  267. .question-title {
  268. flex: 1;
  269. }
  270. .question-score {
  271. flex-basis: 56px;
  272. padding: 0 3px;
  273. }
  274. .question.uncalculate {
  275. position: relative;
  276. }
  277. .question .uncalculate-icon {
  278. display: none;
  279. color: red;
  280. position: absolute;
  281. font-size: 15px;
  282. left: -16px;
  283. top: 0.3em;
  284. }
  285. .question.uncalculate .uncalculate-icon {
  286. display: block;
  287. }
  288. .full-width-btn {
  289. width: 100%;
  290. border-radius: 20px;
  291. }
  292. .undo-btn {
  293. background-color: var(--app-undo-button-bg-color);
  294. border-color: var(--app-undo-button-bg-color);
  295. }
  296. </style>