소스 검색

feat: 优先指定小题评卷

zhangjie 3 주 전
부모
커밋
9c4b4d4087

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "stmms-web",
-  "version": "3.4.5",
+  "version": "3.4.6",
   "private": "true",
   "scripts": {
     "start": "vite --host 0.0.0.0",

+ 3 - 1
src/api/markPage.ts

@@ -81,7 +81,8 @@ export async function getTask(
 export async function updateUISetting(
   mode?: Setting["mode"],
   uiSetting?: UISetting,
-  questionModel?: Setting["questionModel"]
+  questionModel?: Setting["questionModel"],
+  markedQuestionId?: string
 ) {
   return httpApp.post<void>(
     "/api/mark/updateSetting",
@@ -91,6 +92,7 @@ export async function updateUISetting(
         mode: mode || undefined,
         uiSetting: uiSetting ? JSON.stringify(uiSetting) : undefined,
         questionModel: questionModel || undefined,
+        markedQuestionId: markedQuestionId || undefined,
         ...getMarkInfo(),
       },
     }

+ 2 - 0
src/features/mark/Mark.vue

@@ -32,6 +32,7 @@
   <modal-sheet-view />
   <modal-short-cut />
   <modal-mark-problem />
+  <modal-select-marking-question />
 
   <!-- other -->
   <mark-board-track-dialog
@@ -83,6 +84,7 @@ import ModalAllPaper from "./modals/ModalAllPaper.vue";
 import ModalSheetView from "./modals/ModalSheetView.vue";
 import ModalShortCut from "./modals/ModalShortCut.vue";
 import ModalMarkProblem from "./modals/ModalMarkProblem.vue";
+import ModalSelectMarkingQuestion from "./modals/ModalSelectMarkingQuestion.vue";
 
 // composables
 import useTaskWatch from "./composables/useTaskWatch";

+ 77 - 0
src/features/mark/modals/ModalSelectMarkingQuestion.vue

@@ -0,0 +1,77 @@
+<template>
+  <a-modal
+    v-model:visible="visible"
+    title="选择评卷小题"
+    width="406px"
+    :zIndex="1000"
+    wrapClassName="mark-dialog"
+    @ok="handleOk"
+    @cancel="handleCancel"
+  >
+    <a-form @keydown.stop="" @keypress.stop="">
+      <a-form-item label="选择小题" :required="true" class="tw-mb-2">
+        <a-select
+          v-model:value="selectedQuestionId"
+          placeholder="请选择小题"
+          style="width: 100%"
+        >
+          <a-select-option
+            v-for="item in markStore.status"
+            :key="item.questionId"
+            :value="item.questionId"
+          >
+            {{ `大题 ${item.mainNumber} - 小题 ${item.subNumber}` }}
+          </a-select-option>
+        </a-select>
+      </a-form-item>
+    </a-form>
+  </a-modal>
+</template>
+
+<script setup lang="ts">
+import { ref, watch } from "vue";
+import { useMarkStore } from "@/store";
+import { updateUISetting } from "@/api/markPage";
+
+const markStore = useMarkStore();
+
+// Using $ref for visible, assuming Vue Reactivity Transform is enabled as in ModalMarkProblem.vue
+// If not, this should be: const visible = ref(markStore.selectMarkingQuestionModalVisible);
+let visible = $ref(markStore.selectMarkingQuestionModalVisible);
+const selectedQuestionId = ref<string | undefined>(undefined);
+
+watch(
+  () => markStore.selectMarkingQuestionModalVisible,
+  (newVal) => {
+    visible = newVal; // Sync local $ref with store state
+    if (newVal) {
+      // When modal opens, pre-select with current markingQuestionId from store
+      selectedQuestionId.value = markStore.curStatus?.questionId || undefined;
+    }
+  }
+);
+
+// Watch local 'visible' $ref to update store if modal is closed by 'x' or ESC
+watch(
+  () => visible,
+  (newVal) => {
+    if (markStore.selectMarkingQuestionModalVisible !== newVal) {
+      markStore.selectMarkingQuestionModalVisible = newVal;
+    }
+  }
+);
+
+const handleOk = () => {
+  await updateUISetting(
+    markStore.setting.mode,
+    markStore.setting.uiSetting,
+    markStore.setting.questionModel,
+    selectedQuestionId.value
+  );
+  window.location.reload();
+};
+
+const handleCancel = () => {
+  visible = false; // Close modal, which will trigger watcher to update store
+};
+</script>

+ 2 - 0
src/features/mark/stores/mark.ts

@@ -46,6 +46,8 @@ const useMarkStore = defineStore("mark", {
     sliceImagesWithTrackList: [],
     // 问题卷
     problemModalVisible: false,
+    // 单题阅模式下,选择试题模态框是否可见
+    selectMarkingQuestionModalVisible: false,
     // 主观题检查时,缓存已经修改过的试题
     currentTaskModifyQuestion: {},
     currentQuestion: undefined,

+ 11 - 0
src/features/mark/toolbar/MarkTool.vue

@@ -139,6 +139,14 @@
       </div>
     </div>
     <div>
+      <div
+        v-if="markStore.setting.questionModel === 'SINGLE'"
+        class="mark-tool-item"
+        @click="toSwitchMarkingQuestion"
+      >
+        <img src="@/assets/icons/icon-eye-green.svg" />
+        <p>选择小题</p>
+      </div>
       <div
         v-if="checkValid('questionModel')"
         class="mark-tool-item"
@@ -316,6 +324,9 @@ const toSwitchQuestionModal = () => {
     },
   });
 };
+const toSwitchMarkingQuestion = () => {
+  markStore.selectMarkingQuestionModalVisible = true;
+};
 
 function clearLatestTagOfCurrentTask() {
   if (!markStore.currentTask?.markResult) return;

+ 2 - 0
src/types/index.ts

@@ -57,6 +57,8 @@ export interface MarkStore {
   currentSpecialTagType?: SpecialTag.tagType;
   // 是否打开问题卷弹窗
   problemModalVisible: boolean;
+  /** 是否打开选择评卷小题弹窗 */
+  selectMarkingQuestionModalVisible: boolean;
   /** 是否打开回评侧边栏 */
   historyOpen: boolean;
   historyTasks: Array<Task>;