markPage.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import { store } from "@/store/store";
  2. import { httpApp } from "@/plugins/axiosApp";
  3. import {
  4. Setting,
  5. UISetting,
  6. HistoryQueryParams,
  7. MarkStore,
  8. Group,
  9. Task,
  10. CommonResponse,
  11. } from "@/types";
  12. /** 清除评卷任务(之前锁住的任务之类的) */
  13. export async function clearMarkTask() {
  14. return httpApp.post<void>("/api/mark/clear");
  15. }
  16. /** 获取评卷设置 */
  17. export async function getSetting() {
  18. return httpApp.post<Setting>("/api/mark/getSetting");
  19. }
  20. /** 获取评卷状态 */
  21. export async function getStatus() {
  22. return httpApp.post<MarkStore["status"]>("/api/mark/getStatus");
  23. }
  24. /** 获取评卷分组 */
  25. export async function getGroup() {
  26. return httpApp.post<Group[]>("/api/mark/getGroup");
  27. }
  28. /** 获取评卷任务 */
  29. export async function getTask() {
  30. return httpApp.post<Task>("/api/mark/getTask");
  31. }
  32. /** 更新评卷UI */
  33. export async function updateUISetting(
  34. mode?: Setting["mode"],
  35. uiSetting?: UISetting
  36. ) {
  37. return httpApp.post<void>(
  38. "/api/mark/updateSetting",
  39. {},
  40. {
  41. params: {
  42. mode: mode || undefined,
  43. uiSetting: uiSetting ? JSON.stringify(uiSetting) : undefined,
  44. },
  45. }
  46. );
  47. }
  48. /** 获取评卷历史任务 */
  49. export async function getHistoryTask({
  50. pageNumber = 1,
  51. pageSize = 20,
  52. order = "markerTime",
  53. sort = "DESC",
  54. secretNumber = null,
  55. markerScore = null,
  56. }: HistoryQueryParams) {
  57. return httpApp.post<Task[]>(
  58. "/api/mark/getHistory",
  59. {},
  60. {
  61. params: {
  62. pageNumber,
  63. pageSize,
  64. order,
  65. sort,
  66. secretNumber,
  67. markerScore,
  68. },
  69. }
  70. );
  71. }
  72. /** 保存评卷任务(正常保存) */
  73. export async function saveTask() {
  74. if (!store.currentTask?.markResult) return;
  75. let markResult = store.currentTask.markResult;
  76. markResult.problem = false;
  77. markResult.problemType = undefined;
  78. markResult.problemRemark = undefined;
  79. markResult.unselective = false;
  80. markResult.spent = Date.now() - store.currentTask.__markStartTime;
  81. markResult = { ...markResult };
  82. return httpApp.post<CommonResponse>("/api/mark/saveTask", markResult, {
  83. setGlobalMask: true,
  84. });
  85. }
  86. /** 获取用户信息 */
  87. export async function changeUserInfo(name: string, password?: string) {
  88. return httpApp.post<void>(
  89. "/api/mark/changeName",
  90. {},
  91. {
  92. params: {
  93. name,
  94. password: password || undefined,
  95. },
  96. }
  97. );
  98. }
  99. /** 评卷用户退出 */
  100. export function doLogout() {
  101. // window.history.go(-1);
  102. window.close();
  103. }
  104. /** 评卷用户选择分组 */
  105. // ps:已经没用了 3.3.0
  106. export async function doSwitchGroup(markerId: number) {
  107. return httpApp.post<CommonResponse>(
  108. "/api/mark/subjectSelect",
  109. {},
  110. {
  111. params: { markerId },
  112. }
  113. );
  114. }
  115. /** 评卷用户选择试卷的问题类型 */
  116. export async function doProblemType({ problemType, problemRemark }) {
  117. if (!store.currentTask?.markResult) return;
  118. let markResult = store.currentTask?.markResult;
  119. markResult.problem = true;
  120. markResult.unselective = false;
  121. markResult.problemType = problemType;
  122. markResult.problemRemark = problemRemark || undefined;
  123. markResult.markerScore = null;
  124. markResult.scoreList = [];
  125. markResult.specialTagList = [];
  126. markResult.trackList = [];
  127. markResult.spent = Date.now() - store.currentTask.__markStartTime;
  128. markResult = { ...markResult };
  129. return httpApp.post<CommonResponse>("/api/mark/saveTask", markResult);
  130. }
  131. /** 评卷用户选择试卷的为未选做 */
  132. export async function doUnselectiveType() {
  133. if (!store.currentTask?.markResult) return;
  134. let markResult = store.currentTask?.markResult;
  135. markResult.problem = false;
  136. markResult.unselective = true;
  137. markResult.markerScore = -1;
  138. markResult.scoreList = [];
  139. markResult.specialTagList = [];
  140. markResult.trackList = [];
  141. markResult.spent = Date.now() - store.currentTask.__markStartTime;
  142. markResult = { ...markResult };
  143. return httpApp.post<CommonResponse>("/api/mark/saveTask", markResult);
  144. }