MarkProblemDialog.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <a-modal
  3. title="选择试卷的问题类型"
  4. v-model:visible="visible"
  5. @cancel="handleCancel"
  6. width="300px"
  7. :zIndex="6000"
  8. wrapClassName="profile-wrapper"
  9. >
  10. <template #footer>
  11. <a-button key="back" @click="handleCancel">取消</a-button>
  12. </template>
  13. <table class="group-table">
  14. <tr>
  15. <th>问题类型</th>
  16. <th class="tw-text-right" style="padding-right: 20px">操作</th>
  17. </tr>
  18. <tr v-for="(problem, index) in store.setting.problemTypes" :key="index">
  19. <td>{{ problem.name }}</td>
  20. <td class="tw-text-right">
  21. <qm-button type="primary" @click="chooseProblemType(problem.id)">
  22. 选择
  23. </qm-button>
  24. </td>
  25. </tr>
  26. </table>
  27. </a-modal>
  28. </template>
  29. <script setup lang="ts">
  30. import { doProblemType, getStatus } from "@/api/markPage";
  31. import { message } from "ant-design-vue";
  32. import { store } from "@/store/store";
  33. import EventBus from "@/plugins/eventBus";
  34. let visible = $ref(false);
  35. const showModal = () => {
  36. visible = true;
  37. };
  38. async function updateStatus() {
  39. const res = await getStatus();
  40. store.status = res.data;
  41. }
  42. const chooseProblemType = async (problemId: number) => {
  43. if (!store.currentTask) {
  44. message.warn({ content: "没有可以标记的任务", duration: 5 });
  45. return;
  46. }
  47. try {
  48. const res = await doProblemType(problemId);
  49. if (res?.data.success) {
  50. message.success({ content: "问题卷处理成功", duration: 3 });
  51. visible = false;
  52. store.currentTask = undefined;
  53. if (store.historyOpen) {
  54. EventBus.emit("should-reload-history");
  55. } else {
  56. store.tasks.shift();
  57. store.currentTask = store.tasks[0];
  58. }
  59. updateStatus();
  60. } else {
  61. message.error({ content: res?.data.message || "错误", duration: 5 });
  62. }
  63. } catch (error) {
  64. console.log("问题卷处理失败", error);
  65. message.error({ content: "网络异常", duration: 5 });
  66. await new Promise((res) => setTimeout(res, 1500));
  67. window.location.reload();
  68. }
  69. };
  70. const handleCancel = () => {
  71. visible = false;
  72. };
  73. defineExpose({ showModal });
  74. </script>
  75. <style scoped>
  76. .profile-wrapper .ant-modal-title {
  77. color: var(--app-main-text-color);
  78. }
  79. .profile-wrapper .anticon-close {
  80. vertical-align: text-top;
  81. }
  82. .group-table {
  83. width: 100%;
  84. border-collapse: separate;
  85. border-spacing: 0 0.5em;
  86. }
  87. .group-table th {
  88. color: var(--app-small-header-text-color);
  89. }
  90. .group-table tr td {
  91. color: var(--app-bold-text-color);
  92. }
  93. </style>