MarkBoardInspect.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. class="star"
  22. :class="props.tagged ? 'star-yes' : 'star-no'"
  23. @click="makeTag(!props.tagged)"
  24. ></div>
  25. </div>
  26. <div class="tw-flex-grow tw-overflow-auto tw-my-5" v-if="groups">
  27. <template v-for="(groupNumber, index) in groups" :key="index">
  28. <div class="tw-mb-4 tw-bg-white tw-p-4">
  29. <div
  30. class="
  31. tw-flex tw-justify-between tw-place-items-center
  32. hover:tw-bg-gray-200
  33. "
  34. @mouseover="addFocusTrack(groupNumber, undefined, undefined)"
  35. @mouseleave="removeFocusTrack"
  36. >
  37. <span class="secondary-text">分组 {{ groupNumber }}</span>
  38. </div>
  39. <div v-if="questions">
  40. <template v-for="(question, index) in questions" :key="index">
  41. <div
  42. v-if="question.groupNumber === groupNumber"
  43. class="
  44. question
  45. tw-flex tw-place-items-center tw-mb-1 tw-font-bold
  46. hover:tw-bg-gray-200
  47. "
  48. @mouseover="
  49. addFocusTrack(
  50. undefined,
  51. question.mainNumber,
  52. question.subNumber
  53. )
  54. "
  55. @mouseleave="removeFocusTrack"
  56. >
  57. <span class="tw-flex-1">
  58. {{ question.title }} {{ question.mainNumber }}-{{
  59. question.subNumber
  60. }}
  61. </span>
  62. <span class="tw-flex-1 tw-text-center">
  63. {{ question.score === -1 ? "未选做" : question.score || 0 }}
  64. </span>
  65. </div>
  66. </template>
  67. </div>
  68. </div>
  69. </template>
  70. </div>
  71. <div class="tw-flex tw-flex-shrink-0 tw-justify-center tw-gap-4">
  72. <a-button
  73. type="primary"
  74. class="full-width-btn"
  75. :disabled="props.isFirst"
  76. @click="fetchTask(false)"
  77. >
  78. 上一个
  79. </a-button>
  80. <a-button
  81. @click="fetchTask(true)"
  82. type="primary"
  83. class="full-width-btn"
  84. :disabled="props.isLast"
  85. >下一个</a-button
  86. >
  87. </div>
  88. </div>
  89. </template>
  90. <script setup lang="ts">
  91. import type { Question } from "@/types";
  92. import { computed, reactive, watch } from "vue";
  93. import { store } from "@/store/store";
  94. const emit = defineEmits(["makeTag", "fetchTask"]);
  95. const props =
  96. defineProps<{ tagged: boolean; isFirst: boolean; isLast: boolean }>();
  97. let checkedQuestions = reactive([] as Array<Question>);
  98. watch(
  99. () => store.currentTask,
  100. () => {
  101. checkedQuestions.splice(0);
  102. }
  103. );
  104. const groups = computed(() => {
  105. const gs = store.currentTask?.questionList.map((q) => q.groupNumber);
  106. return [...new Set(gs)].sort((a, b) => a - b);
  107. });
  108. const questions = computed(() => {
  109. const qs = store.currentTask?.questionList;
  110. return qs;
  111. });
  112. const markerScore = computed(() => store.currentTask?.markerScore || 0);
  113. function addToCheckedQuestion(question: Question) {
  114. checkedQuestions.push(question);
  115. }
  116. function removeCheckedQuestion(question: Question) {
  117. const idx = checkedQuestions.indexOf(question);
  118. checkedQuestions.splice(idx, 1);
  119. }
  120. function groupChecked(groupNumber: number) {
  121. return (
  122. checkedQuestions.filter((q) => q.groupNumber === groupNumber).length ===
  123. questions.value?.filter((q) => q.groupNumber === groupNumber).length
  124. );
  125. }
  126. function questionChecked(question: Question) {
  127. return checkedQuestions.includes(question);
  128. }
  129. function questionCheckChanged(question: Question) {
  130. const checked = questionChecked(question);
  131. if (checked) {
  132. removeCheckedQuestion(question);
  133. } else {
  134. addToCheckedQuestion(question);
  135. }
  136. }
  137. function groupClicked(groupNumber: number) {
  138. if (groupChecked(groupNumber)) {
  139. checkedQuestions
  140. .filter((q) => q.groupNumber === groupNumber)
  141. .forEach((q) => {
  142. const idx = checkedQuestions.indexOf(q);
  143. checkedQuestions.splice(idx, 1);
  144. });
  145. } else {
  146. questions.value
  147. ?.filter((q) => q.groupNumber === groupNumber)
  148. .forEach((q) => {
  149. if (!questionChecked(q)) checkedQuestions.push(q);
  150. });
  151. }
  152. }
  153. function addFocusTrack(
  154. groupNumber: number | undefined,
  155. mainNumber: number | undefined,
  156. subNumber: string | undefined
  157. ) {
  158. store.focusTracks.splice(0);
  159. if (groupNumber) {
  160. questions.value
  161. ?.filter((q) => q.groupNumber === groupNumber)
  162. ?.map((q) => q.trackList)
  163. .reduce((acc, ts) => acc.concat(ts))
  164. .forEach((t) => {
  165. store.focusTracks.push(t);
  166. });
  167. } else {
  168. questions.value
  169. ?.map((q) => q.trackList)
  170. .reduce((acc, ts) => acc.concat(ts))
  171. .filter((t) => {
  172. if (mainNumber) {
  173. return t.mainNumber === mainNumber && t.subNumber === subNumber;
  174. } else {
  175. return false;
  176. }
  177. })
  178. .forEach((t) => {
  179. store.focusTracks.push(t);
  180. });
  181. }
  182. // console.log(store.focusTracks);
  183. }
  184. function removeFocusTrack() {
  185. store.focusTracks.splice(0);
  186. }
  187. function fetchTask(next: boolean) {
  188. emit("fetchTask", next);
  189. }
  190. function makeTag(isTag: boolean) {
  191. emit("makeTag", isTag);
  192. }
  193. </script>
  194. <style scoped>
  195. .mark-board-track-container {
  196. display: flex;
  197. flex-direction: column;
  198. max-width: 290px;
  199. min-width: 290px;
  200. max-height: calc(100vh - 56px);
  201. padding: 20px;
  202. z-index: 1001;
  203. transition: margin-right 0.5s;
  204. color: var(--app-small-header-text-color);
  205. }
  206. .mark-board-track-container.show {
  207. margin-right: 0;
  208. }
  209. .mark-board-track-container.hide {
  210. margin-right: -290px;
  211. }
  212. .top-container {
  213. background-color: var(--app-container-bg-color);
  214. height: 86px;
  215. border-radius: 5px;
  216. color: white;
  217. background-color: var(--app-primary-button-bg-color);
  218. }
  219. .total-score {
  220. color: var(--app-main-text-color);
  221. font-size: 32px;
  222. }
  223. .question {
  224. min-width: 80px;
  225. background-color: var(--app-container-bg-color);
  226. }
  227. .current-question .score {
  228. color: var(--high-light-score-color);
  229. }
  230. .current-score {
  231. color: var(--app-score-color);
  232. }
  233. .current-score-indicator {
  234. position: absolute;
  235. top: 0;
  236. left: 0;
  237. width: 5px;
  238. height: 5px;
  239. background-color: #5c69f6;
  240. }
  241. .all-zero-unselective-button {
  242. border-radius: 10px;
  243. padding: 7px;
  244. background-color: #4db9ff;
  245. border: none;
  246. }
  247. .full-width-btn {
  248. width: 100%;
  249. border-radius: 20px;
  250. }
  251. .undo-btn {
  252. background-color: var(--app-undo-button-bg-color);
  253. border-color: var(--app-undo-button-bg-color);
  254. }
  255. .star {
  256. margin-top: -30px;
  257. margin-right: 20px;
  258. width: 30px;
  259. height: 30px;
  260. cursor: pointer;
  261. clip-path: polygon(
  262. 50% 0%,
  263. 61% 35%,
  264. 98% 35%,
  265. 68% 57%,
  266. 79% 91%,
  267. 50% 70%,
  268. 21% 91%,
  269. 32% 57%,
  270. 2% 35%,
  271. 39% 35%
  272. );
  273. }
  274. .star.star-yes {
  275. background-color: yellowgreen;
  276. }
  277. .star.star-no {
  278. background-color: white;
  279. }
  280. </style>