MarkHeader.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div
  3. class="
  4. tw-flex tw-gap-4 tw-justify-between tw-items-center
  5. header-container
  6. tw-px-1
  7. "
  8. v-if="store.setting"
  9. >
  10. <div>
  11. {{
  12. `${store.setting.subject.code ?? ""}-${
  13. store.setting.subject.name ?? ""
  14. }`
  15. }}
  16. </div>
  17. <div class="tw-flex tw-gap-1">
  18. <div>
  19. 编号<span class="highlight-text">{{
  20. store.currentTask?.secretNumber
  21. }}</span>
  22. </div>
  23. </div>
  24. <ul v-if="!isSingleStudent" class="tw-flex tw-gap-2 tw-mb-0">
  25. <li>
  26. 待复核<span class="highlight-text">{{ store.status.totalCount }}</span>
  27. </li>
  28. </ul>
  29. <ul class="tw-flex tw-gap-2 tw-mb-0">
  30. <li @click="upScale" title="放大">
  31. <ZoomInOutlined
  32. class="icon-font icon-font-size-20 tw-cursor-pointer"
  33. :style="{
  34. color: greaterThanOneScale ? 'red' : 'white',
  35. }"
  36. />
  37. </li>
  38. <li @click="downScale" title="缩小">
  39. <ZoomOutOutlined
  40. class="icon-font icon-font-size-20 tw-cursor-pointer"
  41. :style="{
  42. color: lessThanOneScale ? 'red' : 'white',
  43. }"
  44. />
  45. </li>
  46. <li @click="normalScale" title="适应">
  47. <FullscreenOutlined
  48. class="icon-font icon-font-size-20 tw-cursor-pointer"
  49. />
  50. </li>
  51. </ul>
  52. <div @click="toggleHistory" v-if="!isSingleStudent" title="回看">
  53. <SnippetsOutlined
  54. class="icon-font icon-font-size-20 tw-cursor-pointer"
  55. :style="{
  56. color: store.historyOpen ? 'red' : 'white',
  57. }"
  58. />
  59. </div>
  60. <div class="tw-flex tw-place-items-center">
  61. <UserOutlined class="icon-font icon-with-text" />{{
  62. store.setting.userName
  63. }}
  64. </div>
  65. <div
  66. class="tw-flex tw-place-items-center tw-cursor-pointer"
  67. @click="closeWindow"
  68. >
  69. <PoweroffOutlined class="icon-font icon-with-text" />关闭
  70. </div>
  71. </div>
  72. </template>
  73. <script setup lang="ts">
  74. import { clearInspectedTask } from "@/api/inspectPage";
  75. import { computed, onMounted, ref } from "vue";
  76. import { store } from "../store";
  77. import {
  78. ZoomInOutlined,
  79. ZoomOutOutlined,
  80. FullscreenOutlined,
  81. SnippetsOutlined,
  82. UserOutlined,
  83. PoweroffOutlined,
  84. } from "@ant-design/icons-vue";
  85. import { useRoute } from "vue-router";
  86. const route = useRoute();
  87. let isSingleStudent = ref(false);
  88. isSingleStudent.value = !!route.query.studentId;
  89. const { studentId, subjectCode } = route.query as {
  90. studentId: string;
  91. subjectCode: string;
  92. };
  93. const upScale = () => {
  94. const s = store.setting.uiSetting["answer.paper.scale"];
  95. if (s < 3)
  96. store.setting.uiSetting["answer.paper.scale"] = +(s + 0.2).toFixed(1);
  97. };
  98. const downScale = () => {
  99. const s = store.setting.uiSetting["answer.paper.scale"];
  100. if (s > 0.2)
  101. store.setting.uiSetting["answer.paper.scale"] = +(s - 0.2).toFixed(1);
  102. };
  103. const normalScale = () => {
  104. store.setting.uiSetting["answer.paper.scale"] = 1;
  105. };
  106. const toggleHistory = () => {
  107. store.historyOpen = !store.historyOpen;
  108. };
  109. const greaterThanOneScale = computed(() => {
  110. return store.setting.uiSetting["answer.paper.scale"] > 1;
  111. });
  112. const lessThanOneScale = computed(() => {
  113. return store.setting.uiSetting["answer.paper.scale"] < 1;
  114. });
  115. async function updateClearTask() {
  116. await clearInspectedTask(studentId, subjectCode);
  117. }
  118. const closeWindow = async () => {
  119. await updateClearTask();
  120. window.close();
  121. };
  122. onMounted(() => {
  123. // 不确定是否一定能在关闭页面时调用
  124. window.addEventListener("beforeunload", () => {
  125. updateClearTask();
  126. });
  127. });
  128. </script>
  129. <style scoped>
  130. .header-container {
  131. position: relative;
  132. font-size: 16px;
  133. height: 40px;
  134. background-color: #5d6d7d;
  135. color: white;
  136. }
  137. .highlight-text {
  138. color: #ffe400;
  139. }
  140. .icon-font {
  141. display: block;
  142. }
  143. .icon-font-size-20 {
  144. font-size: 20px;
  145. }
  146. .icon-with-text {
  147. font-size: 18px;
  148. line-height: 18px;
  149. }
  150. </style>