|
@@ -228,10 +228,6 @@
|
|
<element-prop-edit ref="ElementPropEdit"></element-prop-edit>
|
|
<element-prop-edit ref="ElementPropEdit"></element-prop-edit>
|
|
<!-- right-click-menu -->
|
|
<!-- right-click-menu -->
|
|
<right-click-menu @inset-topic="insetNewTopic"></right-click-menu>
|
|
<right-click-menu @inset-topic="insetNewTopic"></right-click-menu>
|
|
- <!-- card-view-frame -->
|
|
|
|
- <div class="design-preview-frame" v-if="cardPreviewUrl">
|
|
|
|
- <iframe :src="cardPreviewUrl" frameborder="0"></iframe>
|
|
|
|
- </div>
|
|
|
|
<!-- paper-params -->
|
|
<!-- paper-params -->
|
|
<paper-params
|
|
<paper-params
|
|
:pages="pages"
|
|
:pages="pages"
|
|
@@ -250,7 +246,6 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { mapState, mapMutations, mapActions } from "vuex";
|
|
import { mapState, mapMutations, mapActions } from "vuex";
|
|
-import { cardConfigInfos, cardDetail, saveCard } from "../api";
|
|
|
|
import {
|
|
import {
|
|
getElementModel,
|
|
getElementModel,
|
|
getCardHeadModel,
|
|
getCardHeadModel,
|
|
@@ -271,6 +266,18 @@ import TopicSelectDialog from "../components/TopicSelectDialog";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "card-design",
|
|
name: "card-design",
|
|
|
|
+ props: {
|
|
|
|
+ content: {
|
|
|
|
+ type: Object,
|
|
|
|
+ default() {
|
|
|
|
+ return {
|
|
|
|
+ pages: [],
|
|
|
|
+ cardConfig: {},
|
|
|
|
+ paperParams: {}
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
components: {
|
|
components: {
|
|
// CardConfigPropEdit,
|
|
// CardConfigPropEdit,
|
|
TopicElementEdit,
|
|
TopicElementEdit,
|
|
@@ -285,20 +292,11 @@ export default {
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- cardId: this.$route.params.cardId || this.$ls.get("cardId"),
|
|
|
|
- prepareTcPCard: this.$ls.get("prepareTcPCard", {
|
|
|
|
- examTaskId: "",
|
|
|
|
- courseCode: "",
|
|
|
|
- courseName: "",
|
|
|
|
- makeMethod: "SELF",
|
|
|
|
- cardRuleId: ""
|
|
|
|
- }),
|
|
|
|
ELEMENT_LIST,
|
|
ELEMENT_LIST,
|
|
TOPIC_LIST,
|
|
TOPIC_LIST,
|
|
topicList: [],
|
|
topicList: [],
|
|
steps: ["添加标题", "基本设置", "试题配置", "预览生成"],
|
|
steps: ["添加标题", "基本设置", "试题配置", "预览生成"],
|
|
columnWidth: 0,
|
|
columnWidth: 0,
|
|
- cardPreviewUrl: "",
|
|
|
|
isSubmit: false,
|
|
isSubmit: false,
|
|
canSave: false
|
|
canSave: false
|
|
};
|
|
};
|
|
@@ -313,9 +311,6 @@ export default {
|
|
"curPage",
|
|
"curPage",
|
|
"curPageNo"
|
|
"curPageNo"
|
|
]),
|
|
]),
|
|
- isEdit() {
|
|
|
|
- return !!this.cardId;
|
|
|
|
- },
|
|
|
|
cardHeadSampleData() {
|
|
cardHeadSampleData() {
|
|
if (!this.cardConfig["pageSize"]) return;
|
|
if (!this.cardConfig["pageSize"]) return;
|
|
const data = getCardHeadModel(this.cardConfig);
|
|
const data = getCardHeadModel(this.cardConfig);
|
|
@@ -324,12 +319,7 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
- if (!this.prepareTcPCard.examTaskId && !this.isEdit) {
|
|
|
|
- this.$message.error("找不到命题任务,请退出题卡制作!");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
this.initCard();
|
|
this.initCard();
|
|
- this.registWindowSubmit();
|
|
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
...mapMutations("card", [
|
|
...mapMutations("card", [
|
|
@@ -354,47 +344,19 @@ export default {
|
|
"initTopicsFromPages"
|
|
"initTopicsFromPages"
|
|
]),
|
|
]),
|
|
async initCard() {
|
|
async initCard() {
|
|
- if (this.isEdit) {
|
|
|
|
- await this.getCardTempDetail();
|
|
|
|
- } else {
|
|
|
|
- await this.getCardConfig();
|
|
|
|
- this.initPageData();
|
|
|
|
- }
|
|
|
|
- this.addWatch();
|
|
|
|
- },
|
|
|
|
- getCardTitle(titleRule) {
|
|
|
|
- const fieldMap = {
|
|
|
|
- courseCode: this.prepareTcPCard.courseCode,
|
|
|
|
- courseName: this.prepareTcPCard.courseName,
|
|
|
|
- schoolName: this.prepareTcPCard.schoolName
|
|
|
|
- };
|
|
|
|
- Object.entries(fieldMap).forEach(([key, val]) => {
|
|
|
|
- titleRule = titleRule.replace("${" + key + "}", val);
|
|
|
|
- });
|
|
|
|
- return titleRule;
|
|
|
|
- },
|
|
|
|
- async getCardTempDetail() {
|
|
|
|
- const detData = await cardDetail(this.cardId);
|
|
|
|
- // this.canSave = !detData.operateStatus;
|
|
|
|
|
|
+ const { cardConfig, pages, paperParams } = this.content;
|
|
|
|
+ this.setCardConfig(cardConfig);
|
|
|
|
+ this.setPaperParams(paperParams);
|
|
|
|
|
|
- // 可能存在题卡内容没有记录的情况
|
|
|
|
- if (detData.content) {
|
|
|
|
- const cont = JSON.parse(detData.content);
|
|
|
|
- this.setPages(cont.pages);
|
|
|
|
- this.setCardConfig(cont.cardConfig);
|
|
|
|
- this.setPaperParams(cont.paperParams);
|
|
|
|
|
|
+ if (pages && pages.length) {
|
|
|
|
+ this.setPages(pages);
|
|
this.initTopicsFromPages();
|
|
this.initTopicsFromPages();
|
|
this.resetTopicSeries();
|
|
this.resetTopicSeries();
|
|
this.setCurPage(0);
|
|
this.setCurPage(0);
|
|
} else {
|
|
} else {
|
|
- await this.getCardConfig();
|
|
|
|
- // 没有题卡内容时,直接创建新的内容
|
|
|
|
- if (detData.makeMethod === "CUST") {
|
|
|
|
- this.setCardConfig({ cardTitle: detData.title });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
this.initPageData();
|
|
this.initPageData();
|
|
}
|
|
}
|
|
|
|
+ this.addWatch();
|
|
},
|
|
},
|
|
initPageData() {
|
|
initPageData() {
|
|
this.modifyCardHead({
|
|
this.modifyCardHead({
|
|
@@ -405,29 +367,6 @@ export default {
|
|
this.setCurPage(0);
|
|
this.setCurPage(0);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- async getCardConfig() {
|
|
|
|
- const data = await cardConfigInfos(this.prepareTcPCard.cardRuleId);
|
|
|
|
- if (!data) {
|
|
|
|
- this.$message.error("找不到题卡规则!");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- let config = {
|
|
|
|
- ...data,
|
|
|
|
- ...{
|
|
|
|
- pageSize: "A3",
|
|
|
|
- columnNumber: 2,
|
|
|
|
- columnGap: 20,
|
|
|
|
- showForbidArea: true,
|
|
|
|
- cardDesc: "",
|
|
|
|
- makeMethod: this.prepareTcPCard.makeMethod
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- config.aOrB = true; // 默认开启A/B卷型
|
|
|
|
- config.requiredFields = JSON.parse(config.requiredFields);
|
|
|
|
- config.extendFields = JSON.parse(config.extendFields);
|
|
|
|
- config.cardTitle = this.getCardTitle(config.titleRule);
|
|
|
|
- this.setCardConfig(config);
|
|
|
|
- },
|
|
|
|
addNewTopic(item) {
|
|
addNewTopic(item) {
|
|
let element = getElementModel(item.type);
|
|
let element = getElementModel(item.type);
|
|
element.w = document.getElementById("topic-column").offsetWidth;
|
|
element.w = document.getElementById("topic-column").offsetWidth;
|
|
@@ -461,22 +400,6 @@ export default {
|
|
});
|
|
});
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- // 操作
|
|
|
|
- async toPreview() {
|
|
|
|
- if (this.isSubmit) return;
|
|
|
|
- this.isSubmit = true;
|
|
|
|
- const result = await this.save().catch(() => {});
|
|
|
|
- this.isSubmit = false;
|
|
|
|
- if (!result) return;
|
|
|
|
- const { href } = this.$router.resolve({
|
|
|
|
- name: "CardPreview",
|
|
|
|
- params: {
|
|
|
|
- cardId: this.cardId,
|
|
|
|
- viewType: "view"
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- window.open(href);
|
|
|
|
- },
|
|
|
|
swithPage(pindex) {
|
|
swithPage(pindex) {
|
|
if (this.curPageNo === pindex) return;
|
|
if (this.curPageNo === pindex) return;
|
|
this.setCurPage(pindex);
|
|
this.setCurPage(pindex);
|
|
@@ -491,25 +414,13 @@ export default {
|
|
},
|
|
},
|
|
// save
|
|
// save
|
|
getCardData(htmlContent = "", model = "") {
|
|
getCardData(htmlContent = "", model = "") {
|
|
- let data = {
|
|
|
|
|
|
+ const data = {
|
|
title: this.cardConfig.cardTitle,
|
|
title: this.cardConfig.cardTitle,
|
|
content: model,
|
|
content: model,
|
|
- htmlContent,
|
|
|
|
- type: "CUSTOM",
|
|
|
|
- ...this.prepareTcPCard
|
|
|
|
|
|
+ htmlContent
|
|
};
|
|
};
|
|
- if (this.cardId) data.id = this.cardId;
|
|
|
|
return data;
|
|
return data;
|
|
},
|
|
},
|
|
- getRequestConfig() {
|
|
|
|
- return this.prepareTcPCard.makeMethod === "CUST"
|
|
|
|
- ? {
|
|
|
|
- headers: {
|
|
|
|
- schoolId: this.prepareTcPCard.schoolId
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- : {};
|
|
|
|
- },
|
|
|
|
checkElementCovered() {
|
|
checkElementCovered() {
|
|
let elements = [];
|
|
let elements = [];
|
|
this.pages.forEach(page => {
|
|
this.pages.forEach(page => {
|
|
@@ -547,9 +458,9 @@ export default {
|
|
|
|
|
|
return true;
|
|
return true;
|
|
},
|
|
},
|
|
- getModel() {
|
|
|
|
|
|
+ getCardJson() {
|
|
// 防止页面未渲染完成,各试题高度未及时更新,保存数据有误的问题
|
|
// 防止页面未渲染完成,各试题高度未及时更新,保存数据有误的问题
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
|
|
+ return new Promise(resolve => {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
const data = JSON.stringify(
|
|
const data = JSON.stringify(
|
|
{
|
|
{
|
|
@@ -564,90 +475,44 @@ export default {
|
|
}, 100);
|
|
}, 100);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- async save() {
|
|
|
|
- if (!this.checkCardValid()) return;
|
|
|
|
- const model = await this.getModel();
|
|
|
|
- let datas = this.getCardData("", model);
|
|
|
|
- datas.status = "STAGE";
|
|
|
|
- const result = await saveCard(datas, this.getRequestConfig());
|
|
|
|
- this.cardId = result;
|
|
|
|
- this.$ls.set("cardId", this.cardId);
|
|
|
|
- return true;
|
|
|
|
|
|
+ async toPreview() {
|
|
|
|
+ if (this.isSubmit) return;
|
|
|
|
+ this.isSubmit = true;
|
|
|
|
+ const model = await this.getCardJson();
|
|
|
|
+ const datas = this.getCardData("", model);
|
|
|
|
+ this.$emit("on-preview", datas);
|
|
},
|
|
},
|
|
async toSave() {
|
|
async toSave() {
|
|
|
|
+ if (!this.checkCardValid()) return;
|
|
|
|
+
|
|
if (this.isSubmit) return;
|
|
if (this.isSubmit) return;
|
|
this.isSubmit = true;
|
|
this.isSubmit = true;
|
|
- const result = await this.save().catch(() => {});
|
|
|
|
- this.isSubmit = false;
|
|
|
|
- if (result) this.$message.success("保存成功!");
|
|
|
|
|
|
+ const model = await this.getCardJson();
|
|
|
|
+ const datas = this.getCardData("", model);
|
|
|
|
+ this.$emit("on-save", datas);
|
|
},
|
|
},
|
|
toSubmit() {
|
|
toSubmit() {
|
|
if (this.isSubmit) return;
|
|
if (this.isSubmit) return;
|
|
-
|
|
|
|
if (!this.checkCardValid()) return;
|
|
if (!this.checkCardValid()) return;
|
|
|
|
|
|
- this.$confirm("确定要提交当前题卡吗?", "提示", {
|
|
|
|
- type: "warning"
|
|
|
|
- })
|
|
|
|
- .then(() => {
|
|
|
|
- window.cardData = {
|
|
|
|
- cardConfig: this.cardConfig,
|
|
|
|
- pages: this.pages,
|
|
|
|
- paperParams: this.paperParams
|
|
|
|
- };
|
|
|
|
- this.isSubmit = true;
|
|
|
|
- const { href } = this.$router.resolve({
|
|
|
|
- name: "CardPreview",
|
|
|
|
- params: {
|
|
|
|
- cardId: 1,
|
|
|
|
- viewType: "frame"
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- this.cardPreviewUrl = href;
|
|
|
|
- })
|
|
|
|
- .catch(() => {});
|
|
|
|
- },
|
|
|
|
- registWindowSubmit() {
|
|
|
|
- window.submitCardTemp = async (htmlContent, model) => {
|
|
|
|
- const datas = this.getCardData(htmlContent, model);
|
|
|
|
- datas.status = "SUBMIT";
|
|
|
|
- const result = await saveCard(
|
|
|
|
- datas,
|
|
|
|
- this.getRequestConfig()
|
|
|
|
- ).catch(() => {});
|
|
|
|
- this.cardPreviewUrl = "";
|
|
|
|
- this.isSubmit = false;
|
|
|
|
- window.cardData = null;
|
|
|
|
- if (result) {
|
|
|
|
- this.cardId = result;
|
|
|
|
- this.$ls.set("cardId", this.cardId);
|
|
|
|
- this.canSave = false;
|
|
|
|
- this.$message.success("提交成功!");
|
|
|
|
- this.goback();
|
|
|
|
- } else {
|
|
|
|
- this.$message.error("提交失败,请重新尝试!");
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ this.$emit("on-submit", {
|
|
|
|
+ cardConfig: this.cardConfig,
|
|
|
|
+ pages: this.pages,
|
|
|
|
+ paperParams: this.paperParams
|
|
|
|
+ });
|
|
},
|
|
},
|
|
toExit() {
|
|
toExit() {
|
|
- this.$confirm(
|
|
|
|
- "请确保当前题卡已经正常保存,确定要退出当前题卡编辑吗?",
|
|
|
|
- "提示",
|
|
|
|
- {
|
|
|
|
- type: "warning"
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
- .then(() => {
|
|
|
|
- this.goback();
|
|
|
|
- })
|
|
|
|
- .catch(() => {});
|
|
|
|
|
|
+ this.$emit("on-exit");
|
|
|
|
+ },
|
|
|
|
+ loading() {
|
|
|
|
+ this.isSubmit = true;
|
|
|
|
+ },
|
|
|
|
+ unloading() {
|
|
|
|
+ this.isSubmit = false;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
beforeDestroy() {
|
|
beforeDestroy() {
|
|
- this.$ls.remove("cardId");
|
|
|
|
- this.$ls.remove("prepareTcPCard");
|
|
|
|
this.initState();
|
|
this.initState();
|
|
- delete window.submitCardTemp;
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|