|
@@ -5,6 +5,7 @@
|
|
<el-select
|
|
<el-select
|
|
v-model="seqMode"
|
|
v-model="seqMode"
|
|
class="margin-right-10"
|
|
class="margin-right-10"
|
|
|
|
+ size="small"
|
|
@change="seqModeChange"
|
|
@change="seqModeChange"
|
|
>
|
|
>
|
|
<el-option value="MODE1" label="单题型连续"></el-option>
|
|
<el-option value="MODE1" label="单题型连续"></el-option>
|
|
@@ -17,6 +18,7 @@
|
|
class="margin-right-10"
|
|
class="margin-right-10"
|
|
placeholder="请选择"
|
|
placeholder="请选择"
|
|
value-key="id"
|
|
value-key="id"
|
|
|
|
+ size="small"
|
|
@change="paperTempChange"
|
|
@change="paperTempChange"
|
|
>
|
|
>
|
|
<el-option
|
|
<el-option
|
|
@@ -27,8 +29,15 @@
|
|
>
|
|
>
|
|
</el-option>
|
|
</el-option>
|
|
</el-select>
|
|
</el-select>
|
|
- <el-button type="primary" @click="toDownload">下载试卷</el-button>
|
|
|
|
|
|
+ <el-button type="primary" size="small" @click="toDownload"
|
|
|
|
+ >下载试卷</el-button
|
|
|
|
+ >
|
|
</div>
|
|
</div>
|
|
|
|
+ <paper-build-config
|
|
|
|
+ ref="PaperBuildConfig"
|
|
|
|
+ :config-sources="configSources"
|
|
|
|
+ @confirm="buildConfigChange"
|
|
|
|
+ ></paper-build-config>
|
|
<paper-template-view
|
|
<paper-template-view
|
|
ref="PaperTemplateView"
|
|
ref="PaperTemplateView"
|
|
class="preview-body"
|
|
class="preview-body"
|
|
@@ -41,6 +50,7 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import PaperTemplateView from "../components/PaperTemplateView.vue";
|
|
import PaperTemplateView from "../components/PaperTemplateView.vue";
|
|
|
|
+import PaperBuildConfig from "../components/PaperBuildConfig.vue";
|
|
import { getModel as getRichTextModel } from "../elements/rich-text/model";
|
|
import { getModel as getRichTextModel } from "../elements/rich-text/model";
|
|
import { getModel as getPageModel } from "../elements/page/model";
|
|
import { getModel as getPageModel } from "../elements/page/model";
|
|
import { getElementId, randomCode, deepCopy } from "../../card/plugins/utils";
|
|
import { getElementId, randomCode, deepCopy } from "../../card/plugins/utils";
|
|
@@ -69,7 +79,7 @@ const checkRichTextHasCont = function (data) {
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "PaperTemplateBuild",
|
|
name: "PaperTemplateBuild",
|
|
- components: { PaperTemplateView },
|
|
|
|
|
|
+ components: { PaperTemplateView, PaperBuildConfig },
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
paperId: this.$route.params.paperId,
|
|
paperId: this.$route.params.paperId,
|
|
@@ -91,6 +101,12 @@ export default {
|
|
paperStructs: [],
|
|
paperStructs: [],
|
|
TEXT_INDENT_SIZE: 28,
|
|
TEXT_INDENT_SIZE: 28,
|
|
textIndent: 28,
|
|
textIndent: 28,
|
|
|
|
+ configModalForm: {
|
|
|
|
+ showDetailNo: true,
|
|
|
|
+ showDetailScoreTable: false,
|
|
|
|
+ },
|
|
|
|
+ configSources: [],
|
|
|
|
+ prepareDownloadPdf: false,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
@@ -197,7 +213,8 @@ export default {
|
|
this.resetClozeSerialNo(this.paperJson);
|
|
this.resetClozeSerialNo(this.paperJson);
|
|
this.fieldData = {
|
|
this.fieldData = {
|
|
paperName: res.data.name,
|
|
paperName: res.data.name,
|
|
- courseName: `${res.data.course.name}(${res.data.course.code})`,
|
|
|
|
|
|
+ courseName: res.data.course.name,
|
|
|
|
+ courseCode: res.data.course.code,
|
|
totalScore: res.data.totalScore,
|
|
totalScore: res.data.totalScore,
|
|
rootOrgName: res.data.rootOrgName,
|
|
rootOrgName: res.data.rootOrgName,
|
|
};
|
|
};
|
|
@@ -234,6 +251,44 @@ export default {
|
|
const res = await paperTemplateListApi("PAPER_EXPORT");
|
|
const res = await paperTemplateListApi("PAPER_EXPORT");
|
|
this.paperTempList = res.data;
|
|
this.paperTempList = res.data;
|
|
},
|
|
},
|
|
|
|
+ getConfigSources() {
|
|
|
|
+ const { pages } = this.paperTempJson;
|
|
|
|
+ let sources = [],
|
|
|
|
+ fieldAble = {};
|
|
|
|
+ pages.forEach((page) => {
|
|
|
|
+ page.columns.forEach((column) => {
|
|
|
|
+ column.elements.forEach((element) => {
|
|
|
|
+ if (element.type !== "PAPER_PROPS") return;
|
|
|
|
+ if (!sources.length) {
|
|
|
|
+ sources = deepCopy(element.props);
|
|
|
|
+ }
|
|
|
|
+ element.props.forEach((prop) => {
|
|
|
|
+ fieldAble[prop.field] = fieldAble[prop.field] || prop.enable;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ sources.forEach((item) => {
|
|
|
|
+ item.enable = fieldAble[item.field];
|
|
|
|
+ });
|
|
|
|
+ this.configSources = sources;
|
|
|
|
+ },
|
|
|
|
+ buildConfigChange(val) {
|
|
|
|
+ this.configModalForm = val;
|
|
|
|
+ this.updaterFieldInfo();
|
|
|
|
+
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.buildData();
|
|
|
|
+
|
|
|
|
+ if (this.prepareDownloadPdf) {
|
|
|
|
+ this.$nextTick(async () => {
|
|
|
|
+ await this.downloadPaperPdf().catch(() => {});
|
|
|
|
+ this.prepareDownloadPdf = false;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
paperTempChange(paperTemp) {
|
|
paperTempChange(paperTemp) {
|
|
// console.log(paperTemp);
|
|
// console.log(paperTemp);
|
|
this.curPaperTemp = paperTemp;
|
|
this.curPaperTemp = paperTemp;
|
|
@@ -242,6 +297,7 @@ export default {
|
|
: { pages: [], pageConfig: {} };
|
|
: { pages: [], pageConfig: {} };
|
|
this.paperTempJson = paperTempJson;
|
|
this.paperTempJson = paperTempJson;
|
|
this.pages = paperTempJson.pages;
|
|
this.pages = paperTempJson.pages;
|
|
|
|
+ this.getConfigSources();
|
|
this.updaterFieldInfo();
|
|
this.updaterFieldInfo();
|
|
|
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
@@ -255,6 +311,12 @@ export default {
|
|
column.elements.forEach((elem) => {
|
|
column.elements.forEach((elem) => {
|
|
if (elem.type === "PAPER_STRUCT") {
|
|
if (elem.type === "PAPER_STRUCT") {
|
|
elem.structs = this.paperStructs;
|
|
elem.structs = this.paperStructs;
|
|
|
|
+ } else if (elem.type === "SCORE_TABLE") {
|
|
|
|
+ elem.detailCount = this.paperStructs.length;
|
|
|
|
+ } else if (elem.type === "PAPER_PROPS") {
|
|
|
|
+ elem.props.forEach((prop) => {
|
|
|
|
+ prop.value = this.configModalForm[prop.field];
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
if (!elem.elements || !elem.elements.length) return;
|
|
if (!elem.elements || !elem.elements.length) return;
|
|
@@ -451,19 +513,25 @@ export default {
|
|
return contents;
|
|
return contents;
|
|
},
|
|
},
|
|
parseDetailTitle(data) {
|
|
parseDetailTitle(data) {
|
|
- let content = this.getRichStruct([
|
|
|
|
- {
|
|
|
|
- type: "text",
|
|
|
|
- value: `${data.cnNum}、`,
|
|
|
|
- },
|
|
|
|
|
|
+ let blocks = [
|
|
{
|
|
{
|
|
type: "text",
|
|
type: "text",
|
|
value: `${data.name}(共${data.unitCount}小题,满分${data.score}分)`,
|
|
value: `${data.name}(共${data.unitCount}小题,满分${data.score}分)`,
|
|
},
|
|
},
|
|
- ]);
|
|
|
|
|
|
+ ];
|
|
|
|
+ if (this.configModalForm.showDetailNo) {
|
|
|
|
+ blocks.unshift({
|
|
|
|
+ type: "text",
|
|
|
|
+ value: `${data.cnNum}、`,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ let content = this.getRichStruct(blocks);
|
|
return getRichTextModel({
|
|
return getRichTextModel({
|
|
styles: { width: "100%", fontWeight: 600 },
|
|
styles: { width: "100%", fontWeight: 600 },
|
|
content,
|
|
content,
|
|
|
|
+ classNames: this.configModalForm.showDetailScoreTable
|
|
|
|
+ ? "is-detail-title"
|
|
|
|
+ : "",
|
|
});
|
|
});
|
|
},
|
|
},
|
|
parseTitleOption(
|
|
parseTitleOption(
|
|
@@ -529,9 +597,27 @@ export default {
|
|
this.pages = pages;
|
|
this.pages = pages;
|
|
},
|
|
},
|
|
buildReleasePages() {
|
|
buildReleasePages() {
|
|
|
|
+ this.addDetailScoreTable();
|
|
this.resetRenderStructSize();
|
|
this.resetRenderStructSize();
|
|
// console.log(this.renderStructList);
|
|
// console.log(this.renderStructList);
|
|
this.buildPageAutoPage();
|
|
this.buildPageAutoPage();
|
|
|
|
+
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.addDetailScoreTable();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ addDetailScoreTable() {
|
|
|
|
+ if (!this.configModalForm.showDetailScoreTable) return;
|
|
|
|
+
|
|
|
|
+ const scoreTableHtml = `<table class="detail-score-table"><tr><th>得分</th><th>评分人</th></tr><tr><td></td><td></td></tr></table>`;
|
|
|
|
+ const dom = document.createElement("div");
|
|
|
|
+ dom.innerHTML = scoreTableHtml;
|
|
|
|
+ document.querySelectorAll(".is-detail-title").forEach((node) => {
|
|
|
|
+ const hasScoreTable =
|
|
|
|
+ node.firstChild.className.includes("detail-score-table");
|
|
|
|
+ if (hasScoreTable) return;
|
|
|
|
+ node.insertBefore(dom.firstChild.cloneNode(true), node.firstChild);
|
|
|
|
+ });
|
|
},
|
|
},
|
|
resetRenderStructSize() {
|
|
resetRenderStructSize() {
|
|
let curOptions = [];
|
|
let curOptions = [];
|
|
@@ -828,6 +914,20 @@ export default {
|
|
return previewTemp(this.$refs.PaperTemplateView.$el.outerHTML);
|
|
return previewTemp(this.$refs.PaperTemplateView.$el.outerHTML);
|
|
},
|
|
},
|
|
async toDownload() {
|
|
async toDownload() {
|
|
|
|
+ const valid = await this.$refs.PaperBuildConfig.checkData().catch(
|
|
|
|
+ () => {}
|
|
|
|
+ );
|
|
|
|
+ if (!valid) return;
|
|
|
|
+
|
|
|
|
+ const configData = this.$refs.PaperBuildConfig.getData();
|
|
|
|
+ if (JSON.stringify(configData) === JSON.stringify(this.configModalForm)) {
|
|
|
|
+ this.downloadPaperPdf();
|
|
|
|
+ } else {
|
|
|
|
+ this.prepareDownloadPdf = true;
|
|
|
|
+ this.buildConfigChange(configData);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async downloadPaperPdf() {
|
|
const htmlCont = this.getPreviewTemp();
|
|
const htmlCont = this.getPreviewTemp();
|
|
|
|
|
|
if (this.downloading) return;
|
|
if (this.downloading) return;
|
|
@@ -864,4 +964,14 @@ export default {
|
|
margin-top: 10px;
|
|
margin-top: 10px;
|
|
margin-bottom: 10px;
|
|
margin-bottom: 10px;
|
|
}
|
|
}
|
|
|
|
+.paper-template-build .paper-build-config {
|
|
|
|
+ padding: 10px 15px 2px;
|
|
|
|
+ margin-top: 5px;
|
|
|
|
+ background: #fff;
|
|
|
|
+ border-radius: 10px;
|
|
|
|
+}
|
|
|
|
+.paper-build-config .el-form-item {
|
|
|
|
+ margin-bottom: 16px;
|
|
|
|
+ margin-right: 30px;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|