MarkHeader.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. <HistoryOutlined class="icon-font icon-font-size-20" />
  54. </div> -->
  55. <div class="tw-flex tw-place-items-center">
  56. <UserOutlined class="icon-font icon-with-text" />{{
  57. store.setting.userName
  58. }}
  59. </div>
  60. <div
  61. class="tw-flex tw-place-items-center tw-cursor-pointer"
  62. @click="closeWindow"
  63. >
  64. <PoweroffOutlined class="icon-font icon-with-text" />关闭
  65. </div>
  66. </div>
  67. </template>
  68. <script lang="ts">
  69. import { computed, defineComponent, onMounted, ref } from "vue";
  70. import { store } from "@/features/mark/store";
  71. import {
  72. ZoomInOutlined,
  73. ZoomOutOutlined,
  74. FullscreenOutlined,
  75. HistoryOutlined,
  76. UserOutlined,
  77. PoweroffOutlined,
  78. AlertOutlined,
  79. QuestionCircleOutlined,
  80. } from "@ant-design/icons-vue";
  81. import { useRoute } from "vue-router";
  82. import { clearInspectedTask } from "@/api/libraryInspectPage";
  83. export default defineComponent({
  84. name: "MarkHeader",
  85. components: {
  86. ZoomInOutlined,
  87. ZoomOutOutlined,
  88. FullscreenOutlined,
  89. HistoryOutlined,
  90. UserOutlined,
  91. PoweroffOutlined,
  92. AlertOutlined,
  93. QuestionCircleOutlined,
  94. },
  95. setup() {
  96. const route = useRoute();
  97. let isSingleStudent = ref(false);
  98. isSingleStudent.value = !!route.query.studentId;
  99. const { studentId, subjectCode, groupNumber } = route.query as {
  100. studentId: string;
  101. subjectCode: string;
  102. groupNumber: string;
  103. };
  104. const upScale = () => {
  105. const s = store.setting.uiSetting["answer.paper.scale"];
  106. if (s < 3)
  107. store.setting.uiSetting["answer.paper.scale"] = +(s + 0.2).toFixed(1);
  108. };
  109. const downScale = () => {
  110. const s = store.setting.uiSetting["answer.paper.scale"];
  111. if (s > 0.2)
  112. store.setting.uiSetting["answer.paper.scale"] = +(s - 0.2).toFixed(1);
  113. };
  114. const normalScale = () => {
  115. store.setting.uiSetting["answer.paper.scale"] = 1;
  116. };
  117. const toggleHistory = () => {
  118. store.historyOpen = !store.historyOpen;
  119. };
  120. const greaterThanOneScale = computed(() => {
  121. return store.setting.uiSetting["answer.paper.scale"] > 1;
  122. });
  123. const lessThanOneScale = computed(() => {
  124. return store.setting.uiSetting["answer.paper.scale"] < 1;
  125. });
  126. async function updateHistoryTask({
  127. pageNumber = 1,
  128. pageSize = 10,
  129. }: {
  130. pageNumber: number; // 从1开始
  131. pageSize: number;
  132. }) {
  133. // const res = await getInspectedHistory({
  134. // pageNumber,
  135. // pageSize,
  136. // subjectCode,
  137. // });
  138. // if (res.data) {
  139. // store.historyTasks.push(res.data);
  140. // }
  141. }
  142. async function updateClearTask() {
  143. await clearInspectedTask(subjectCode, groupNumber);
  144. }
  145. const closeWindow = async () => {
  146. await updateClearTask();
  147. window.close();
  148. };
  149. onMounted(() => {
  150. // 不确定是否一定能在关闭页面时调用
  151. window.addEventListener("beforeunload", () => {
  152. updateClearTask();
  153. });
  154. });
  155. return {
  156. store,
  157. isSingleStudent,
  158. upScale,
  159. downScale,
  160. normalScale,
  161. greaterThanOneScale,
  162. lessThanOneScale,
  163. updateHistoryTask,
  164. toggleHistory,
  165. closeWindow,
  166. };
  167. },
  168. });
  169. </script>
  170. <style scoped>
  171. .header-container {
  172. position: relative;
  173. font-size: 16px;
  174. height: 40px;
  175. background-color: #5d6d7d;
  176. color: white;
  177. }
  178. .highlight-text {
  179. color: #ffe400;
  180. }
  181. .icon-font {
  182. display: block;
  183. }
  184. .icon-font-size-20 {
  185. font-size: 20px;
  186. }
  187. .icon-with-text {
  188. font-size: 18px;
  189. line-height: 18px;
  190. }
  191. </style>