MarkHeader.vue 15 KB

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