|
@@ -28,7 +28,7 @@
|
|
|
</ul>
|
|
|
</div>
|
|
|
<div class="list-operate">
|
|
|
- <!-- <el-button type="primary">批量导入</el-button> -->
|
|
|
+ <!-- <el-button type="primary" @click="oneClickImport">一键导入</el-button> -->
|
|
|
<el-button type="primary" @click="showSelectQuestionType">新建</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -67,11 +67,12 @@
|
|
|
</div>
|
|
|
|
|
|
<SelectQuestionType :visible.sync="visible" @addQuestionToExercise="addQuestionToExercise" />
|
|
|
+ <ImportPage :visible.sync="importVisible" @oneKeyImport="oneKeyImport" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { exerciseNames, questionDataList } from '../data/questionType';
|
|
|
+import { exerciseNames, questionDataList, analysisOneKeyImportData } from '../data/questionType';
|
|
|
import {
|
|
|
AddQuestionToExercise,
|
|
|
DeleteQuestion,
|
|
@@ -84,6 +85,7 @@ import {
|
|
|
|
|
|
import CreateMain from './components/create.vue';
|
|
|
import PreviewQuestionTypeMixin from '../data/PreviewQuestionTypeMixin';
|
|
|
+import ImportPage from './components/common/ImportPage.vue';
|
|
|
import SelectQuestionType from './components/common/SelectQuestionType.vue';
|
|
|
import draggable from 'vuedraggable';
|
|
|
|
|
@@ -93,6 +95,7 @@ export default {
|
|
|
CreateMain,
|
|
|
SelectQuestionType,
|
|
|
draggable,
|
|
|
+ ImportPage,
|
|
|
},
|
|
|
mixins: [PreviewQuestionTypeMixin],
|
|
|
provide() {
|
|
@@ -100,6 +103,9 @@ export default {
|
|
|
updateCurQuestionType: this.updateCurQuestionType,
|
|
|
exercise_id: this.exercise_id,
|
|
|
refreshPreviewData: this.refreshPreviewData,
|
|
|
+ updateLoading: (loading) => {
|
|
|
+ this.loading = loading;
|
|
|
+ },
|
|
|
};
|
|
|
},
|
|
|
data() {
|
|
@@ -119,6 +125,7 @@ export default {
|
|
|
previewData: {}, // 预览数据
|
|
|
back_url: back_url || '/personal_question', // 返回地址
|
|
|
visible: false, // 选择题目类型弹窗
|
|
|
+ importVisible: false, // 一键导入弹窗
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -149,6 +156,7 @@ export default {
|
|
|
* @param {string} content 题目内容
|
|
|
*/
|
|
|
addQuestionToExercise(type, additional_type, content = '') {
|
|
|
+ this.$refs.createMain.saveQuestion();
|
|
|
AddQuestionToExercise({
|
|
|
exercise_id: this.exercise_id,
|
|
|
type,
|
|
@@ -165,6 +173,14 @@ export default {
|
|
|
showSelectQuestionType() {
|
|
|
this.visible = true;
|
|
|
},
|
|
|
+ oneClickImport() {
|
|
|
+ this.importVisible = true;
|
|
|
+ },
|
|
|
+ oneKeyImport(text) {
|
|
|
+ let questionList = text.split(/\n\s*\n+/);
|
|
|
+ console.log(questionList);
|
|
|
+ analysisOneKeyImportData(questionList);
|
|
|
+ },
|
|
|
// 创建默认题目
|
|
|
createDefaultQuestion() {
|
|
|
this.addQuestionToExercise('select', 'single', questionDataList['select']);
|
|
@@ -216,10 +232,10 @@ export default {
|
|
|
if (this.index_list.length === 0) return;
|
|
|
this.$refs.createMain.clearSaveDate();
|
|
|
this.loading = true;
|
|
|
- let curI = this.curIndex;
|
|
|
+ let curId = this.index_list[this.curIndex].id;
|
|
|
GetQuestionInfo({ question_id: this.index_list[this.curIndex].id })
|
|
|
.then(({ question, file_list }) => {
|
|
|
- if (curI !== this.curIndex) return;
|
|
|
+ if (curId !== this.index_list[this.curIndex].id) return;
|
|
|
this.$refs.createMain.resetSaveDate();
|
|
|
if (!question.content) return;
|
|
|
// 将题目文件id列表添加到题目内容中
|
|
@@ -230,7 +246,6 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.createMain.$refs.exercise?.[0].setQuestion(content);
|
|
|
this.refreshPreviewData();
|
|
|
- this.loading = false;
|
|
|
});
|
|
|
})
|
|
|
.catch(() => {});
|
|
@@ -318,6 +333,11 @@ export default {
|
|
|
* @param {number} param.oldIndex 移动前的索引
|
|
|
*/
|
|
|
moveQuestion({ newIndex, oldIndex }) {
|
|
|
+ if (newIndex === oldIndex) {
|
|
|
+ this.isMoveQuestion = false;
|
|
|
+ this.moveQuestionData = {};
|
|
|
+ return;
|
|
|
+ }
|
|
|
let isMoveCur = newIndex === this.curIndex || oldIndex === this.curIndex; // 是否移动当前题目
|
|
|
let isEffectCurIndex = newIndex < this.curIndex !== oldIndex < this.curIndex; // 是否影响当前题目索引
|
|
|
if (isMoveCur) {
|
|
@@ -329,6 +349,7 @@ export default {
|
|
|
if (isMoveCur || isEffectCurIndex) {
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.createMain.$refs.exercise?.[0].setQuestion(this.moveQuestionData);
|
|
|
+ this.moveQuestionData = {};
|
|
|
this.refreshPreviewData();
|
|
|
this.$refs.createMain.resetSaveDate();
|
|
|
});
|