MarkHeader.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div
  3. class="tw-flex tw-gap-2 tw-justify-between tw-items-center header-container tw-px-1"
  4. v-if="store.setting && store.setting.subject.name"
  5. >
  6. <div style="max-width: 10%">
  7. <a
  8. class="tw-text-white tw-underline tw-block tw-overflow-ellipsis tw-overflow-hidden tw-whitespace-nowrap"
  9. :title="store.setting.subject.name"
  10. href="/mark/subject-select"
  11. >{{ store.setting.subject.code + "-" + store.setting.subject.name }}</a
  12. >
  13. </div>
  14. <div v-if="store.setting.statusValue === 'TRIAL'">试评</div>
  15. <div class="tw-flex tw-gap-1">
  16. <div>
  17. 编号<span class="highlight-text">{{
  18. store.currentTask?.secretNumber
  19. }}</span>
  20. </div>
  21. <div
  22. v-if="store.currentTask && store.currentTask.objectiveScore !== null"
  23. >
  24. 客观分<span class="highlight-text">{{
  25. store.currentTask.objectiveScore
  26. }}</span>
  27. </div>
  28. </div>
  29. <ul class="tw-flex tw-gap-2 tw-mb-0">
  30. <li>
  31. 已评<span class="highlight-text">{{ store.status.personCount }}</span>
  32. </li>
  33. <li v-if="store.setting.topCount">
  34. 分配<span class="highlight-text">{{ store.setting.topCount }}</span>
  35. </li>
  36. <li>
  37. 未评<span class="highlight-text">{{
  38. store.status.totalCount - store.status.markedCount
  39. }}</span>
  40. </li>
  41. <li
  42. :title="`问题卷${store.status.problemCount}\n待仲裁${store.status.arbitrateCount}`"
  43. >
  44. <QuestionCircleOutlined class="icon-font icon-font-size-20" />
  45. </li>
  46. <li>
  47. 进度<span class="highlight-text">{{ progress }}%</span>
  48. </li>
  49. </ul>
  50. <ul class="tw-flex tw-gap-2 tw-mb-0">
  51. <li @click="upScale" title="放大">
  52. <ZoomInOutlined
  53. class="icon-font icon-font-size-20 tw-cursor-pointer"
  54. :style="{
  55. color: greaterThanOneScale ? 'red' : 'white',
  56. }"
  57. />
  58. </li>
  59. <li @click="downScale" title="缩小">
  60. <ZoomOutOutlined
  61. class="icon-font icon-font-size-20 tw-cursor-pointer"
  62. :style="{
  63. color: lessThanOneScale ? 'red' : 'white',
  64. }"
  65. />
  66. </li>
  67. <li @click="normalScale" title="适应">
  68. <FullscreenOutlined
  69. class="icon-font icon-font-size-20 tw-cursor-pointer"
  70. />
  71. </li>
  72. </ul>
  73. <div>
  74. <a-dropdown class="header-bg-color">
  75. <template #overlay v-if="!store.setting.forceMode">
  76. <a-menu>
  77. <a-menu-item
  78. key="1"
  79. @click="toggleSettingMode"
  80. style="font-size: 16px"
  81. >
  82. {{ exchangeModeName }}
  83. </a-menu-item>
  84. </a-menu>
  85. </template>
  86. <a-button
  87. style="font-size: 16px; color: white !important; border: none"
  88. >
  89. {{ modeName }}
  90. <DownOutlined
  91. v-if="!store.setting.forceMode"
  92. style="display: inline-flex"
  93. />
  94. </a-button>
  95. </a-dropdown>
  96. </div>
  97. <div @click="toggleHistory" title="回看">
  98. <HistoryOutlined class="icon-font icon-font-size-20" />
  99. </div>
  100. <div
  101. class="tw-flex tw-place-items-center"
  102. :title="
  103. '评卷时间段:' +
  104. (store.setting.startTime > 0
  105. ? $filters.datetimeFilter(store.setting.startTime)
  106. : '-') +
  107. ' ~ ' +
  108. (store.setting.endTime > 0
  109. ? $filters.datetimeFilter(store.setting.endTime)
  110. : '-')
  111. "
  112. >
  113. <AlertOutlined class="icon-font icon-font-size-20" />
  114. </div>
  115. <a-popover title="小助手" trigger="hover" class="tw-cursor-pointer">
  116. <template #content>
  117. <table class="assistant-table">
  118. <tr v-if="store.setting.subject.paperUrl">
  119. <td>试卷</td>
  120. <td>
  121. <a-switch
  122. v-model:checked="store.setting.uiSetting['paper.modal']"
  123. />
  124. </td>
  125. </tr>
  126. <tr v-if="store.setting.subject.answerUrl">
  127. <td>答案</td>
  128. <td>
  129. <a-switch
  130. v-model:checked="store.setting.uiSetting['answer.modal']"
  131. />
  132. </td>
  133. </tr>
  134. <tr>
  135. <td>全卷</td>
  136. <td><a-switch v-model:checked="store.allPaperModal" /></td>
  137. </tr>
  138. <tr v-if="store.setting.sheetView">
  139. <td>原图</td>
  140. <td>
  141. <a-switch v-model:checked="store.sheetViewModal" />
  142. </td>
  143. </tr>
  144. <tr>
  145. <td>缩略图</td>
  146. <td>
  147. <a-switch
  148. v-model:checked="store.setting.uiSetting['minimap.modal']"
  149. />
  150. </td>
  151. </tr>
  152. <tr>
  153. <td>特殊标记</td>
  154. <td>
  155. <a-switch
  156. v-model:checked="store.setting.uiSetting['specialTag.modal']"
  157. />
  158. </td>
  159. </tr>
  160. <tr v-if="store.setting.statusValue !== 'TRIAL'">
  161. <td>问题卷</td>
  162. <td><a-button @click="openProblemModal">选择问题类型</a-button></td>
  163. </tr>
  164. </table>
  165. </template>
  166. <div class="tw-flex">
  167. 小助手
  168. <DownOutlined
  169. style="font-size: 12px; display: inline-block"
  170. class="tw-self-center tw-ml-1"
  171. />
  172. </div>
  173. </a-popover>
  174. <div
  175. @click="openSwitchGroupModal"
  176. class="tw-flex tw-place-content-center tw-cursor-pointer"
  177. style="max-width: 8%"
  178. :title="group?.title + '-' + group?.number"
  179. >
  180. <div
  181. class="tw-overflow-ellipsis tw-overflow-hidden tw-whitespace-nowrap tw-mr-1"
  182. >
  183. {{ "分组:" + group?.number }}
  184. </div>
  185. <DownOutlined
  186. v-if="store.groups.length > 1"
  187. style="font-size: 12px; display: inline-block"
  188. class="tw-self-center"
  189. />
  190. </div>
  191. <div
  192. class="tw-flex tw-place-items-center tw-cursor-pointer"
  193. @click="openProfileModal"
  194. >
  195. <UserOutlined class="icon-font icon-with-text" />{{
  196. store.setting.userName
  197. }}
  198. </div>
  199. <div
  200. class="tw-flex tw-place-items-center tw-cursor-pointer"
  201. @click="logout"
  202. >
  203. <PoweroffOutlined class="icon-font icon-with-text" />
  204. 退出
  205. </div>
  206. </div>
  207. <MarkChangeProfile ref="changeProfileRef" />
  208. <MarkSwitchGroupDialog ref="switchGroupRef" />
  209. <MarkProblemDialog
  210. @should-reload-history="$emit('should-reload-history')"
  211. ref="problemRef"
  212. />
  213. </template>
  214. <script lang="ts">
  215. import { doLogout, getHistoryTask } from "@/api/markPage";
  216. import { computed, defineComponent, ref } from "vue";
  217. import { store } from "./store";
  218. import {
  219. ZoomInOutlined,
  220. ZoomOutOutlined,
  221. FullscreenOutlined,
  222. HistoryOutlined,
  223. UserOutlined,
  224. PoweroffOutlined,
  225. AlertOutlined,
  226. QuestionCircleOutlined,
  227. DownOutlined,
  228. } from "@ant-design/icons-vue";
  229. import { ModeEnum } from "@/types";
  230. import MarkChangeProfile from "./MarkChangeProfile.vue";
  231. import MarkSwitchGroupDialog from "./MarkSwitchGroupDialog.vue";
  232. import MarkProblemDialog from "./MarkProblemDialog.vue";
  233. import { message } from "ant-design-vue";
  234. export default defineComponent({
  235. name: "MarkHeader",
  236. components: {
  237. ZoomInOutlined,
  238. ZoomOutOutlined,
  239. FullscreenOutlined,
  240. HistoryOutlined,
  241. UserOutlined,
  242. DownOutlined,
  243. PoweroffOutlined,
  244. AlertOutlined,
  245. QuestionCircleOutlined,
  246. MarkChangeProfile,
  247. MarkSwitchGroupDialog,
  248. MarkProblemDialog,
  249. },
  250. emits: ["should-reload-history"],
  251. setup() {
  252. const modeName = computed(() =>
  253. store.setting.mode === ModeEnum.TRACK ? "轨迹模式" : "普通模式"
  254. );
  255. const exchangeModeName = computed(() =>
  256. store.setting.mode === ModeEnum.TRACK ? "普通模式" : "轨迹模式"
  257. );
  258. async function toggleSettingMode() {
  259. if (store.setting.mode === ModeEnum.TRACK) {
  260. store.setting.mode = ModeEnum.COMMON;
  261. } else {
  262. store.setting.mode = ModeEnum.TRACK;
  263. }
  264. if (store.currentMarkResult) {
  265. store.currentMarkResult.scoreList = [];
  266. store.currentMarkResult.trackList = [];
  267. }
  268. if (store.currentTask) {
  269. store.currentTask.questionList.forEach((q) => (q.score = null));
  270. }
  271. store.currentQuestion = undefined;
  272. store.currentScore = undefined;
  273. message.info({ content: "重新加载中...", duration: 3 });
  274. // 等待一秒后,重新加载页面
  275. await new Promise((resolve) => setTimeout(resolve, 1000));
  276. window.location.reload();
  277. }
  278. const progress = computed(() => {
  279. const { totalCount, markedCount } = store.status;
  280. if (totalCount <= 0) return 0;
  281. let p = markedCount / totalCount;
  282. if (p < 0.01 && markedCount >= 1) p = 0.01;
  283. p = Math.floor(p * 100);
  284. return p;
  285. });
  286. const group = computed(() => {
  287. return store.groups.find((g) => g.number === store.setting.groupNumber);
  288. });
  289. const upScale = () => {
  290. const s = store.setting.uiSetting["answer.paper.scale"];
  291. if (s < 3)
  292. store.setting.uiSetting["answer.paper.scale"] = +(s + 0.2).toFixed(1);
  293. };
  294. const downScale = () => {
  295. const s = store.setting.uiSetting["answer.paper.scale"];
  296. if (s > 0.2)
  297. store.setting.uiSetting["answer.paper.scale"] = +(s - 0.2).toFixed(1);
  298. };
  299. const normalScale = () => {
  300. store.setting.uiSetting["answer.paper.scale"] = 1;
  301. };
  302. const toggleHistory = () => {
  303. store.historyOpen = !store.historyOpen;
  304. };
  305. const greaterThanOneScale = computed(() => {
  306. return store.setting.uiSetting["answer.paper.scale"] > 1;
  307. });
  308. const lessThanOneScale = computed(() => {
  309. return store.setting.uiSetting["answer.paper.scale"] < 1;
  310. });
  311. async function updateHistoryTask({
  312. pageNumber = 1,
  313. pageSize = 10,
  314. order = "markerTime",
  315. sort = "DESC",
  316. secretNumber = null,
  317. }: {
  318. pageNumber: number; // 从1开始
  319. pageSize: number;
  320. order: "markerTime" | "markerScore";
  321. sort: "ASC" | "DESC";
  322. secretNumber: string | null;
  323. }) {
  324. const res = await getHistoryTask({
  325. pageNumber,
  326. pageSize,
  327. order,
  328. sort,
  329. secretNumber,
  330. });
  331. if (res.data) {
  332. store.historyTasks.push(res.data);
  333. }
  334. }
  335. const logout = () => {
  336. doLogout();
  337. };
  338. const changeProfileRef = ref(null);
  339. const openProfileModal = () => {
  340. // @ts-ignore
  341. changeProfileRef.value?.showModal();
  342. };
  343. const switchGroupRef = ref(null);
  344. const openSwitchGroupModal = () => {
  345. // @ts-ignore
  346. switchGroupRef.value?.showModal();
  347. };
  348. const problemRef = ref(null);
  349. const openProblemModal = () => {
  350. // @ts-ignore
  351. problemRef.value?.showModal();
  352. };
  353. return {
  354. store,
  355. modeName,
  356. exchangeModeName,
  357. toggleSettingMode,
  358. progress,
  359. group,
  360. upScale,
  361. downScale,
  362. normalScale,
  363. greaterThanOneScale,
  364. lessThanOneScale,
  365. updateHistoryTask,
  366. toggleHistory,
  367. logout,
  368. changeProfileRef,
  369. openProfileModal,
  370. switchGroupRef,
  371. openSwitchGroupModal,
  372. problemRef,
  373. openProblemModal,
  374. };
  375. },
  376. });
  377. </script>
  378. <style scoped>
  379. .header-bg-color {
  380. background-color: #5d6d7d;
  381. }
  382. .header-container {
  383. /* z-index: 10000; */
  384. position: relative;
  385. font-size: 16px;
  386. height: 40px;
  387. background-color: #5d6d7d;
  388. color: white;
  389. }
  390. .highlight-text {
  391. color: #ffe400;
  392. }
  393. .icon-font {
  394. display: block;
  395. }
  396. .icon-font-size-20 {
  397. font-size: 20px;
  398. }
  399. .line-height-20 {
  400. line-height: 20px;
  401. }
  402. .icon-with-text {
  403. font-size: 18px;
  404. line-height: 18px;
  405. }
  406. .header-bg-color.ant-btn:hover {
  407. background-color: #5d6d7d !important;
  408. }
  409. .assistant-table {
  410. border-collapse: separate;
  411. border-spacing: 0 0.5em;
  412. }
  413. </style>