|
|
@@ -21,7 +21,7 @@
|
|
|
@change="handleSwiperChange" @transition="handleSwiperTransition"
|
|
|
@animationfinish="handleSwiperAnimationFinish">
|
|
|
<swiper-item class="h-full" v-for="(item, index) in questionList" :key="index">
|
|
|
- <question-item :question="item" />
|
|
|
+ <question-item :question="item" @update:question="handleUpdateQuestion" />
|
|
|
</swiper-item>
|
|
|
</swiper>
|
|
|
</view>
|
|
|
@@ -102,7 +102,7 @@ import { NEXT_QUESTION, PREV_QUESTION, NEXT_QUESTION_QUICKLY, PREV_QUESTION_QUIC
|
|
|
import { Examinee, ExamPaper, ExamPaperSubmit } from '@/types/study';
|
|
|
const { prevData, transferBack } = useTransferPage();
|
|
|
const { setQuestionList, questionList, stateQuestionList, questionTypeDesc, favoriteList, notKnowList, markList, currentIndex,
|
|
|
- totalCount, doneCount, notDoneCount, notKnowCount, markCount,
|
|
|
+ totalCount, doneCount, notDoneCount, notKnowCount, markCount, isAllDone,
|
|
|
loadExamData, nextQuestion, prevQuestion, nextQuestionQuickly, prevQuestionQuickly, swiperDuration,
|
|
|
formatPracticeDuration, formatExamDuration, practiceDuration, startPracticeDuration, stopPracticeDuration,
|
|
|
examDuration, startExamDuration, stopExamDuration, setExamDuration, setCountDownCallback, changeIndex, reset } = useExam();
|
|
|
@@ -116,6 +116,8 @@ const isAnimationFinish = ref(false);
|
|
|
const transitionStartX = ref(null);
|
|
|
const transitionEndX = ref(null);
|
|
|
const isReady = ref(false);
|
|
|
+// 自动提交只提醒1次
|
|
|
+const hasShowSubmitConfirm = ref(false);
|
|
|
const examineerData = ref<Examinee>({} as Examinee);
|
|
|
const paperData = ref<ExamPaper>({} as ExamPaper);
|
|
|
const pageTitle = computed(() => {
|
|
|
@@ -137,7 +139,6 @@ const handleLeftClick = () => {
|
|
|
beforeQuit();
|
|
|
};
|
|
|
const handleSwiperChange = (e: any) => {
|
|
|
- // console.log(e)
|
|
|
currentIndex.value = e.detail.current;
|
|
|
};
|
|
|
const beforeQuit = () => {
|
|
|
@@ -151,30 +152,24 @@ const beforeQuit = () => {
|
|
|
content: msg,
|
|
|
}).then(confirm => {
|
|
|
if (confirm) {
|
|
|
- handleSubmit();
|
|
|
+ handleSubmit(true);
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
const currentQuestion = computed(() => {
|
|
|
- // console.log(questionList.value[currentIndex.value])
|
|
|
return questionList.value[currentIndex.value] || {};
|
|
|
});
|
|
|
const hanadleNavigate = (index: number) => {
|
|
|
- // console.log('hanadleNavigate', qs)
|
|
|
- // const index = questionList.value.findIndex(q => q.id === qs.id);
|
|
|
changeIndex(index);
|
|
|
}
|
|
|
const handleFavorite = () => {
|
|
|
- // console.log('handleFavorite')
|
|
|
currentQuestion.value.isFavorite = !currentQuestion.value.isFavorite;
|
|
|
};
|
|
|
const handleMark = () => {
|
|
|
- // console.log('handleMark')
|
|
|
currentQuestion.value.isMark = !currentQuestion.value.isMark;
|
|
|
};
|
|
|
const questionStatsPopupRef = ref();
|
|
|
const handleCalendar = () => {
|
|
|
- console.log('handleCalendar')
|
|
|
questionStatsPopupRef.value.open();
|
|
|
};
|
|
|
|
|
|
@@ -229,8 +224,7 @@ const beforeSubmit = () => {
|
|
|
content: text,
|
|
|
}).then(confirm => {
|
|
|
if (confirm) {
|
|
|
- // uni.navigateBack();
|
|
|
- handleSubmit();
|
|
|
+ handleSubmit(false);
|
|
|
} else {
|
|
|
startTime();
|
|
|
}
|
|
|
@@ -255,24 +249,46 @@ const handleReset = () => {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-const handleSubmit = () => {
|
|
|
+const autoSubmit = () => {
|
|
|
+ if (isAllDone.value) {
|
|
|
+ if (hasShowSubmitConfirm.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ hasShowSubmitConfirm.value = true;
|
|
|
+ beforeSubmit();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleSubmit = (tempSave: boolean = false) => {
|
|
|
console.log('handleSubmit', questionList.value)
|
|
|
- uni.$ie.showLoading('保存中...');
|
|
|
+ const msg = tempSave ? '保存中...' : '提交中...';
|
|
|
+ uni.$ie.showLoading(msg);
|
|
|
setTimeout(() => {
|
|
|
uni.$ie.hideLoading();
|
|
|
const params = {
|
|
|
...paperData.value,
|
|
|
- questions: questionList.value,
|
|
|
+ questions: questionList.value.map(item => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ isDone: tempSave ? item.isDone : true
|
|
|
+ };
|
|
|
+ }),
|
|
|
examineeId: examineerData.value.examineeId,
|
|
|
+ isDone: isAllDone.value
|
|
|
} as ExamPaperSubmit;
|
|
|
if (!isExamMode.value) {
|
|
|
params.duration = practiceDuration.value;
|
|
|
}
|
|
|
- console.log(params);
|
|
|
commitExamineePaper(params);
|
|
|
uni.navigateBack();
|
|
|
}, 1000);
|
|
|
- console.log('handleSubmit')
|
|
|
+}
|
|
|
+
|
|
|
+const handleUpdateQuestion = (question: Study.Question) => {
|
|
|
+ // questionList.value[currentIndex.value] = question;
|
|
|
+ if (currentIndex.value === questionList.value.length - 1) {
|
|
|
+ autoSubmit();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const loadData = async () => {
|
|
|
@@ -300,7 +316,7 @@ const loadData = async () => {
|
|
|
}
|
|
|
isReady.value = true;
|
|
|
setCountDownCallback(() => {
|
|
|
- handleSubmit();
|
|
|
+ handleSubmit(false);
|
|
|
});
|
|
|
startTime();
|
|
|
};
|