MarkBoardInspect.vue 7.7 KB

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