MarkBoardMouse.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div v-if="store.currentTask" class="mark-board-track-container">
  3. <div class="tw-my-2 tw-flex tw-place-content-center">
  4. <a-dropdown>
  5. <template #overlay>
  6. <a-menu>
  7. <a-menu-item key="1" @click="toggleKeyMouse">
  8. 键盘给分
  9. </a-menu-item>
  10. </a-menu>
  11. </template>
  12. <a-button>
  13. 鼠标给分
  14. <DownOutlined style="display: inline-flex" />
  15. </a-button>
  16. </a-dropdown>
  17. </div>
  18. <div>
  19. <h1 class="tw-text-3xl tw-text-center">
  20. 总分:{{ store.currentMarkResult?.markerScore || 0 }}
  21. </h1>
  22. </div>
  23. <div class="tw-flex tw-place-content-center tw-mb-2">
  24. <qm-button type="primary" shape="round" size="large" @click="submit">
  25. 提交
  26. </qm-button>
  27. </div>
  28. <div v-if="store.currentTask && store.currentTask.questionList">
  29. <template
  30. v-for="(question, index) in store.currentTask?.questionList"
  31. :key="index"
  32. >
  33. <div class="question tw-rounded tw-p-1 tw-mb-2">
  34. <div>
  35. <div>
  36. {{ question.title }} {{ question.mainNumber }}-{{
  37. question.subNumber
  38. }}
  39. </div>
  40. <div class="tw-flex tw-flex-wrap tw-gap-1">
  41. <div
  42. v-for="(s, i) in Math.round(question.maxScore * 100 + 100) /
  43. 100"
  44. :key="i"
  45. @click="chooseScore(question, s - 1)"
  46. class="single-score"
  47. :class="isCurrentScore(question, s - 1) && 'current-score'"
  48. >
  49. {{ s - 1 }}
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. </div>
  56. </div>
  57. </template>
  58. <script lang="ts">
  59. import { Question } from "@/types";
  60. import { isNumber } from "lodash";
  61. import { defineComponent, watch } from "vue";
  62. import { store } from "./store";
  63. import { keyMouse } from "./use/keyboardAndMouse";
  64. import { message } from "ant-design-vue";
  65. import { DownOutlined } from "@ant-design/icons-vue";
  66. export default defineComponent({
  67. name: "MarkBoardMouse",
  68. emits: ["submit"],
  69. components: { DownOutlined },
  70. setup(props, { emit }) {
  71. const { toggleKeyMouse } = keyMouse();
  72. function chooseScore(question: Question, score: number) {
  73. store.currentQuestion = question;
  74. store.currentQuestion.score = score;
  75. }
  76. function isCurrentScore(question: Question, score: number) {
  77. return question.score === score;
  78. }
  79. function submit() {
  80. const errors: any = [];
  81. store.currentTask?.questionList.forEach((question, index) => {
  82. if (!isNumber(question.score)) {
  83. errors.push({ question, index, error: "没有赋分不能提交" });
  84. }
  85. });
  86. if (errors.length === 0) {
  87. emit("submit");
  88. } else {
  89. console.log(errors);
  90. message.error({
  91. content: errors
  92. .map((e: any) => `${e.index + 1}、${e.error}`)
  93. .join("\n"),
  94. duration: 10,
  95. });
  96. }
  97. }
  98. return {
  99. store,
  100. toggleKeyMouse,
  101. chooseScore,
  102. isCurrentScore,
  103. submit,
  104. };
  105. },
  106. });
  107. </script>
  108. <style scoped>
  109. .mark-board-track-container {
  110. max-width: 250px;
  111. min-width: 250px;
  112. border-left: 1px solid grey;
  113. padding-left: 6px;
  114. padding-right: 6px;
  115. max-height: calc(100vh - 41px);
  116. }
  117. .question {
  118. min-width: 80px;
  119. border: 1px solid grey;
  120. }
  121. .single-score {
  122. width: 29px;
  123. height: 29px;
  124. display: grid;
  125. place-content: center;
  126. border: 1px solid black;
  127. border-radius: 5px;
  128. }
  129. .current-score {
  130. border: 1px solid yellowgreen;
  131. background-color: lightblue;
  132. }
  133. </style>