MarkHeader.vue 13 KB

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