markPage.ts 4.3 KB

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