MarkBoardMouse.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div
  3. v-if="markStore.currentTask"
  4. class="mark-board-track is-mouse-board"
  5. :class="[
  6. markStore.isTrackMode && markStore.isScoreBoardCollapsed
  7. ? 'hide'
  8. : 'show',
  9. ]"
  10. >
  11. <div class="board-mode">
  12. <a-select
  13. v-model:value="normalMode"
  14. style="width: 120px"
  15. @change="normalModeChange"
  16. >
  17. <a-select-option value="keyboard">键盘给分</a-select-option>
  18. <a-select-option value="mouse">鼠标给分</a-select-option>
  19. </a-select>
  20. </div>
  21. <div class="board-header">
  22. <div class="board-header-left">
  23. <div class="board-header-info">
  24. <img src="@/assets/icons/icon-star.svg" /><span>总分</span>
  25. </div>
  26. <div class="board-header-score">
  27. <transition-group name="score-number-animation" tag="span">
  28. <span :key="markStore.currentTask.markResult?.markerScore || 0">{{
  29. markStore.currentTask.markResult?.markerScore
  30. }}</span>
  31. </transition-group>
  32. </div>
  33. </div>
  34. <qm-button
  35. v-if="props.isCheckAnswer && !hasModifyScore"
  36. class="board-header-submit"
  37. size="medium"
  38. type="primary"
  39. @click="checkSubmit"
  40. >
  41. 复核
  42. </qm-button>
  43. <qm-button
  44. v-else
  45. class="board-header-submit"
  46. size="medium"
  47. type="primary"
  48. @click="submit"
  49. >
  50. 提交
  51. </qm-button>
  52. </div>
  53. <div
  54. v-if="markStore.currentTask && markStore.currentTask.questionList"
  55. class="board-questions"
  56. :style="{
  57. flexGrow: 2,
  58. }"
  59. >
  60. <template
  61. v-for="(question, index) in markStore.currentTask.questionList"
  62. :key="index"
  63. >
  64. <div class="board-question-full-box">
  65. <div
  66. :id="'bq-' + question.mainNumber + '-' + question.subNumber"
  67. :class="[
  68. 'board-question',
  69. {
  70. 'is-current': isCurrentQuestion(question),
  71. 'is-disabled': isDisabledQuestion(question),
  72. },
  73. ]"
  74. @click="chooseQuestion(question)"
  75. >
  76. <div class="question-info">
  77. <div class="question-title" :title="question.title">
  78. {{ question.title }}
  79. </div>
  80. <div class="question-no">
  81. {{ question.mainNumber }}-{{ question.subNumber }}
  82. </div>
  83. </div>
  84. <div v-if="question.problem" class="question-score is-problem">
  85. 问题卷
  86. </div>
  87. <div
  88. v-else-if="isArbitrated(question)"
  89. class="question-score is-problem"
  90. >
  91. {{ getArbitratedStatusName(question) }}
  92. </div>
  93. <div v-else-if="!question.selfMark" class="question-score">
  94. 已评
  95. </div>
  96. <div v-else class="board-scores">
  97. <div
  98. v-for="(s, i) in questionScoreSteps(question)"
  99. :key="i"
  100. :class="[
  101. 'board-score',
  102. { 'is-current': isCurrentScore(question, s) },
  103. ]"
  104. @click="chooseScore(question, s)"
  105. >
  106. {{ s }}
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </template>
  112. </div>
  113. <div
  114. v-if="!isCheckAnswer && markStore.currentQuestion?.selfMark"
  115. class="board-footer"
  116. >
  117. <qm-button
  118. v-if="markStore.currentQuestion?.problem"
  119. class="board-clear"
  120. @click="cancelProblemQuestion"
  121. >
  122. 取消问题卷
  123. </qm-button>
  124. <qm-button v-else class="board-clear" @click="toMarkProblemQuestion">
  125. 标记问题卷
  126. </qm-button>
  127. </div>
  128. </div>
  129. </template>
  130. <script setup lang="ts">
  131. import { ref } from "vue";
  132. import type { Question } from "@/types";
  133. import { useMarkStore } from "@/store";
  134. import useAutoChooseFirstQuestion from "../composables/useAutoChooseFirstQuestion";
  135. import useQuestion from "../composables/useQuestion";
  136. import useMakeTrack from "../composables/useMakeTrack";
  137. const markStore = useMarkStore();
  138. const {
  139. isDisabledQuestion,
  140. isArbitrated,
  141. getArbitratedStatusName,
  142. cancelProblemQuestion,
  143. toMarkProblemQuestion,
  144. } = useQuestion();
  145. const { chooseQuestion } = useAutoChooseFirstQuestion();
  146. const { makeCommonTrack } = useMakeTrack();
  147. const emit = defineEmits([
  148. "submit",
  149. "allZeroSubmit",
  150. "unselectiveSubmit",
  151. "checkSubmit",
  152. ]);
  153. const props = defineProps<{ isCheckAnswer?: boolean }>();
  154. const hasModifyScore = ref(false);
  155. // 切换给分模式
  156. const normalMode = ref(markStore.setting.uiSetting["normal.mode"] || "mouse");
  157. function normalModeChange(value: string) {
  158. markStore.setting.uiSetting["normal.mode"] = value;
  159. }
  160. function isCurrentQuestion(question: Question) {
  161. return (
  162. markStore.currentQuestion?.mainNumber === question.mainNumber &&
  163. markStore.currentQuestion?.subNumber === question.subNumber
  164. );
  165. }
  166. function chooseScore(question: Question, score: number) {
  167. if (isDisabledQuestion(question)) return;
  168. // 只要修改了分值,就当做已修改
  169. hasModifyScore.value = true;
  170. makeCommonTrack(question, score);
  171. }
  172. function isCurrentScore(question: Question, score: number) {
  173. const { __index } = question;
  174. const questionScore =
  175. markStore.currentTask &&
  176. markStore.currentTask.markResult &&
  177. markStore.currentTask.markResult.scoreList[__index];
  178. return questionScore === score;
  179. }
  180. function questionScoreSteps(question: Question) {
  181. if (!question) return [];
  182. const remainScore = Math.round(question.maxScore * 100) / 100;
  183. const steps = [];
  184. for (
  185. let i = 0;
  186. i <= remainScore;
  187. i = Math.round(i * 100 + question.intervalScore * 100) / 100
  188. ) {
  189. steps.push(i);
  190. }
  191. if (
  192. Math.round(remainScore * 100) % Math.round(question.intervalScore * 100) !==
  193. 0
  194. ) {
  195. steps.push(remainScore);
  196. }
  197. return steps;
  198. }
  199. function submit() {
  200. emit("submit");
  201. }
  202. function checkSubmit() {
  203. emit("checkSubmit");
  204. }
  205. const buttonHeightForSelective = $computed(() =>
  206. markStore.setting.selective && markStore.setting.enableAllZero
  207. ? "36px"
  208. : "76px"
  209. );
  210. </script>
  211. <style scoped>
  212. .mark-board-track-container {
  213. max-width: 290px;
  214. min-width: 290px;
  215. padding: 20px;
  216. max-height: calc(100vh - 56px - 0px);
  217. overflow: auto;
  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. }
  231. .total-score {
  232. color: var(--app-main-text-color);
  233. font-size: 32px;
  234. }
  235. .question {
  236. min-width: 80px;
  237. }
  238. .single-score {
  239. position: relative;
  240. width: 32px;
  241. height: 32px;
  242. font-size: var(--app-secondary-font-size);
  243. display: grid;
  244. place-content: center;
  245. background-color: var(--app-container-bg-color);
  246. border-radius: 30px;
  247. }
  248. .current-score {
  249. background-color: var(--app-score-color);
  250. color: white;
  251. }
  252. .all-zero-unselective-button {
  253. height: v-bind(buttonHeightForSelective);
  254. border-radius: 10px;
  255. padding: 7px;
  256. background-color: #4db9ff;
  257. border: none;
  258. }
  259. </style>