MarkBoardMouse.vue 5.5 KB

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