|
@@ -3,13 +3,13 @@
|
|
custom-class="question-preview-dialog edit-paper"
|
|
custom-class="question-preview-dialog edit-paper"
|
|
:visible.sync="modalIsShow"
|
|
:visible.sync="modalIsShow"
|
|
title="试题预览"
|
|
title="试题预览"
|
|
- width="1000px"
|
|
|
|
- top="20px"
|
|
|
|
|
|
+ top="0"
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
:close-on-press-escape="false"
|
|
:close-on-press-escape="false"
|
|
append-to-body
|
|
append-to-body
|
|
|
|
+ @open="openHandle"
|
|
>
|
|
>
|
|
- <div v-if="modalIsShow" class="edit-part">
|
|
|
|
|
|
+ <div class="edit-part" :key="question.id">
|
|
<div class="edit-cont">
|
|
<div class="edit-cont">
|
|
<div class="edit-cont-title">
|
|
<div class="edit-cont-title">
|
|
<rich-text :text-json="question.quesBody"></rich-text>
|
|
<rich-text :text-json="question.quesBody"></rich-text>
|
|
@@ -110,8 +110,18 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <div slot="footer">
|
|
|
|
- <el-button @click="cancel">关闭</el-button>
|
|
|
|
|
|
+ <div class="box-justify" slot="footer">
|
|
|
|
+ <div>
|
|
|
|
+ <template v-if="showSwitch">
|
|
|
|
+ <el-button :disabled="loading" size="mini" @click="toPrev"
|
|
|
|
+ >上一题</el-button
|
|
|
|
+ >
|
|
|
|
+ <el-button :disabled="loading" size="mini" @click="toNext"
|
|
|
|
+ >下一题</el-button
|
|
|
|
+ >
|
|
|
|
+ </template>
|
|
|
|
+ </div>
|
|
|
|
+ <el-button size="mini" @click="cancel">关闭</el-button>
|
|
</div>
|
|
</div>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
</template>
|
|
</template>
|
|
@@ -123,19 +133,48 @@ export default {
|
|
name: "QuestionPreviewDialog",
|
|
name: "QuestionPreviewDialog",
|
|
components: { QuestionAnswer },
|
|
components: { QuestionAnswer },
|
|
props: {
|
|
props: {
|
|
- question: {
|
|
|
|
|
|
+ data: {
|
|
|
|
+ type: Object,
|
|
|
|
+ default: null,
|
|
|
|
+ },
|
|
|
|
+ showSwitch: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false,
|
|
|
|
+ },
|
|
|
|
+ listInfo: {
|
|
type: Object,
|
|
type: Object,
|
|
- default() {
|
|
|
|
- return {};
|
|
|
|
- },
|
|
|
|
|
|
+ default: null,
|
|
|
|
+ // {dataList,curIndex,pageNumber,totalPages}
|
|
|
|
+ },
|
|
|
|
+ fetchPage: {
|
|
|
|
+ type: Function,
|
|
|
|
+ default: null,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
modalIsShow: false,
|
|
modalIsShow: false,
|
|
|
|
+ question: {},
|
|
|
|
+ curIndex: 0,
|
|
|
|
+ loading: false,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ watch: {
|
|
|
|
+ data(val) {
|
|
|
|
+ this.question = val;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
|
|
+ openHandle() {
|
|
|
|
+ if (this.data) {
|
|
|
|
+ this.question = this.data;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!this.listInfo) return;
|
|
|
|
+ this.curIndex = this.listInfo.curIndex;
|
|
|
|
+ this.selectQuestion();
|
|
|
|
+ },
|
|
cancel() {
|
|
cancel() {
|
|
this.modalIsShow = false;
|
|
this.modalIsShow = false;
|
|
},
|
|
},
|
|
@@ -157,6 +196,73 @@ export default {
|
|
const typeQuestion = ["PARAGRAPH_MATCHING", "BANKED_CLOZE"];
|
|
const typeQuestion = ["PARAGRAPH_MATCHING", "BANKED_CLOZE"];
|
|
return typeQuestion.includes(questionType);
|
|
return typeQuestion.includes(questionType);
|
|
},
|
|
},
|
|
|
|
+ toPrev() {
|
|
|
|
+ if (this.listInfo && this.fetchPage) {
|
|
|
|
+ this.prevQuestion();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.$emit("on-prev");
|
|
|
|
+ },
|
|
|
|
+ toNext() {
|
|
|
|
+ if (this.listInfo && this.fetchPage) {
|
|
|
|
+ this.nextQuestion();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.$emit("on-next");
|
|
|
|
+ },
|
|
|
|
+ // question view
|
|
|
|
+ selectQuestion() {
|
|
|
|
+ this.question = this.listInfo.dataList[this.curIndex];
|
|
|
|
+ },
|
|
|
|
+ async prevQuestion() {
|
|
|
|
+ const { pageNumber } = this.listInfo;
|
|
|
|
+ if (this.curIndex <= 0) {
|
|
|
|
+ if (pageNumber <= 1) {
|
|
|
|
+ this.$message.error("已经是第一道试题!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.loading = true;
|
|
|
|
+ let result = true;
|
|
|
|
+ await this.fetchPage(pageNumber - 1).catch(() => {
|
|
|
|
+ result = false;
|
|
|
|
+ });
|
|
|
|
+ this.loading = false;
|
|
|
|
+ if (!result) return;
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.curIndex = this.listInfo.dataList.length - 1;
|
|
|
|
+ this.selectQuestion();
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ this.curIndex--;
|
|
|
|
+ this.selectQuestion();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async nextQuestion() {
|
|
|
|
+ const { pageNumber, totalPages, dataList } = this.listInfo;
|
|
|
|
+ if (this.curIndex >= dataList.length - 1) {
|
|
|
|
+ if (pageNumber >= totalPages) {
|
|
|
|
+ this.$message.error("已经是最后一道试题!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.loading = true;
|
|
|
|
+ let result = true;
|
|
|
|
+ await this.fetchPage(pageNumber + 1).catch(() => {
|
|
|
|
+ result = false;
|
|
|
|
+ });
|
|
|
|
+ this.loading = false;
|
|
|
|
+ if (!result) return;
|
|
|
|
+
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.curIndex = 0;
|
|
|
|
+ this.selectQuestion();
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ this.curIndex++;
|
|
|
|
+ this.selectQuestion();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|