|
@@ -42,7 +42,7 @@
|
|
|
@deleteQuestion="deleteQuestion"
|
|
|
/>
|
|
|
|
|
|
- <div class="preview" :style="{ height: preview ? '300px' : 'auto' }">
|
|
|
+ <div class="preview" :style="{ height: preview ? 'calc(50vh - 32px)' : 'auto' }">
|
|
|
<div class="preview-header">
|
|
|
<span class="quick-preview">快捷预览:</span>
|
|
|
<div class="preview-right">
|
|
@@ -154,7 +154,7 @@ export default {
|
|
|
content,
|
|
|
})
|
|
|
.then(() => {
|
|
|
- this.getExerciseQuestionIndexList();
|
|
|
+ this.getExerciseQuestionIndexList(false, true);
|
|
|
})
|
|
|
.catch(() => {
|
|
|
this.$message.error('添加失败');
|
|
@@ -169,12 +169,17 @@ export default {
|
|
|
},
|
|
|
/**
|
|
|
* 获取练习题目索引列表
|
|
|
+ * @param {boolean} init 是否初始化
|
|
|
+ * @param {boolean} isAdd 是否添加题目
|
|
|
*/
|
|
|
- getExerciseQuestionIndexList(init) {
|
|
|
+ getExerciseQuestionIndexList(init = false, isAdd = false) {
|
|
|
GetExerciseQuestionIndexList({ exercise_id: this.exercise_id })
|
|
|
.then(({ index_list }) => {
|
|
|
this.index_list = index_list;
|
|
|
|
|
|
+ if (isAdd) {
|
|
|
+ this.curIndex = this.index_list.length - 1;
|
|
|
+ }
|
|
|
if (!init) return;
|
|
|
this.getQuestionInfo();
|
|
|
})
|
|
@@ -289,7 +294,7 @@ export default {
|
|
|
},
|
|
|
/**
|
|
|
* 修改当前题目类型
|
|
|
- * @param {Array} arr
|
|
|
+ * @param {array} arr
|
|
|
*/
|
|
|
updateCurQuestionType(arr) {
|
|
|
let type = arr[arr.length - 1];
|
|
@@ -302,13 +307,22 @@ export default {
|
|
|
* @param {number} param.oldIndex 移动前的索引
|
|
|
*/
|
|
|
moveQuestion({ newIndex, oldIndex }) {
|
|
|
+ let isMoveCur = newIndex === this.curIndex || oldIndex === this.curIndex; // 是否移动当前题目
|
|
|
+ let isEffectCurIndex = newIndex < this.curIndex !== oldIndex < this.curIndex; // 是否影响当前题目索引
|
|
|
+ if (isMoveCur) {
|
|
|
+ this.curIndex = this.curIndex === newIndex ? oldIndex : newIndex;
|
|
|
+ } else if (isEffectCurIndex) {
|
|
|
+ this.curIndex = newIndex < this.curIndex ? this.curIndex + 1 : this.curIndex - 1;
|
|
|
+ }
|
|
|
+ if (isMoveCur || isEffectCurIndex) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.createMain.$refs.exercise?.[0].setQuestion(this.moveQuestionData);
|
|
|
+ this.isMoveQuestion = false;
|
|
|
+ this.refreshPreviewData();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
let order = newIndex > oldIndex;
|
|
|
- this.curIndex = this.curIndex === newIndex ? oldIndex : newIndex;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.createMain.$refs.exercise?.[0].setQuestion(this.moveQuestionData);
|
|
|
- this.isMoveQuestion = false;
|
|
|
- this.refreshPreviewData();
|
|
|
- });
|
|
|
MoveQuestion({
|
|
|
question_id: this.index_list[newIndex].id,
|
|
|
dest_question_id: this.index_list[order ? newIndex - 1 : newIndex + 1].id,
|
|
@@ -328,9 +342,19 @@ export default {
|
|
|
this.$message.error('移动失败');
|
|
|
});
|
|
|
},
|
|
|
- handleStart() {
|
|
|
- this.isMoveQuestion = true;
|
|
|
- this.moveQuestionData = this.$refs.createMain.$refs.exercise?.[0].data;
|
|
|
+ /**
|
|
|
+ * 开始移动题目
|
|
|
+ * @param {object} param 移动参数
|
|
|
+ * @param {number} param.newIndex 移动后的索引
|
|
|
+ * @param {number} param.oldIndex 移动前的索引
|
|
|
+ */
|
|
|
+ handleStart({ newIndex, oldIndex }) {
|
|
|
+ let isMoveCur = newIndex === this.curIndex || oldIndex === this.curIndex; // 是否移动当前题目
|
|
|
+ let isEffectCurIndex = newIndex < this.curIndex !== oldIndex < this.curIndex; // 是否影响当前题目索引
|
|
|
+ if (isMoveCur || isEffectCurIndex) {
|
|
|
+ this.isMoveQuestion = true;
|
|
|
+ this.moveQuestionData = this.$refs.createMain.$refs.exercise?.[0].data;
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
};
|