|
@@ -1,31 +1,36 @@
|
|
import { message } from "ant-design-vue";
|
|
import { message } from "ant-design-vue";
|
|
import { studentSubjectiveConfirmData } from "@/api/checkPage";
|
|
import { studentSubjectiveConfirmData } from "@/api/checkPage";
|
|
import { useMarkStore } from "@/store";
|
|
import { useMarkStore } from "@/store";
|
|
|
|
+import { computed, ref } from "vue";
|
|
|
|
|
|
export default function useTask(ids: string[]) {
|
|
export default function useTask(ids: string[]) {
|
|
const markStore = useMarkStore();
|
|
const markStore = useMarkStore();
|
|
- const studentIds = $ref(ids);
|
|
|
|
|
|
+ const studentIds = ref(ids);
|
|
|
|
|
|
- let currentStudentId = $ref("");
|
|
|
|
- const currentIndex = $computed(() => studentIds.indexOf(currentStudentId));
|
|
|
|
- const isFirst = $computed(() => currentIndex === 0);
|
|
|
|
- const isLast = $computed(() => currentIndex === studentIds.length - 1);
|
|
|
|
- const isMultiStudent = $computed(() => studentIds.length > 1);
|
|
|
|
|
|
+ const currentStudentId = ref("");
|
|
|
|
+ const currentIndex = computed(() =>
|
|
|
|
+ studentIds.value.indexOf(currentStudentId.value)
|
|
|
|
+ );
|
|
|
|
+ const isFirst = computed(() => currentIndex.value === 0);
|
|
|
|
+ const isLast = computed(
|
|
|
|
+ () => currentIndex.value === studentIds.value.length - 1
|
|
|
|
+ );
|
|
|
|
+ const isMultiStudent = computed(() => studentIds.value.length > 1);
|
|
|
|
|
|
async function getNextStudent() {
|
|
async function getNextStudent() {
|
|
- if (isLast) {
|
|
|
|
|
|
+ if (isLast.value) {
|
|
void message.warning("已经是最后一份!");
|
|
void message.warning("已经是最后一份!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- await updateTask(studentIds[currentIndex + 1]);
|
|
|
|
|
|
+ await updateTask(studentIds.value[currentIndex.value + 1]);
|
|
}
|
|
}
|
|
|
|
|
|
async function getPreviousStudent() {
|
|
async function getPreviousStudent() {
|
|
- if (isFirst) {
|
|
|
|
|
|
+ if (isFirst.value) {
|
|
void message.warning("已经是第一份!");
|
|
void message.warning("已经是第一份!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- await updateTask(studentIds[currentIndex - 1]);
|
|
|
|
|
|
+ await updateTask(studentIds.value[currentIndex.value - 1]);
|
|
}
|
|
}
|
|
|
|
|
|
async function updateTask(studentId) {
|
|
async function updateTask(studentId) {
|
|
@@ -39,7 +44,7 @@ export default function useTask(ids: string[]) {
|
|
newTask.sheetUrls = newTask.sheetUrls || [];
|
|
newTask.sheetUrls = newTask.sheetUrls || [];
|
|
newTask.sliceUrls = [...newTask.sheetUrls];
|
|
newTask.sliceUrls = [...newTask.sheetUrls];
|
|
markStore.currentTask = newTask;
|
|
markStore.currentTask = newTask;
|
|
- currentStudentId = studentId;
|
|
|
|
|
|
+ currentStudentId.value = studentId;
|
|
}
|
|
}
|
|
|
|
|
|
return {
|
|
return {
|