|
@@ -4,6 +4,7 @@
|
|
|
v-if="dataReady"
|
|
|
ref="CardDesign"
|
|
|
:content="cardContent"
|
|
|
+ :paper-json="paperJson"
|
|
|
@on-preview="toPreview"
|
|
|
@on-save="toSave"
|
|
|
@on-submit="toSubmit"
|
|
@@ -18,8 +19,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { cardConfigInfos, cardDetail, saveCard } from "../api";
|
|
|
+import { cardConfigInfos, cardDetail, saveCard, paperDetailApi } from "../api";
|
|
|
import CardDesign from "../components/CardDesign";
|
|
|
+import { getPaperJsonSimpleStructInfo } from "../autoBuild/paperStruct";
|
|
|
|
|
|
export default {
|
|
|
name: "CardEdit",
|
|
@@ -29,7 +31,8 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
cardId: this.$route.params.cardId,
|
|
|
- prepareTcPCard: { paperId: "" },
|
|
|
+ paperId: this.$route.params.paperId,
|
|
|
+ paperJson: null,
|
|
|
cardContent: {},
|
|
|
cardPreviewUrl: "",
|
|
|
canSave: false,
|
|
@@ -46,21 +49,18 @@ export default {
|
|
|
this.registWindowSubmit();
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
- // this.$ls.remove("cardId");
|
|
|
- // this.$ls.remove("prepareTcPCard");
|
|
|
delete window.submitCardTemp;
|
|
|
},
|
|
|
methods: {
|
|
|
async initCard() {
|
|
|
this.dataReady = false;
|
|
|
+ const paperRes = await paperDetailApi(this.paperId);
|
|
|
+ this.paperJson = paperRes.data;
|
|
|
+
|
|
|
if (this.isEdit) {
|
|
|
await this.getCardTempDetail();
|
|
|
} else {
|
|
|
- const cardConfig = await this.getCardConfig();
|
|
|
- this.cardContent = {
|
|
|
- pages: [],
|
|
|
- cardConfig,
|
|
|
- };
|
|
|
+ await this.initCardContent();
|
|
|
}
|
|
|
this.dataReady = true;
|
|
|
},
|
|
@@ -69,14 +69,30 @@ export default {
|
|
|
// 可能存在题卡内容没有记录的情况
|
|
|
if (detData.content) {
|
|
|
this.cardContent = JSON.parse(detData.content);
|
|
|
+ const curPaperSimpleStruct = getPaperJsonSimpleStructInfo(
|
|
|
+ this.paperJson
|
|
|
+ );
|
|
|
+ if (curPaperSimpleStruct !== this.cardContent.paperSimpleStruct) {
|
|
|
+ this.$message.info("试卷结构有变化,将重新生成题卡");
|
|
|
+ this.cardContent = {
|
|
|
+ pages: [],
|
|
|
+ cardConfig: detData.cardConfig,
|
|
|
+ paperSimpleStruct: getPaperJsonSimpleStructInfo(this.paperJson),
|
|
|
+ };
|
|
|
+ }
|
|
|
} else {
|
|
|
- let cardConfig = await this.getCardConfig();
|
|
|
- this.cardContent = {
|
|
|
- pages: [],
|
|
|
- cardConfig,
|
|
|
- };
|
|
|
+ this.$message.info("无题卡内容,将重新生成题卡");
|
|
|
+ await this.initCardContent();
|
|
|
}
|
|
|
},
|
|
|
+ async initCardContent() {
|
|
|
+ const cardConfig = await this.getCardConfig();
|
|
|
+ this.cardContent = {
|
|
|
+ pages: [],
|
|
|
+ cardConfig,
|
|
|
+ paperSimpleStruct: getPaperJsonSimpleStructInfo(this.paperJson),
|
|
|
+ };
|
|
|
+ },
|
|
|
async getCardConfig() {
|
|
|
const data = await cardConfigInfos();
|
|
|
if (!data) {
|
|
@@ -100,8 +116,7 @@ export default {
|
|
|
let data = this.$refs.CardDesign.getCardData(htmlContent, model);
|
|
|
data = {
|
|
|
...data,
|
|
|
- type: "CUSTOM",
|
|
|
- ...this.prepareTcPCard,
|
|
|
+ paperId: this.paperId,
|
|
|
};
|
|
|
if (this.cardId) data.id = this.cardId;
|
|
|
return data;
|