MarkHeader.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <div
  3. class="tw-flex tw-gap-2 tw-justify-between tw-items-center header-container"
  4. v-if="store.setting && store.setting.subject.name"
  5. >
  6. <div
  7. class="tw-flex tw-place-content-center tw-cursor-pointer tw-relative menu"
  8. :class="[store.historyOpen && 'menu-toggled']"
  9. @click="toggleHistory"
  10. >
  11. <span title="回看" class="tw-inline-flex tw-place-content-center">
  12. <img
  13. src="./images/left-menu.svg"
  14. :class="[store.historyOpen && 'svg-red']"
  15. />
  16. </span>
  17. <div v-if="store.historyOpen" class="triangle"></div>
  18. </div>
  19. <div style="max-width: 12%; margin-left: -20px">
  20. <a
  21. class="
  22. tw-text-white
  23. tw-block
  24. tw-overflow-ellipsis
  25. tw-overflow-hidden
  26. tw-whitespace-nowrap
  27. header-big-text
  28. "
  29. :title="store.setting.subject.name"
  30. href="/mark/subject-select"
  31. >{{
  32. `${store.setting.subject.code ?? ""}-${
  33. store.setting.subject.name ?? ""
  34. }`
  35. }}</a
  36. >
  37. </div>
  38. <div class="tw-flex" style="margin: 0 -20px 0 -40px">
  39. <a-tooltip>
  40. <template #title>
  41. 问题卷{{ store.status.problemCount }}
  42. <br />
  43. 待仲裁{{ store.status.arbitrateCount }}
  44. </template>
  45. <img src="./images/problems.svg" />
  46. </a-tooltip>
  47. </div>
  48. <div v-if="store.setting.statusValue === 'TRIAL'">试评</div>
  49. <div class="tw-flex tw-gap-1">
  50. <div>
  51. <span class="header-small-text">编号</span>
  52. <span class="highlight-text">
  53. {{ store.currentTask?.secretNumber ?? "-" }}
  54. </span>
  55. </div>
  56. <div
  57. v-if="store.currentTask && store.currentTask.objectiveScore !== null"
  58. >
  59. <span class="header-small-text">客观分</span>
  60. <span class="highlight-text">
  61. {{ store.currentTask.objectiveScore }}
  62. </span>
  63. </div>
  64. </div>
  65. <div v-show="store.status.totalCount" class="tw-flex tw-gap-2">
  66. <span>
  67. <span class="header-small-text">已评</span>
  68. <span
  69. class="highlight-text"
  70. :class="markCountChanged && 'markcount-animation'"
  71. >{{ personCountAnimated }}</span
  72. >
  73. </span>
  74. <span v-if="store.setting.topCount">
  75. <span class="header-small-text">分配</span>
  76. <span class="highlight-text">{{ store.setting.topCount ?? "-" }}</span>
  77. </span>
  78. <span>
  79. <span class="header-small-text">未评</span>
  80. <span
  81. class="highlight-text"
  82. :class="markCountChanged && 'markcount-animation'"
  83. >{{ todoMarkCountAnimated }}</span
  84. >
  85. </span>
  86. <span>
  87. <span class="header-small-text">进度</span>
  88. <span class="highlight-text">{{ progress ?? "-" }}%</span>
  89. </span>
  90. </div>
  91. <div class="tw-flex tw-place-items-center">
  92. <a-tooltip>
  93. <template #title>
  94. 评卷时间段
  95. <br />
  96. {{
  97. store.setting.startTime > 0
  98. ? $filters.datetimeFilter(store.setting.startTime)
  99. : "-"
  100. }}
  101. <br />~<br />
  102. {{
  103. store.setting.endTime > 0
  104. ? $filters.datetimeFilter(store.setting.endTime)
  105. : "-"
  106. }}
  107. </template>
  108. <img src="./images/时间.png" style="width: 16px; height: 16px" />
  109. </a-tooltip>
  110. </div>
  111. <div class="tw-flex">
  112. <a-dropdown class="header-bg-color">
  113. <template #overlay v-if="!store.setting.forceMode">
  114. <a-menu>
  115. <a-menu-item key="1" @click="toggleSettingMode">
  116. {{ exchangeModeName }}
  117. </a-menu-item>
  118. </a-menu>
  119. </template>
  120. <a-button
  121. style="
  122. font-size: 14px;
  123. color: rgba(255, 255, 255, 0.5);
  124. border: none;
  125. display: flex;
  126. align-items: center;
  127. "
  128. >
  129. <img
  130. src="./images/轨迹模式.png"
  131. style="
  132. width: 11px;
  133. height: 12px;
  134. display: inline;
  135. margin-right: 2px;
  136. "
  137. />
  138. {{ modeName }}
  139. <div v-if="!store.setting.forceMode" class="dropdown-triangle"></div>
  140. </a-button>
  141. </a-dropdown>
  142. </div>
  143. <a-popover
  144. v-if="!isScanImage()"
  145. title="小助手"
  146. trigger="hover"
  147. class="tw-cursor-pointer"
  148. >
  149. <template #content>
  150. <table class="assistant-table">
  151. <tr v-if="store.setting.statusValue !== 'TRIAL'">
  152. <td>问题卷</td>
  153. <td><a-button @click="openProblemModal">选择问题类型</a-button></td>
  154. </tr>
  155. </table>
  156. </template>
  157. <div class="tw-flex tw-items-center">
  158. <img
  159. src="./images/小助手.png"
  160. style="width: 10px; height: 12px; margin-right: 2px"
  161. />
  162. <span style="font-size: 14px">小助手</span>
  163. <div class="dropdown-triangle"></div>
  164. </div>
  165. </a-popover>
  166. <a-popover v-if="isScanImage()" trigger="hover" class="tw-cursor-pointer">
  167. <template #title>
  168. <span style="color: #283e76; font-size: 16px">小助手</span>
  169. </template>
  170. <template #content>
  171. <table class="assistant-table">
  172. <tr v-if="store.setting.subject.paperUrl">
  173. <td>试卷</td>
  174. <td>
  175. <a-switch
  176. v-model:checked="store.setting.uiSetting['paper.modal']"
  177. />
  178. </td>
  179. </tr>
  180. <tr v-if="store.setting.subject.answerUrl">
  181. <td>答案</td>
  182. <td>
  183. <a-switch
  184. v-model:checked="store.setting.uiSetting['answer.modal']"
  185. />
  186. </td>
  187. </tr>
  188. <tr>
  189. <td>全卷</td>
  190. <td><a-switch v-model:checked="store.allPaperModal" /></td>
  191. </tr>
  192. <tr v-if="store.setting.sheetView">
  193. <td>原图</td>
  194. <td>
  195. <a-switch v-model:checked="store.sheetViewModal" />
  196. </td>
  197. </tr>
  198. <tr>
  199. <td>缩略图</td>
  200. <td>
  201. <a-switch
  202. v-model:checked="store.setting.uiSetting['minimap.modal']"
  203. />
  204. </td>
  205. </tr>
  206. <tr>
  207. <td>特殊标记</td>
  208. <td>
  209. <a-switch
  210. v-model:checked="store.setting.uiSetting['specialTag.modal']"
  211. />
  212. </td>
  213. </tr>
  214. <tr v-if="store.setting.statusValue !== 'TRIAL'">
  215. <td>问题卷</td>
  216. <td>
  217. <a-button
  218. type="text"
  219. style="color: #5d65ff; margin-right: -15px; height: 25px"
  220. @click="openProblemModal"
  221. >
  222. 选择问题类型
  223. </a-button>
  224. </td>
  225. </tr>
  226. <tr v-if="isScanImage()">
  227. <td>分数/标记大小</td>
  228. <td>
  229. <a-slider
  230. v-model:value="store.setting.uiSetting['score.fontSize.scale']"
  231. :min="0.5"
  232. :step="0.1"
  233. :max="2"
  234. style="margin: 0"
  235. />
  236. </td>
  237. </tr>
  238. </table>
  239. </template>
  240. <div class="tw-flex tw-items-center">
  241. <img
  242. src="./images/小助手.png"
  243. style="width: 10px; height: 12px; margin-right: 2px"
  244. />
  245. <span style="font-size: 14px">小助手</span>
  246. <div class="dropdown-triangle"></div>
  247. </div>
  248. </a-popover>
  249. <div
  250. @click="openSwitchGroupModal"
  251. class="tw-flex tw-place-content-center tw-cursor-pointer tw-items-center"
  252. style="max-width: 8%"
  253. :title="store.setting.groupTitle + '-' + store.setting.groupNumber"
  254. >
  255. <img
  256. src="./images/分组.png"
  257. style="width: 10px; height: 12px; margin-right: 2px"
  258. />
  259. <div
  260. class="tw-overflow-ellipsis tw-overflow-hidden tw-whitespace-nowrap"
  261. style="font-size: 14px"
  262. >
  263. {{ "分组:" + store.setting.groupNumber }}
  264. </div>
  265. <div v-if="store.groups.length > 1" class="dropdown-triangle"></div>
  266. </div>
  267. <div class="tw-flex tw-gap-4">
  268. <div
  269. class="tw-flex tw-place-items-center tw-cursor-pointer"
  270. style="font-size: 14px"
  271. @click="openProfileModal"
  272. >
  273. <!-- <UserOutlined /> -->
  274. {{ store.setting.userName }}
  275. </div>
  276. <div
  277. class="tw-flex tw-place-items-center tw-cursor-pointer"
  278. @click="logout"
  279. style="font-size: 14px"
  280. >
  281. <!-- <PoweroffOutlined /> -->
  282. 退出
  283. </div>
  284. <div
  285. class="tw-flex tw-place-content-center tw-cursor-pointer menu"
  286. :class="[
  287. !store.setting.uiSetting['score.board.collapse'] &&
  288. store.currentTask &&
  289. 'menu-toggled',
  290. ]"
  291. @click="toggleScoreBoard"
  292. >
  293. <span
  294. title="给分板"
  295. class="tw-inline-flex tw-place-content-center tw-relative"
  296. >
  297. <img
  298. src="./images/right-menu.svg"
  299. :class="[
  300. !store.setting.uiSetting['score.board.collapse'] && 'svg-red',
  301. ]"
  302. />
  303. </span>
  304. <div
  305. v-if="
  306. !store.setting.uiSetting['score.board.collapse'] &&
  307. store.currentTask
  308. "
  309. class="triangle"
  310. ></div>
  311. </div>
  312. </div>
  313. </div>
  314. <MarkChangeProfile ref="changeProfileRef" />
  315. <MarkSwitchGroupDialog ref="switchGroupRef" />
  316. <MarkProblemDialog
  317. @should-reload-history="$emit('should-reload-history')"
  318. ref="problemRef"
  319. />
  320. </template>
  321. <script setup lang="ts">
  322. import { doLogout, updateUISetting } from "@/api/markPage";
  323. import { computed, ref, watch, watchEffect } from "vue";
  324. import { store, isScanImage } from "./store";
  325. import {
  326. SnippetsOutlined,
  327. UserOutlined,
  328. PoweroffOutlined,
  329. ClockCircleOutlined,
  330. DownOutlined,
  331. } from "@ant-design/icons-vue";
  332. import { ModeEnum } from "@/types";
  333. import MarkChangeProfile from "./MarkChangeProfile.vue";
  334. import MarkSwitchGroupDialog from "./MarkSwitchGroupDialog.vue";
  335. import MarkProblemDialog from "./MarkProblemDialog.vue";
  336. import { isNumber } from "lodash";
  337. import { Modal } from "ant-design-vue";
  338. import gsap from "gsap";
  339. defineEmits(["should-reload-history"]);
  340. const modeName = computed(() =>
  341. store.setting.mode === ModeEnum.TRACK ? "轨迹模式" : "普通模式"
  342. );
  343. const exchangeModeName = computed(() =>
  344. store.setting.mode === ModeEnum.TRACK ? "普通模式" : "轨迹模式"
  345. );
  346. async function toggleSettingMode() {
  347. if (store.setting.mode === ModeEnum.TRACK) {
  348. store.setting.mode = ModeEnum.COMMON;
  349. } else {
  350. store.setting.mode = ModeEnum.TRACK;
  351. }
  352. await updateUISetting(store.setting.mode);
  353. const body = document.querySelector("body");
  354. if (body) body.innerHTML = "重新加载中...";
  355. // 等待一秒后,重新加载页面
  356. await new Promise((resolve) => setTimeout(resolve, 1000));
  357. window.location.reload();
  358. }
  359. const progress = computed(() => {
  360. const { totalCount, markedCount } = store.status;
  361. if (totalCount <= 0) return 0;
  362. let p = markedCount / totalCount;
  363. if (p < 0.01 && markedCount >= 1) p = 0.01;
  364. p = Math.floor(p * 100);
  365. return p;
  366. });
  367. const toggleHistory = () => {
  368. store.historyOpen = !store.historyOpen;
  369. };
  370. const toggleScoreBoard = () => {
  371. store.setting.uiSetting["score.board.collapse"] =
  372. !store.setting.uiSetting["score.board.collapse"];
  373. };
  374. const logout = () => {
  375. doLogout();
  376. };
  377. const changeProfileRef = ref(null);
  378. const openProfileModal = () => {
  379. // @ts-ignore
  380. changeProfileRef.value?.showModal();
  381. };
  382. const switchGroupRef = ref(null);
  383. const openSwitchGroupModal = () => {
  384. // @ts-ignore
  385. switchGroupRef.value?.showModal();
  386. };
  387. const problemRef = ref(null);
  388. const openProblemModal = () => {
  389. // @ts-ignore
  390. problemRef.value?.showModal();
  391. };
  392. watchEffect(() => {
  393. if (
  394. isNumber(store.setting.topCount) &&
  395. store.setting.topCount > 0 &&
  396. store.setting.topCount === store.status.personCount
  397. ) {
  398. Modal.confirm({
  399. centered: true,
  400. mask: true,
  401. zIndex: 6000,
  402. maskStyle: { opacity: 0.97 },
  403. content: `分配任务份已完成,是否继续?`,
  404. okText: "继续",
  405. cancelText: "退出",
  406. onCancel: () => {
  407. logout();
  408. },
  409. onOk: () => {},
  410. });
  411. }
  412. });
  413. const personCountAnimated = computed(() => {
  414. if (store.status.personCountTweenedNumber === undefined) return "-";
  415. return Number(store.status.personCountTweenedNumber).toFixed(0);
  416. });
  417. const todoMarkCountAnimated = computed(() => {
  418. if (store.status.totalCount === undefined) return "-";
  419. return Number(store.status.todoMarkCountTweenedNumber).toFixed(0);
  420. });
  421. let markCountChanged = ref(false);
  422. watch(
  423. () => [
  424. store.status.personCount,
  425. store.status.totalCount,
  426. store.status.markedCount,
  427. ],
  428. ([personCount, totalCount, markedCount]) => {
  429. if (store.status.personCountTweenedNumber === undefined) {
  430. store.status.personCountTweenedNumber = 0;
  431. store.status.todoMarkCountTweenedNumber = 0;
  432. }
  433. markCountChanged.value = true;
  434. setTimeout(() => (markCountChanged.value = false), 3000);
  435. gsap.to(store.status, {
  436. duration: 1.5,
  437. personCountTweenedNumber: personCount,
  438. todoMarkCountTweenedNumber: totalCount - markedCount,
  439. });
  440. }
  441. );
  442. </script>
  443. <style scoped>
  444. .header-bg-color {
  445. background-color: var(--header-bg-color);
  446. }
  447. .header-container {
  448. position: relative;
  449. font-size: 16px;
  450. height: 56px;
  451. line-height: 16px;
  452. background-color: var(--header-bg-color);
  453. color: rgba(255, 255, 255, 0.5);
  454. }
  455. .menu {
  456. width: 56px;
  457. height: 56px;
  458. padding: 20px;
  459. }
  460. .menu:hover,
  461. .menu-toggled {
  462. background-color: rgba(255, 255, 255, 0.2);
  463. }
  464. .header-container span {
  465. vertical-align: middle;
  466. }
  467. .header-big-text {
  468. font-size: 20px;
  469. line-height: 30px;
  470. }
  471. .header-small-text {
  472. font-size: 12px;
  473. /* line-height: 12px; */
  474. }
  475. .highlight-text {
  476. color: white;
  477. }
  478. .header-bg-color.ant-btn:hover {
  479. background-color: #5d6d7d !important;
  480. }
  481. .assistant-table {
  482. z-index: 5500;
  483. border-collapse: separate;
  484. border-spacing: 0 1em;
  485. color: #435488;
  486. width: 240px;
  487. }
  488. .assistant-table tr td:nth-child(2) {
  489. text-align: right;
  490. }
  491. .svg-red {
  492. filter: invert(27%) sepia(51%) saturate(2878%) hue-rotate(346deg)
  493. brightness(104%) contrast(97%);
  494. }
  495. .triangle {
  496. background-color: white;
  497. width: 10px;
  498. height: 10px;
  499. clip-path: polygon(0 100%, 100% 100%, 50% 0);
  500. position: absolute;
  501. bottom: -2px;
  502. }
  503. .dropdown-triangle {
  504. background-color: #8c8d9b;
  505. width: 7px;
  506. height: 5px;
  507. clip-path: polygon(0 0, 100% 0, 50% 100%);
  508. margin-left: 4px;
  509. }
  510. .markcount-animation {
  511. animation: change-color 3s ease-in-out;
  512. }
  513. @keyframes change-color {
  514. 0% {
  515. color: red;
  516. }
  517. 100% {
  518. color: white;
  519. }
  520. }
  521. </style>