|
@@ -31,6 +31,7 @@ import { examRuleDetail } from "../../base/api";
|
|
|
import { getEnums } from "../../login/api";
|
|
|
import { UNDERTAKING_BODY } from "../../../../card/enumerate";
|
|
|
import timeMixin from "@/mixins/timeMixin";
|
|
|
+import { MD5 } from "@/plugins/md5";
|
|
|
|
|
|
export default {
|
|
|
name: "card-edit",
|
|
@@ -57,6 +58,7 @@ export default {
|
|
|
cardPreviewUrl: "",
|
|
|
canSave: false,
|
|
|
dataReady: false,
|
|
|
+ lastStageCardContent: "",
|
|
|
// card-preview-dialog
|
|
|
viewType: "view",
|
|
|
cardData: null,
|
|
@@ -80,6 +82,7 @@ export default {
|
|
|
this.cardId = this.cardId || this.prepareTcPCard.id;
|
|
|
this.cardType = this.prepareTcPCard.type || "CUSTOM";
|
|
|
this.initCard();
|
|
|
+ this.openAutoSave();
|
|
|
},
|
|
|
methods: {
|
|
|
openAutoSave() {
|
|
@@ -123,9 +126,12 @@ export default {
|
|
|
async getCardTempDetail() {
|
|
|
const detData = await cardDetail(this.cardId);
|
|
|
// 可能存在题卡内容没有记录的情况
|
|
|
- if (detData.content) {
|
|
|
- this.cardContent = JSON.parse(detData.content);
|
|
|
+ if (detData.content || detData.stageContent) {
|
|
|
+ // TODO:
|
|
|
+ const content = detData.stageContent || detData.content;
|
|
|
+ this.cardContent = JSON.parse(content);
|
|
|
this.cardName = detData.title;
|
|
|
+ this.lastStageCardContent = content;
|
|
|
} else {
|
|
|
let cardConfig = await this.getCardConfig();
|
|
|
// 没有题卡内容时,直接创建新的内容
|
|
@@ -228,9 +234,13 @@ export default {
|
|
|
async toSave(datas) {
|
|
|
let cardInfo = this.getCardInfo(datas);
|
|
|
cardInfo.status = "STAGE";
|
|
|
+ if (MD5(cardInfo.content) === MD5(this.lastStageCardContent)) return;
|
|
|
+
|
|
|
const result = await saveCard(cardInfo, this.getRequestConfig()).catch(
|
|
|
() => {}
|
|
|
);
|
|
|
+ this.lastStageCardContent = cardInfo.content;
|
|
|
+ this.$refs.CardDesign.updateUnsubmitStatus(true);
|
|
|
if (!result) return;
|
|
|
this.cardId = result;
|
|
|
this.$ls.set("cardId", this.cardId);
|
|
@@ -279,6 +289,7 @@ export default {
|
|
|
this.cardName = "";
|
|
|
this.cardId = result;
|
|
|
this.$ls.set("cardId", this.cardId);
|
|
|
+ this.$refs.CardDesign.updateUnsubmitStatus(false);
|
|
|
this.$message.success("提交成功!");
|
|
|
this.goback();
|
|
|
} else {
|