|
@@ -2,7 +2,7 @@
|
|
|
<div class="card-design">
|
|
|
<div class="design-top">
|
|
|
<div class="design-top-logo">
|
|
|
- <h1>答题卡制作</h1>
|
|
|
+ <h1><i class="icon icon-back" @click="toExit"></i>答题卡制作</h1>
|
|
|
</div>
|
|
|
<!-- <div class="design-top-info">
|
|
|
<div class="info-help"><i class="icon icon-help"></i>帮助</div>
|
|
@@ -245,13 +245,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { mapState, mapMutations, mapActions } from "vuex";
|
|
|
-import {
|
|
|
- cardConfigInfos,
|
|
|
- cardDetailEdit,
|
|
|
- cardTempDetail,
|
|
|
- saveCard,
|
|
|
- submitCard
|
|
|
-} from "../api";
|
|
|
+import { cardConfigInfos, cardDetail, saveCard } from "../api";
|
|
|
import {
|
|
|
getElementModel,
|
|
|
getCardHeadModel,
|
|
@@ -287,8 +281,14 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
cardId: this.$route.params.cardId || this.$ls.get("cardId"),
|
|
|
- cardDetailId: this.$ls.get("cardDetailId"),
|
|
|
- prepareTcPCard: this.$ls.get("prepareTcPCard", {}),
|
|
|
+ prepareTcPCard: this.$ls.get("prepareTcPCard", {
|
|
|
+ examTaskId: "",
|
|
|
+ courseCode: "",
|
|
|
+ courseName: "",
|
|
|
+ makeMethod: "SELF",
|
|
|
+ cardRuleId: "",
|
|
|
+ paperType: ""
|
|
|
+ }),
|
|
|
ELEMENT_LIST,
|
|
|
TOPIC_LIST,
|
|
|
topicList: [],
|
|
@@ -320,7 +320,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- if (!this.prepareTcPCard.examTaskId) {
|
|
|
+ if (!this.prepareTcPCard.examTaskId && !this.isEdit) {
|
|
|
this.$message.error("找不到命题任务,请退出题卡制作!");
|
|
|
return;
|
|
|
}
|
|
@@ -350,24 +350,21 @@ export default {
|
|
|
"initTopicsFromPages"
|
|
|
]),
|
|
|
async initCard() {
|
|
|
- await this.getCardConfig();
|
|
|
if (this.isEdit) {
|
|
|
- this.getCardTempDetail();
|
|
|
+ await this.getCardTempDetail();
|
|
|
} else {
|
|
|
+ await this.getCardConfig();
|
|
|
this.initPageData();
|
|
|
}
|
|
|
this.addWatch();
|
|
|
},
|
|
|
async getCardTempDetail() {
|
|
|
- const detData = await cardDetailEdit(this.cardId);
|
|
|
- const tempData = await cardTempDetail(this.cardId);
|
|
|
+ const detData = await cardDetail(this.cardId);
|
|
|
// this.canSave = !detData.operateStatus;
|
|
|
- // this.prepareTcPCard = Object.assign(this.prepareTcPCard, detData);
|
|
|
|
|
|
// 可能存在题卡内容没有记录的情况
|
|
|
- if (tempData) {
|
|
|
- const cont = JSON.parse(tempData.content);
|
|
|
- this.cardDetailId = tempData.id;
|
|
|
+ if (detData.content) {
|
|
|
+ const cont = JSON.parse(detData.content);
|
|
|
this.setPages(cont.pages);
|
|
|
this.setCardConfig(cont.cardConfig);
|
|
|
this.setPaperParams(cont.paperParams);
|
|
@@ -375,11 +372,11 @@ export default {
|
|
|
this.resetTopicSeries();
|
|
|
this.setCurPage(0);
|
|
|
} else {
|
|
|
+ await this.getCardConfig();
|
|
|
// 没有题卡内容时,直接创建新的内容
|
|
|
- this.setCardConfig({
|
|
|
- cardName: detData.title,
|
|
|
- aOrB: detData.enablePaperType.split(",").length > 1
|
|
|
- });
|
|
|
+ let mod = { aOrB: detData.paperType.split(",").length > 1 };
|
|
|
+ if (detData.makeMethod === "CUST") mod.cardTitle = detData.title;
|
|
|
+ this.setCardConfig(mod);
|
|
|
this.initPageData();
|
|
|
}
|
|
|
},
|
|
@@ -405,12 +402,15 @@ export default {
|
|
|
columnNumber: 2,
|
|
|
columnGap: 20,
|
|
|
showForbidArea: true,
|
|
|
- cardName: ""
|
|
|
+ cardDesc: ""
|
|
|
}
|
|
|
};
|
|
|
config.aOrB = this.prepareTcPCard["paperType"]
|
|
|
? this.prepareTcPCard.paperType.split(",").length > 1
|
|
|
- : null;
|
|
|
+ : false;
|
|
|
+ config.requiredFields = JSON.parse(config.requiredFields);
|
|
|
+ config.extendFields = JSON.parse(config.extendFields);
|
|
|
+ config.cardTitle = config.titleRule;
|
|
|
this.setCardConfig(config);
|
|
|
},
|
|
|
addNewTopic(item) {
|
|
@@ -477,47 +477,15 @@ export default {
|
|
|
this.setPaperParams(paperParams);
|
|
|
},
|
|
|
// save
|
|
|
- getCardData(contentTemp = "", model = "") {
|
|
|
- const multiEnablePaperType =
|
|
|
- this.prepareTcPCard["paperType"] &&
|
|
|
- this.prepareTcPCard["paperType"].split(",").length > 1
|
|
|
- ? this.prepareTcPCard["paperType"]
|
|
|
- : "";
|
|
|
- const tcPCard = this.$objAssign(
|
|
|
- {
|
|
|
- examId: "",
|
|
|
- enablePaperType: "A",
|
|
|
- courseName: "",
|
|
|
- courseCode: "",
|
|
|
- cardSource: "",
|
|
|
- title: "",
|
|
|
- id: this.cardId
|
|
|
- },
|
|
|
- {
|
|
|
- ...this.prepareTcPCard,
|
|
|
- title: this.cardConfig.cardName,
|
|
|
- enablePaperType: this.cardConfig.aOrB
|
|
|
- ? multiEnablePaperType || "A,B"
|
|
|
- : "A"
|
|
|
- }
|
|
|
- );
|
|
|
-
|
|
|
+ getCardData(htmlContent = "", model = "") {
|
|
|
let data = {
|
|
|
- tcPCard,
|
|
|
- tcPCardDetail: {
|
|
|
- content: model,
|
|
|
- subjectiveAttachmentId:
|
|
|
- this.paperParams["subjectiveAttachmentId"] || "",
|
|
|
- contentTemp
|
|
|
- }
|
|
|
+ title: this.cardConfig.cardTitle,
|
|
|
+ content: model,
|
|
|
+ htmlContent,
|
|
|
+ type: "CUSTOM",
|
|
|
+ ...this.prepareTcPCard
|
|
|
};
|
|
|
- if (this.cardDetailId) data.tcPCardDetail.id = this.cardDetailId;
|
|
|
-
|
|
|
- if (this.prepareTcPCard.taskId && this.prepareTcPCard.cardSource === "1")
|
|
|
- data.tcPExamTaskDetail = {
|
|
|
- ...this.prepareTcPCard,
|
|
|
- cardId: this.cardId
|
|
|
- };
|
|
|
+ if (this.cardId) data.id = this.cardId;
|
|
|
return data;
|
|
|
},
|
|
|
checkElementCovered() {
|
|
@@ -534,19 +502,19 @@ export default {
|
|
|
return elements.length;
|
|
|
},
|
|
|
checkCardValid() {
|
|
|
- if (!this.cardConfig.schoolName) {
|
|
|
- this.$message.error("主标题不能为空!");
|
|
|
+ if (!this.cardConfig.cardTitle) {
|
|
|
+ this.$message.error("题卡标题不能为空!");
|
|
|
this.setCurPageNo(0);
|
|
|
setTimeout(() => {
|
|
|
document.getElementById("cardTitleInput").focus();
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
- if (!this.cardConfig.cardName) {
|
|
|
- this.$message.error("题卡标题不能为空!");
|
|
|
+ if (!this.cardConfig.cardDesc) {
|
|
|
+ this.$message.error("题卡描述信息不能为空!");
|
|
|
this.setCurPage(0);
|
|
|
setTimeout(() => {
|
|
|
- document.getElementById("cardNameInput").focus();
|
|
|
+ document.getElementById("cardDescInput").focus();
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
@@ -570,11 +538,10 @@ export default {
|
|
|
},
|
|
|
async save() {
|
|
|
if (!this.checkCardValid()) return;
|
|
|
-
|
|
|
- const result = await saveCard(this.getCardData("", this.getModel()));
|
|
|
- this.cardDetailId = result.cardDetailId;
|
|
|
- this.cardId = result.cardId;
|
|
|
- this.$ls.set("cardDetailId", this.cardDetailId);
|
|
|
+ let datas = this.getCardData("", this.getModel());
|
|
|
+ datas.status = "STAGE";
|
|
|
+ const result = await saveCard(datas);
|
|
|
+ this.cardId = result;
|
|
|
this.$ls.set("cardId", this.cardId);
|
|
|
return true;
|
|
|
},
|
|
@@ -582,13 +549,6 @@ export default {
|
|
|
const result = await this.save();
|
|
|
if (result) this.$message.success("保存成功!");
|
|
|
},
|
|
|
- // toSave() {
|
|
|
- // // console.log(this.getCardData());
|
|
|
- // this.canSave = true;
|
|
|
- // setTimeout(() => {
|
|
|
- // this.canSave = false;
|
|
|
- // }, 500);
|
|
|
- // },
|
|
|
toSubmit() {
|
|
|
if (this.isSubmit) return;
|
|
|
|
|
@@ -606,25 +566,30 @@ export default {
|
|
|
paperParams: this.paperParams
|
|
|
};
|
|
|
this.isSubmit = true;
|
|
|
- this.cardPreviewUrl = `/#/card/preview/${this.cardId}/frame`;
|
|
|
+ const { href } = this.$router.resolve({
|
|
|
+ name: "CardPreview",
|
|
|
+ params: {
|
|
|
+ cardId: 1,
|
|
|
+ viewType: "frame"
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.cardPreviewUrl = href;
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
},
|
|
|
registWindowSubmit() {
|
|
|
- window.submitCardTemp = async (cardContentTemp, model) => {
|
|
|
- const data = this.getCardData(cardContentTemp, model);
|
|
|
- const result = await submitCard(data).catch(() => {});
|
|
|
+ window.submitCardTemp = async (htmlContent, model) => {
|
|
|
+ const datas = this.getCardData(htmlContent, model);
|
|
|
+ datas.status = "SUBMIT";
|
|
|
+ const result = await saveCard(datas).catch(() => {});
|
|
|
this.cardPreviewUrl = "";
|
|
|
this.isSubmit = false;
|
|
|
window.cardData = null;
|
|
|
if (result) {
|
|
|
- this.cardDetailId = result.cardDetailId;
|
|
|
- this.cardId = result.cardId;
|
|
|
- this.$ls.set("cardDetailId", this.cardDetailId);
|
|
|
+ this.cardId = result;
|
|
|
this.$ls.set("cardId", this.cardId);
|
|
|
this.canSave = false;
|
|
|
this.$message.success("提交成功!");
|
|
|
- // 提交之后退出编辑,v1.1修改
|
|
|
this.goback();
|
|
|
} else {
|
|
|
this.$message.error("提交失败,请重新尝试!");
|
|
@@ -649,7 +614,6 @@ export default {
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
this.$ls.remove("cardId");
|
|
|
- this.$ls.remove("cardDetailId");
|
|
|
this.$ls.remove("prepareTcPCard");
|
|
|
this.initState();
|
|
|
delete window.submitCardTemp;
|