MarkHeader.vue 15 KB

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