MarkBoardMouse.vue 7.2 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="
  115. markStore.currentQuestion?.problem &&
  116. markStore.currentQuestion?.selfMark
  117. "
  118. class="board-footer"
  119. >
  120. <!-- 非回评下自己标记的问题卷才能取消 -->
  121. <qm-button class="board-clear" @click="cancelProblem">
  122. 取消问题卷
  123. </qm-button>
  124. </div>
  125. </div>
  126. </template>
  127. <script setup lang="ts">
  128. import { ref } from "vue";
  129. import type { Question } from "@/types";
  130. import { useMarkStore } from "@/store";
  131. import useAutoChooseFirstQuestion from "../composables/useAutoChooseFirstQuestion";
  132. import useQuestion from "../composables/useQuestion";
  133. import useMakeTrack from "../composables/useMakeTrack";
  134. const markStore = useMarkStore();
  135. const { isDisabledQuestion, isArbitrated, getArbitratedStatusName } =
  136. useQuestion();
  137. const { chooseQuestion } = useAutoChooseFirstQuestion();
  138. const { makeCommonTrack } = useMakeTrack();
  139. const emit = defineEmits([
  140. "submit",
  141. "allZeroSubmit",
  142. "unselectiveSubmit",
  143. "checkSubmit",
  144. ]);
  145. const props = defineProps<{ isCheckAnswer?: boolean }>();
  146. const hasModifyScore = ref(false);
  147. // 切换给分模式
  148. const normalMode = ref(markStore.setting.uiSetting["normal.mode"] || "mouse");
  149. function normalModeChange(value: string) {
  150. markStore.setting.uiSetting["normal.mode"] = value;
  151. }
  152. function isCurrentQuestion(question: Question) {
  153. return (
  154. markStore.currentQuestion?.mainNumber === question.mainNumber &&
  155. markStore.currentQuestion?.subNumber === question.subNumber
  156. );
  157. }
  158. function chooseScore(question: Question, score: number) {
  159. if (isDisabledQuestion(question)) return;
  160. // 只要修改了分值,就当做已修改
  161. hasModifyScore.value = true;
  162. makeCommonTrack(question, score);
  163. }
  164. function isCurrentScore(question: Question, score: number) {
  165. const { __index } = question;
  166. const questionScore =
  167. markStore.currentTask &&
  168. markStore.currentTask.markResult &&
  169. markStore.currentTask.markResult.scoreList[__index];
  170. return questionScore === score;
  171. }
  172. function questionScoreSteps(question: Question) {
  173. if (!question) return [];
  174. const remainScore = Math.round(question.maxScore * 100) / 100;
  175. const steps = [];
  176. for (
  177. let i = 0;
  178. i <= remainScore;
  179. i = Math.round(i * 100 + question.intervalScore * 100) / 100
  180. ) {
  181. steps.push(i);
  182. }
  183. if (
  184. Math.round(remainScore * 100) % Math.round(question.intervalScore * 100) !==
  185. 0
  186. ) {
  187. steps.push(remainScore);
  188. }
  189. return steps;
  190. }
  191. function cancelProblem() {
  192. if (!markStore.currentQuestion) return;
  193. markStore.currentQuestion.problem = false;
  194. markStore.currentQuestion.problemType = null;
  195. markStore.currentQuestion.problemRemark = "";
  196. }
  197. function submit() {
  198. emit("submit");
  199. }
  200. function checkSubmit() {
  201. emit("checkSubmit");
  202. }
  203. const buttonHeightForSelective = $computed(() =>
  204. markStore.setting.selective && markStore.setting.enableAllZero
  205. ? "36px"
  206. : "76px"
  207. );
  208. </script>
  209. <style scoped>
  210. .mark-board-track-container {
  211. max-width: 290px;
  212. min-width: 290px;
  213. padding: 20px;
  214. max-height: calc(100vh - 56px - 0px);
  215. overflow: auto;
  216. z-index: 1001;
  217. transition: margin-right 0.5s;
  218. color: var(--app-small-header-text-color);
  219. }
  220. .mark-board-track-container.show {
  221. margin-right: 0;
  222. }
  223. .mark-board-track-container.hide {
  224. margin-right: -290px;
  225. }
  226. .top-container {
  227. background-color: var(--app-container-bg-color);
  228. }
  229. .total-score {
  230. color: var(--app-main-text-color);
  231. font-size: 32px;
  232. }
  233. .question {
  234. min-width: 80px;
  235. }
  236. .single-score {
  237. position: relative;
  238. width: 32px;
  239. height: 32px;
  240. font-size: var(--app-secondary-font-size);
  241. display: grid;
  242. place-content: center;
  243. background-color: var(--app-container-bg-color);
  244. border-radius: 30px;
  245. }
  246. .current-score {
  247. background-color: var(--app-score-color);
  248. color: white;
  249. }
  250. .all-zero-unselective-button {
  251. height: v-bind(buttonHeightForSelective);
  252. border-radius: 10px;
  253. padding: 7px;
  254. background-color: #4db9ff;
  255. border: none;
  256. }
  257. </style>