MarkBoardInspect.vue 8.8 KB

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