|
@@ -37,6 +37,7 @@
|
|
|
ref="createMain"
|
|
|
:cur-index="curIndex"
|
|
|
:index-list="index_list"
|
|
|
+ :loading="loading"
|
|
|
@selectExerciseItem="selectExerciseItem"
|
|
|
@setPreview="setPreview"
|
|
|
@deleteQuestion="deleteQuestion"
|
|
@@ -105,6 +106,7 @@ export default {
|
|
|
const { id, back_url } = this.$route.query;
|
|
|
|
|
|
return {
|
|
|
+ loading: false, // 题目加载中
|
|
|
exercise_id: id, // 练习id
|
|
|
exercise: { name: '' }, // 练习信息
|
|
|
isEditExercise: false, // 是否编辑练习
|
|
@@ -212,8 +214,12 @@ export default {
|
|
|
*/
|
|
|
getQuestionInfo() {
|
|
|
if (this.index_list.length === 0) return;
|
|
|
+ this.$refs.createMain.clearSaveDate();
|
|
|
+ this.loading = true;
|
|
|
+ let curI = this.curIndex;
|
|
|
GetQuestionInfo({ question_id: this.index_list[this.curIndex].id })
|
|
|
.then(({ question, file_list }) => {
|
|
|
+ if (curI !== this.curIndex) return;
|
|
|
this.$refs.createMain.resetSaveDate();
|
|
|
if (!question.content) return;
|
|
|
// 将题目文件id列表添加到题目内容中
|
|
@@ -224,6 +230,7 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.createMain.$refs.exercise?.[0].setQuestion(content);
|
|
|
this.refreshPreviewData();
|
|
|
+ this.loading = false;
|
|
|
});
|
|
|
})
|
|
|
.catch(() => {});
|
|
@@ -316,11 +323,12 @@ export default {
|
|
|
} else if (isEffectCurIndex) {
|
|
|
this.curIndex = newIndex < this.curIndex ? this.curIndex + 1 : this.curIndex - 1;
|
|
|
}
|
|
|
+ this.isMoveQuestion = false;
|
|
|
if (isMoveCur || isEffectCurIndex) {
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.createMain.$refs.exercise?.[0].setQuestion(this.moveQuestionData);
|
|
|
- this.isMoveQuestion = false;
|
|
|
this.refreshPreviewData();
|
|
|
+ this.$refs.createMain.resetSaveDate();
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -332,10 +340,12 @@ export default {
|
|
|
})
|
|
|
.then(() => {
|
|
|
this.$message.success('移动成功');
|
|
|
+ let curI = this.curIndex;
|
|
|
// 移动题目后,单独更新当前题目的题号
|
|
|
GetQuestionInfo({ question_id: this.index_list[this.curIndex].id })
|
|
|
.then(({ question }) => {
|
|
|
if (!question) return;
|
|
|
+ if (curI !== this.curIndex) return;
|
|
|
this.$refs.createMain.$refs.exercise?.[0].setQuestionNumber(question.question_number);
|
|
|
})
|
|
|
.catch(() => {});
|
|
@@ -351,6 +361,7 @@ export default {
|
|
|
* @param {number} param.oldIndex 移动前的索引
|
|
|
*/
|
|
|
handleStart({ newIndex, oldIndex }) {
|
|
|
+ this.$refs.createMain.clearSaveDate();
|
|
|
let isMoveCur = newIndex === this.curIndex || oldIndex === this.curIndex; // 是否移动当前题目
|
|
|
let isEffectCurIndex = newIndex < this.curIndex !== oldIndex < this.curIndex; // 是否影响当前题目索引
|
|
|
if (isMoveCur || isEffectCurIndex) {
|