markPage.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. import { store } from "@/store/app";
  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(questionModel: Setting["questionModal"]) {
  30. return httpApp.post<MarkStore["status"]>(
  31. "/api/mark/getStatus",
  32. {},
  33. { params: { questionModel, ...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(questionModal: Setting["questionModal"]) {
  46. return httpApp.post<Task>(
  47. "/api/mark/getTask",
  48. {},
  49. { params: { questionModal, ...getMarkInfo() } }
  50. );
  51. }
  52. /** 更新评卷UI */
  53. export async function updateUISetting(
  54. mode?: Setting["mode"],
  55. uiSetting?: UISetting,
  56. questionModal?: Setting["questionModal"]
  57. ) {
  58. return httpApp.post<void>(
  59. "/api/mark/updateSetting",
  60. {},
  61. {
  62. params: {
  63. mode: mode || undefined,
  64. uiSetting: uiSetting ? JSON.stringify(uiSetting) : undefined,
  65. questionModal: questionModal || undefined,
  66. ...getMarkInfo(),
  67. },
  68. }
  69. );
  70. }
  71. /** 获取评卷历史任务 */
  72. export async function getHistoryTask({
  73. pageNumber = 1,
  74. pageSize = 20,
  75. order = "markerTime",
  76. sort = "DESC",
  77. secretNumber = null,
  78. markerScore = null,
  79. }: HistoryQueryParams) {
  80. return httpApp.post<Task[]>(
  81. "/api/mark/getHistory",
  82. {},
  83. {
  84. params: {
  85. pageNumber,
  86. pageSize,
  87. order,
  88. sort,
  89. secretNumber,
  90. markerScore,
  91. ...getMarkInfo(),
  92. },
  93. }
  94. );
  95. }
  96. /** 保存评卷任务(正常保存) */
  97. export async function saveTask() {
  98. if (!store.currentTask?.markResult) return;
  99. let markResult = store.currentTask.markResult;
  100. markResult.problem = false;
  101. markResult.problemType = undefined;
  102. markResult.problemRemark = undefined;
  103. markResult.unselective = false;
  104. markResult.spent = Date.now() - store.currentTask.__markStartTime;
  105. markResult = { ...markResult };
  106. return httpApp.post<CommonResponse>("/api/mark/saveTask", markResult, {
  107. setGlobalMask: true,
  108. params: getMarkInfo(),
  109. });
  110. }
  111. /** 获取用户信息 */
  112. export async function changeUserInfo(name: string, password?: string) {
  113. return httpApp.post<void>(
  114. "/api/mark/changeName",
  115. {},
  116. {
  117. params: {
  118. name,
  119. password: password || undefined,
  120. },
  121. }
  122. );
  123. }
  124. /** 评卷用户退出 */
  125. export function doLogout() {
  126. // window.history.go(-1);
  127. window.close();
  128. }
  129. /** 评卷用户选择分组 */
  130. // ps:已经没用了 3.3.0
  131. export async function doSwitchGroup(markerId: number) {
  132. return httpApp.post<CommonResponse>(
  133. "/api/mark/subjectSelect",
  134. {},
  135. {
  136. params: { markerId, ...getMarkInfo() },
  137. }
  138. );
  139. }
  140. /** 评卷用户选择试卷的问题类型 */
  141. export async function doProblemType({ problemType, problemRemark }) {
  142. if (!store.currentTask?.markResult) return;
  143. let markResult = store.currentTask?.markResult;
  144. markResult.problem = true;
  145. markResult.unselective = false;
  146. markResult.problemType = problemType;
  147. markResult.problemRemark = problemRemark || undefined;
  148. markResult.markerScore = null;
  149. markResult.scoreList = [];
  150. markResult.specialTagList = [];
  151. markResult.trackList = [];
  152. markResult.spent = Date.now() - store.currentTask.__markStartTime;
  153. markResult = { ...markResult };
  154. return httpApp.post<CommonResponse>("/api/mark/saveTask", markResult, {
  155. params: getMarkInfo(),
  156. });
  157. }
  158. /** 评卷用户选择试卷的为未选做 */
  159. export async function doUnselectiveType() {
  160. if (!store.currentTask?.markResult) return;
  161. let markResult = store.currentTask?.markResult;
  162. markResult.problem = false;
  163. markResult.unselective = true;
  164. markResult.markerScore = -1;
  165. markResult.scoreList = [];
  166. markResult.specialTagList = [];
  167. markResult.trackList = [];
  168. markResult.spent = Date.now() - store.currentTask.__markStartTime;
  169. markResult = { ...markResult };
  170. return httpApp.post<CommonResponse>("/api/mark/saveTask", markResult, {
  171. params: getMarkInfo(),
  172. });
  173. }
  174. /** 获取评卷任务 */
  175. export async function getMarkTask(id: string) {
  176. return httpApp.post<boolean>(
  177. "/api/admin/mark/task/get_mark_track",
  178. {},
  179. { params: { id } }
  180. );
  181. }
  182. /** 打回评卷任务 */
  183. export async function doRejectTask(params: {
  184. id: string;
  185. rejectReason: string;
  186. }) {
  187. return httpApp.post<boolean>("/api/admin/mark/task/reject", {}, { params });
  188. }