MarkBoardInspect.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div
  3. v-if="store.currentTask"
  4. class="mark-board-track-container"
  5. :class="[store.setting.uiSetting['score.board.collapse'] ? '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. const emit = defineEmits(["inspect", "reject"]);
  115. let checkedQuestions = reactive([] as Array<Question>);
  116. watch(
  117. () => store.currentTask,
  118. () => {
  119. checkedQuestions.splice(0);
  120. }
  121. );
  122. let groups = $computed(() => {
  123. const gs = store.currentTask?.questionList.map((q) => q.groupNumber);
  124. return [...new Set(gs)].sort((a, b) => a - b);
  125. });
  126. let questions = $computed(() => {
  127. const qs = store.currentTask?.questionList;
  128. return qs;
  129. });
  130. let markerScore = $computed(() => store.currentTask?.markerScore || 0);
  131. function addToCheckedQuestion(question: Question) {
  132. checkedQuestions.push(question);
  133. }
  134. function removeCheckedQuestion(question: Question) {
  135. const idx = checkedQuestions.indexOf(question);
  136. checkedQuestions.splice(idx, 1);
  137. }
  138. function groupChecked(groupNumber: number) {
  139. return (
  140. checkedQuestions.filter((q) => q.groupNumber === groupNumber).length ===
  141. questions?.filter((q) => q.groupNumber === groupNumber).length
  142. );
  143. }
  144. function questionChecked(question: Question) {
  145. return checkedQuestions.includes(question);
  146. }
  147. function questionCheckChanged(question: Question) {
  148. const checked = questionChecked(question);
  149. if (checked) {
  150. removeCheckedQuestion(question);
  151. } else {
  152. addToCheckedQuestion(question);
  153. }
  154. }
  155. function groupClicked(groupNumber: number) {
  156. if (groupChecked(groupNumber)) {
  157. checkedQuestions
  158. .filter((q) => q.groupNumber === groupNumber)
  159. .forEach((q) => {
  160. const idx = checkedQuestions.indexOf(q);
  161. checkedQuestions.splice(idx, 1);
  162. });
  163. } else {
  164. questions
  165. ?.filter((q) => q.groupNumber === groupNumber)
  166. .forEach((q) => {
  167. if (!questionChecked(q)) checkedQuestions.push(q);
  168. });
  169. }
  170. }
  171. function addFocusTrack(
  172. groupNumber: number | undefined,
  173. mainNumber: number | undefined,
  174. subNumber: string | undefined
  175. ) {
  176. store.focusTracks.splice(0);
  177. if (groupNumber) {
  178. questions
  179. ?.filter((q) => q.groupNumber === groupNumber)
  180. ?.map((q) => q.trackList)
  181. .reduce((acc, ts) => acc.concat(ts))
  182. .forEach((t) => {
  183. store.focusTracks.push(t);
  184. });
  185. } else {
  186. questions
  187. ?.map((q) => q.trackList)
  188. .reduce((acc, ts) => acc.concat(ts))
  189. .filter((t) => {
  190. if (mainNumber) {
  191. return t.mainNumber === mainNumber && t.subNumber === subNumber;
  192. } else {
  193. return false;
  194. }
  195. })
  196. .forEach((t) => {
  197. store.focusTracks.push(t);
  198. });
  199. }
  200. // console.log(store.focusTracks);
  201. }
  202. function removeFocusTrack() {
  203. store.focusTracks.splice(0);
  204. }
  205. function reject() {
  206. if (checkedQuestions.length === 0) {
  207. message.warn({ content: "请先选择试题。" });
  208. return;
  209. }
  210. emit("reject", checkedQuestions);
  211. }
  212. function inspect() {
  213. emit("inspect");
  214. }
  215. </script>
  216. <style scoped>
  217. .mark-board-track-container {
  218. display: flex;
  219. flex-direction: column;
  220. max-width: 290px;
  221. min-width: 290px;
  222. max-height: calc(100vh - 56px);
  223. padding: 20px;
  224. z-index: 1001;
  225. transition: margin-right 0.5s;
  226. color: var(--app-small-header-text-color);
  227. }
  228. .mark-board-track-container.show {
  229. margin-right: 0;
  230. }
  231. .mark-board-track-container.hide {
  232. margin-right: -290px;
  233. }
  234. .top-container {
  235. background-color: var(--app-container-bg-color);
  236. height: 86px;
  237. border-radius: 5px;
  238. color: white;
  239. background-color: var(--app-primary-button-bg-color);
  240. }
  241. .total-score {
  242. color: var(--app-main-text-color);
  243. font-size: 32px;
  244. }
  245. .question {
  246. min-width: 80px;
  247. background-color: var(--app-container-bg-color);
  248. }
  249. .current-question .score {
  250. color: var(--high-light-score-color);
  251. }
  252. .current-score {
  253. color: var(--app-score-color);
  254. }
  255. .current-score-indicator {
  256. position: absolute;
  257. top: 0;
  258. left: 0;
  259. width: 5px;
  260. height: 5px;
  261. background-color: #5c69f6;
  262. }
  263. .all-zero-unselective-button {
  264. border-radius: 10px;
  265. padding: 7px;
  266. background-color: #4db9ff;
  267. border: none;
  268. }
  269. .full-width-btn {
  270. width: 100%;
  271. border-radius: 20px;
  272. }
  273. .undo-btn {
  274. background-color: var(--app-undo-button-bg-color);
  275. border-color: var(--app-undo-button-bg-color);
  276. }
  277. </style>