|
@@ -1,11 +1,20 @@
|
|
|
<template>
|
|
|
<div class="paper-template-build">
|
|
|
<div class="paper-template-build-body">
|
|
|
- <div class="box-justify margin_top_10">
|
|
|
- <el-button type="primary" @click="toDownload">下载试卷</el-button>
|
|
|
+ <div class="margin_top_10">
|
|
|
+ <el-select
|
|
|
+ v-model="seqMode"
|
|
|
+ class="margin-right-10"
|
|
|
+ @change="seqModeChange"
|
|
|
+ >
|
|
|
+ <el-option value="MODE1" label="单题型连续"></el-option>
|
|
|
+ <el-option value="MODE2" label="客观题整体连续"></el-option>
|
|
|
+ <el-option value="MODE3" label="按大题独立"></el-option>
|
|
|
+ <el-option value="MODE5" label="整卷连续"></el-option>
|
|
|
+ </el-select>
|
|
|
<el-select
|
|
|
v-model="curPaperTemp"
|
|
|
- class="size-select"
|
|
|
+ class="margin-right-10"
|
|
|
placeholder="请选择"
|
|
|
value-key="id"
|
|
|
@change="paperTempChange"
|
|
@@ -18,6 +27,7 @@
|
|
|
>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
+ <el-button type="primary" @click="toDownload">下载试卷</el-button>
|
|
|
</div>
|
|
|
<paper-template-view
|
|
|
ref="PaperTemplateView"
|
|
@@ -62,6 +72,8 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
paperId: this.$route.params.paperId,
|
|
|
+ viewType: this.$route.params.viewType,
|
|
|
+ seqMode: "MODE1",
|
|
|
renderStructList: [],
|
|
|
pages: [],
|
|
|
paperJson: {},
|
|
@@ -75,13 +87,83 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
+ if (this.viewType === "frame") {
|
|
|
+ this.initFrame();
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.initData();
|
|
|
},
|
|
|
methods: {
|
|
|
+ async initFrame() {
|
|
|
+ try {
|
|
|
+ const paperSet = window.parent.paperSet;
|
|
|
+ if (!paperSet) {
|
|
|
+ this.emitFrameResult(false, "数据缺失");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.seqMode = paperSet.seqMode;
|
|
|
+ this.curPaperTemp = paperSet.paperTemp;
|
|
|
+
|
|
|
+ await this.getPaperJson();
|
|
|
+
|
|
|
+ let paperTempJson = this.curPaperTemp.content
|
|
|
+ ? JSON.parse(this.curPaperTemp.content)
|
|
|
+ : { pages: [] };
|
|
|
+ this.paperTempJson = paperTempJson;
|
|
|
+ this.pages = paperTempJson.pages;
|
|
|
+ this.updaterFieldInfo();
|
|
|
+ } catch (error) {
|
|
|
+ this.emitFrameResult(false, "数据错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$nextTick(async () => {
|
|
|
+ try {
|
|
|
+ this.maxColumnWidth =
|
|
|
+ document.getElementById("column-0-0").offsetWidth;
|
|
|
+ this.maxColumnHeight =
|
|
|
+ document.getElementById("column-0-0").offsetHeight;
|
|
|
+ this.parseRenderStructList();
|
|
|
+ this.buildPrePages();
|
|
|
+ } catch (error) {
|
|
|
+ this.emitFrameResult(false, "构建错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ const loadRes = await this.waitAllImgLoaded().catch(() => {});
|
|
|
+ if (!loadRes) {
|
|
|
+ this.emitFrameResult(false, "数据缓存错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ try {
|
|
|
+ this.buildReleasePages();
|
|
|
+ this.emitFrameResult(true, "", this.getPreviewTemp());
|
|
|
+ } catch (error) {
|
|
|
+ this.emitFrameResult(false, "构建pdf错误");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ emitFrameResult(success = true, errorMsg = "", htmlCont = "") {
|
|
|
+ window.parent &&
|
|
|
+ window.parent.submitPaperTemp &&
|
|
|
+ window.parent.submitPaperTemp({
|
|
|
+ success,
|
|
|
+ errorMsg,
|
|
|
+ htmlCont,
|
|
|
+ templateId: this.curPaperTemp.id,
|
|
|
+ });
|
|
|
+ },
|
|
|
async initData() {
|
|
|
await this.getPaperJson();
|
|
|
await this.getPaperTempList();
|
|
|
|
|
|
+ if (!this.paperTempList.length) {
|
|
|
+ this.$message.error("导出模板缺失!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.paperTempChange(this.paperTempList[0]);
|
|
|
+
|
|
|
// test--->
|
|
|
// this.paperJson = paperJson;
|
|
|
// this.paperTempJson = paperTempJson;
|
|
@@ -91,7 +173,10 @@ export default {
|
|
|
// });
|
|
|
},
|
|
|
async getPaperJson() {
|
|
|
- const res = await paperDetailInfoApi(this.paperId);
|
|
|
+ const res = await paperDetailInfoApi({
|
|
|
+ paperId: this.paperId,
|
|
|
+ seqMode: this.seqMode,
|
|
|
+ });
|
|
|
this.paperJson = res.data;
|
|
|
this.fieldData = {
|
|
|
paperName: res.data.name,
|
|
@@ -100,17 +185,18 @@ export default {
|
|
|
rootOrgName: res.data.rootOrgName,
|
|
|
};
|
|
|
},
|
|
|
+ async seqModeChange() {
|
|
|
+ await this.getPaperJson();
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.buildData();
|
|
|
+ });
|
|
|
+ },
|
|
|
async getPaperTempList() {
|
|
|
const res = await paperTemplateListApi("PAPER_EXPORT");
|
|
|
this.paperTempList = res.data;
|
|
|
- if (!this.paperTempList.length) {
|
|
|
- this.$message.error("导出模板缺失!");
|
|
|
- return Promise.reject();
|
|
|
- }
|
|
|
- this.paperTempChange(this.paperTempList[0]);
|
|
|
},
|
|
|
paperTempChange(paperTemp) {
|
|
|
- console.log(paperTemp);
|
|
|
+ // console.log(paperTemp);
|
|
|
this.curPaperTemp = paperTemp;
|
|
|
let paperTempJson = paperTemp.content
|
|
|
? JSON.parse(paperTemp.content)
|
|
@@ -548,7 +634,7 @@ export default {
|
|
|
imgUrls.push(...this.getRichJsonImgUrls(item.content));
|
|
|
});
|
|
|
|
|
|
- console.log(imgUrls);
|
|
|
+ // console.log(imgUrls);
|
|
|
|
|
|
if (!imgUrls.length) return Promise.resolve(true);
|
|
|
const imgLoads = imgUrls.map((item) => this.loadImg(item));
|