|
@@ -437,21 +437,36 @@
|
|
height="800"
|
|
height="800"
|
|
></iframe>
|
|
></iframe>
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
|
|
+ <!-- answer dom -->
|
|
|
|
+ <answer-template-view
|
|
|
|
+ v-if="paperJson"
|
|
|
|
+ ref="AnswerTemplateView"
|
|
|
|
+ id="answer-template-view"
|
|
|
|
+ class="preview-body"
|
|
|
|
+ :answerData="paperJson"
|
|
|
|
+ :pageCountMode="pageCountMode"
|
|
|
|
+ @rend-finished="rendFinished"
|
|
|
|
+ ></answer-template-view>
|
|
</section>
|
|
</section>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import PaperBuildConfig from "../../paper-export/components/PaperBuildConfig.vue";
|
|
import PaperBuildConfig from "../../paper-export/components/PaperBuildConfig.vue";
|
|
|
|
+import AnswerTemplateView from "../../paper-export/components/AnswerTemplateView.vue";
|
|
import { QUESTION_API } from "@/constants/constants";
|
|
import { QUESTION_API } from "@/constants/constants";
|
|
import { LEVEL_TYPE, PUBLICITY_LIST } from "../constants/constants";
|
|
import { LEVEL_TYPE, PUBLICITY_LIST } from "../constants/constants";
|
|
import { mapState } from "vuex";
|
|
import { mapState } from "vuex";
|
|
import { downloadByApi, downloadByBlob } from "@/plugins/download";
|
|
import { downloadByApi, downloadByBlob } from "@/plugins/download";
|
|
import { paperTemplateListApi } from "../../paper-export/api";
|
|
import { paperTemplateListApi } from "../../paper-export/api";
|
|
import { deepCopy } from "@/plugins/utils";
|
|
import { deepCopy } from "@/plugins/utils";
|
|
|
|
+import { paperDetailInfoApi } from "../../paper/api";
|
|
|
|
+import { buildPdf } from "@/plugins/htmlToPdf";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
PaperBuildConfig,
|
|
PaperBuildConfig,
|
|
|
|
+ AnswerTemplateView,
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
@@ -527,6 +542,7 @@ export default {
|
|
paperTempList: [],
|
|
paperTempList: [],
|
|
configSources: [],
|
|
configSources: [],
|
|
configModalForm: {},
|
|
configModalForm: {},
|
|
|
|
+ paperJson: null,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -1107,7 +1123,7 @@ export default {
|
|
// console.log(href);
|
|
// console.log(href);
|
|
this.paperPreviewUrl = href;
|
|
this.paperPreviewUrl = href;
|
|
},
|
|
},
|
|
- toDownloadAnswerPdf() {
|
|
|
|
|
|
+ toDownloadAnswerPdf1() {
|
|
if (this.downloading) return;
|
|
if (this.downloading) return;
|
|
this.downloading = true;
|
|
this.downloading = true;
|
|
window.answerSet = {
|
|
window.answerSet = {
|
|
@@ -1127,6 +1143,54 @@ export default {
|
|
});
|
|
});
|
|
this.answerPreviewUrl = href;
|
|
this.answerPreviewUrl = href;
|
|
},
|
|
},
|
|
|
|
+ async toDownloadAnswerPdf() {
|
|
|
|
+ if (this.downloading) return;
|
|
|
|
+ this.downloading = true;
|
|
|
|
+
|
|
|
|
+ await this.getPaperJson().catch(() => {
|
|
|
|
+ this.downloading = false;
|
|
|
|
+ this.$message.error("生成答案pdf错误");
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ async rendFinished() {
|
|
|
|
+ const answerPdfName = `${this.exportModel.courseName}(${this.exportModel.courseCode})_${this.exportModel.paperName}_答案.pdf`;
|
|
|
|
+ await buildPdf({
|
|
|
|
+ elements: document
|
|
|
|
+ .getElementById("answer-template-view")
|
|
|
|
+ .querySelectorAll(".page-answer-flat"),
|
|
|
|
+ filename: answerPdfName,
|
|
|
|
+ pageSize: "A4",
|
|
|
|
+ }).catch((error) => {
|
|
|
|
+ console.error(error);
|
|
|
|
+ this.downloading = false;
|
|
|
|
+ this.$message.error("生成答案pdf错误");
|
|
|
|
+ });
|
|
|
|
+ this.paperJson = null;
|
|
|
|
+ this.$message.success("答案pdf生成成功");
|
|
|
|
+ },
|
|
|
|
+ async getPaperJson() {
|
|
|
|
+ const res = await paperDetailInfoApi({
|
|
|
|
+ paperId: this.exportModel.id,
|
|
|
|
+ seqMode: this.exportModel.seqMode,
|
|
|
|
+ });
|
|
|
|
+ this.paperJson = res.data;
|
|
|
|
+ this.resetClozeSerialNo(this.paperJson);
|
|
|
|
+ },
|
|
|
|
+ resetClozeSerialNo(paperData) {
|
|
|
|
+ const clozeQuestionTypes = ["CLOZE", "BANKED_CLOZE"];
|
|
|
|
+ paperData.paperDetails.forEach((detail) => {
|
|
|
|
+ detail.paperDetailUnits.forEach((question) => {
|
|
|
|
+ if (!clozeQuestionTypes.includes(question.questionType)) return;
|
|
|
|
+ question.question.quesBody.sections.forEach((section) => {
|
|
|
|
+ section.blocks.forEach((block) => {
|
|
|
|
+ if (block.type !== "cloze") return;
|
|
|
|
+ block.value =
|
|
|
|
+ question.question.subQuestions[block.value - 1].questionSeq;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ },
|
|
registWindowSubmit() {
|
|
registWindowSubmit() {
|
|
window.submitPaperTemp = async ({
|
|
window.submitPaperTemp = async ({
|
|
success,
|
|
success,
|