|
@@ -118,7 +118,8 @@ export default {
|
|
|
dialogWidth: '860px',
|
|
dialogWidth: '860px',
|
|
|
themeColor: '',
|
|
themeColor: '',
|
|
|
bookFontSize: '',
|
|
bookFontSize: '',
|
|
|
- previewType: 'previewCheckShow'
|
|
|
|
|
|
|
+ previewType: 'previewCheckShow',
|
|
|
|
|
+ submitting: false
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
@@ -198,30 +199,63 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- finishTaskMaterial() {
|
|
|
|
|
|
|
+ async finishTaskMaterial() {
|
|
|
|
|
+ if (this.submitting) return;
|
|
|
if (this.exam_answer.length === 0 && this.category === 'GCLS') {
|
|
if (this.exam_answer.length === 0 && this.category === 'GCLS') {
|
|
|
this.$message.warning(this.$i18n.t('Key333'));
|
|
this.$message.warning(this.$i18n.t('Key333'));
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (this.category === 'EEP') {
|
|
|
|
|
- this.exam_answer = this.$refs.eep.getAllComponentUserAnswer();
|
|
|
|
|
- }
|
|
|
|
|
- const loading = this.$loading();
|
|
|
|
|
- FinishMyTaskMaterial_Student({
|
|
|
|
|
- task_id: this.id,
|
|
|
|
|
- material_type: 'COURSEWARE',
|
|
|
|
|
- material_id: this.coursewareId,
|
|
|
|
|
- exam_answer: this.exam_answer
|
|
|
|
|
- })
|
|
|
|
|
- .then(() => {
|
|
|
|
|
- this.$message.success(this.$i18n.t('Key334'));
|
|
|
|
|
- this.dialogClose();
|
|
|
|
|
- this.$router.go(0);
|
|
|
|
|
- })
|
|
|
|
|
- .finally(() => {
|
|
|
|
|
- loading.close();
|
|
|
|
|
- this.exam_answer = '';
|
|
|
|
|
|
|
+
|
|
|
|
|
+ this.submitting = true;
|
|
|
|
|
+ let loading = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (this.category === 'EEP') {
|
|
|
|
|
+ loading = this.$loading({ lock: true, text: '正在提交,请稍候…' });
|
|
|
|
|
+ // 录音在“停止录音”时已异步上传,这里先停止仍在录制的录音并等待上传完成,
|
|
|
|
|
+ // 避免把 MB 级 base64 录音内联进答案导致提交请求超时
|
|
|
|
|
+ const eep = this.$refs.eep;
|
|
|
|
|
+ if (!eep || typeof eep.getAllComponentUserAnswer !== 'function') {
|
|
|
|
|
+ loading.close();
|
|
|
|
|
+ loading = null;
|
|
|
|
|
+ this.$message.error('课件尚未加载完成,请稍后重试');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (typeof eep.waitForPendingRecordings === 'function') {
|
|
|
|
|
+ const { timedOut } = await eep.waitForPendingRecordings();
|
|
|
|
|
+ const { oversize } =
|
|
|
|
|
+ typeof eep.validateAnswerSize === 'function' ? eep.validateAnswerSize() : { oversize: [] };
|
|
|
|
|
+ if (timedOut || oversize.length > 0) {
|
|
|
|
|
+ loading.close();
|
|
|
|
|
+ loading = null;
|
|
|
|
|
+ this.$message.error(
|
|
|
|
|
+ timedOut
|
|
|
|
|
+ ? '录音上传超时,请检查网络后重试'
|
|
|
|
|
+ : `有 ${oversize.length} 处录音未能上传,请稍后重试或重新录制`
|
|
|
|
|
+ );
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ this.exam_answer = eep.getAllComponentUserAnswer();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!loading) loading = this.$loading();
|
|
|
|
|
+ await FinishMyTaskMaterial_Student({
|
|
|
|
|
+ task_id: this.id,
|
|
|
|
|
+ material_type: 'COURSEWARE',
|
|
|
|
|
+ material_id: this.coursewareId,
|
|
|
|
|
+ exam_answer: this.exam_answer
|
|
|
});
|
|
});
|
|
|
|
|
+ this.$message.success(this.$i18n.t('Key334'));
|
|
|
|
|
+ this.dialogClose();
|
|
|
|
|
+ this.$router.go(0);
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ // 请求错误已由响应拦截器提示,这里只兜底非请求异常
|
|
|
|
|
+ if (!e || !e.isAxiosError) this.$message.error('提交失败,请稍后重试');
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ if (loading) loading.close();
|
|
|
|
|
+ this.submitting = false;
|
|
|
|
|
+ this.exam_answer = '';
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
dialogClose() {
|
|
dialogClose() {
|