|
@@ -12,27 +12,13 @@
|
|
@on-exit="toExit"
|
|
@on-exit="toExit"
|
|
></component>
|
|
></component>
|
|
|
|
|
|
- <!-- card-view-frame -->
|
|
|
|
- <div class="design-preview-frame" v-if="cardPreviewUrl">
|
|
|
|
- <iframe :src="cardPreviewUrl" frameborder="0"></iframe>
|
|
|
|
- </div>
|
|
|
|
- <!-- card-view-dialog -->
|
|
|
|
- <el-dialog
|
|
|
|
- class="card-view-dialog"
|
|
|
|
- :visible.sync="dialogIsShow"
|
|
|
|
- :close-on-click-modal="false"
|
|
|
|
- :close-on-press-escape="false"
|
|
|
|
- append-to-body
|
|
|
|
- fullscreen
|
|
|
|
- @closed="dialogClosed"
|
|
|
|
- >
|
|
|
|
- <iframe
|
|
|
|
- v-if="dialogIsShow && cardDialogPreviewUrl"
|
|
|
|
- :src="cardDialogPreviewUrl"
|
|
|
|
- frameborder="0"
|
|
|
|
- :style="dialogFrameStyle"
|
|
|
|
- ></iframe>
|
|
|
|
- </el-dialog>
|
|
|
|
|
|
+ <!-- card-preview-dialog -->
|
|
|
|
+ <card-preview-dialog
|
|
|
|
+ ref="CardPreviewDialog"
|
|
|
|
+ :cardData="cardData"
|
|
|
|
+ :view-type="viewType"
|
|
|
|
+ @confirm="previewConfirm"
|
|
|
|
+ ></card-preview-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -40,6 +26,7 @@
|
|
import { cardConfigInfos, cardDetail, saveCard } from "../api";
|
|
import { cardConfigInfos, cardDetail, saveCard } from "../api";
|
|
import CardDesign from "../../../../card/components/CardDesign";
|
|
import CardDesign from "../../../../card/components/CardDesign";
|
|
import CardFreeDesign from "../../../../card/modules/free/components/CardFreeDesign";
|
|
import CardFreeDesign from "../../../../card/modules/free/components/CardFreeDesign";
|
|
|
|
+import CardPreviewDialog from "../components/CardPreviewDialog.vue";
|
|
import { examRuleDetail } from "../../base/api";
|
|
import { examRuleDetail } from "../../base/api";
|
|
import { getEnums } from "../../login/api";
|
|
import { getEnums } from "../../login/api";
|
|
|
|
|
|
@@ -48,6 +35,7 @@ export default {
|
|
components: {
|
|
components: {
|
|
CardDesign,
|
|
CardDesign,
|
|
CardFreeDesign,
|
|
CardFreeDesign,
|
|
|
|
+ CardPreviewDialog,
|
|
},
|
|
},
|
|
props: {
|
|
props: {
|
|
isDialog: {
|
|
isDialog: {
|
|
@@ -66,10 +54,9 @@ export default {
|
|
cardPreviewUrl: "",
|
|
cardPreviewUrl: "",
|
|
canSave: false,
|
|
canSave: false,
|
|
dataReady: false,
|
|
dataReady: false,
|
|
- // card-view-dialog
|
|
|
|
- dialogIsShow: false,
|
|
|
|
- cardDialogPreviewUrl: "",
|
|
|
|
- dialogFrameStyle: {},
|
|
|
|
|
|
+ // card-preview-dialog
|
|
|
|
+ viewType: "view",
|
|
|
|
+ cardData: null,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -89,19 +76,7 @@ export default {
|
|
this.cardCreateMethod = this.prepareTcPCard.createMethod || "STANDARD";
|
|
this.cardCreateMethod = this.prepareTcPCard.createMethod || "STANDARD";
|
|
this.cardId = this.cardId || this.prepareTcPCard.id;
|
|
this.cardId = this.cardId || this.prepareTcPCard.id;
|
|
this.cardType = this.prepareTcPCard.type || "CUSTOM";
|
|
this.cardType = this.prepareTcPCard.type || "CUSTOM";
|
|
- // if (
|
|
|
|
- // !this.prepareTcPCard.examTaskId &&
|
|
|
|
- // !this.isEdit &&
|
|
|
|
- // this.cardType === "CUSTOM"
|
|
|
|
- // ) {
|
|
|
|
- // this.$message.error("找不到命题任务,请退出题卡制作!");
|
|
|
|
- // return;
|
|
|
|
- // }
|
|
|
|
this.initCard();
|
|
this.initCard();
|
|
- this.registWindowSubmit();
|
|
|
|
- // card-view
|
|
|
|
- this.initFrameStyle();
|
|
|
|
- window.addEventListener("resize", this.initFrameStyle);
|
|
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
initFrameStyle() {
|
|
initFrameStyle() {
|
|
@@ -239,58 +214,24 @@ export default {
|
|
this.cardDialogPreviewUrl = "";
|
|
this.cardDialogPreviewUrl = "";
|
|
},
|
|
},
|
|
toPreview(cardData) {
|
|
toPreview(cardData) {
|
|
- window.cardData = {
|
|
|
|
|
|
+ this.cardData = {
|
|
...cardData,
|
|
...cardData,
|
|
createMethod: this.cardCreateMethod,
|
|
createMethod: this.cardCreateMethod,
|
|
type: this.cardType,
|
|
type: this.cardType,
|
|
};
|
|
};
|
|
- const { href } = this.$router.resolve({
|
|
|
|
- name: "CardPreview",
|
|
|
|
- params: {
|
|
|
|
- cardId: 1,
|
|
|
|
- viewType: "frame-view",
|
|
|
|
- },
|
|
|
|
- query: {
|
|
|
|
- t: Date.now(),
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- this.cardDialogPreviewUrl = href;
|
|
|
|
- this.dialogIsShow = true;
|
|
|
|
|
|
+ this.viewType = "view";
|
|
|
|
+ this.$refs.CardPreviewDialog.open();
|
|
},
|
|
},
|
|
// save
|
|
// save
|
|
async toSave(datas) {
|
|
async toSave(datas) {
|
|
- if (!this.cardName) {
|
|
|
|
- const res = await this.$prompt("请输入题卡名称", "提示", {
|
|
|
|
- type: "warning",
|
|
|
|
- showInput: true,
|
|
|
|
- inputPlaceholder: "请输入题卡名称",
|
|
|
|
- inputValue: this.cardName,
|
|
|
|
- inputValidator: (val) => {
|
|
|
|
- if (!val) return "请输入题卡名称!";
|
|
|
|
- if (val.length > 50) return "题卡名称不得超过50个字符!";
|
|
|
|
- return true;
|
|
|
|
- },
|
|
|
|
- }).catch(() => {});
|
|
|
|
- if (!res || res.action !== "confirm") {
|
|
|
|
- this.$refs.CardDesign.unloading();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this.cardName = res.value;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
let cardInfo = this.getCardInfo(datas);
|
|
let cardInfo = this.getCardInfo(datas);
|
|
cardInfo.status = "STAGE";
|
|
cardInfo.status = "STAGE";
|
|
const result = await saveCard(cardInfo, this.getRequestConfig()).catch(
|
|
const result = await saveCard(cardInfo, this.getRequestConfig()).catch(
|
|
() => {}
|
|
() => {}
|
|
);
|
|
);
|
|
-
|
|
|
|
- this.$refs.CardDesign.unloading();
|
|
|
|
if (!result) return;
|
|
if (!result) return;
|
|
-
|
|
|
|
this.cardId = result;
|
|
this.cardId = result;
|
|
this.$ls.set("cardId", this.cardId);
|
|
this.$ls.set("cardId", this.cardId);
|
|
- this.$message.success("保存成功!");
|
|
|
|
- return this.cardId;
|
|
|
|
},
|
|
},
|
|
async toSubmit(cardData) {
|
|
async toSubmit(cardData) {
|
|
const res = await this.$prompt("确定要提交当前题卡吗?", "提示", {
|
|
const res = await this.$prompt("确定要提交当前题卡吗?", "提示", {
|
|
@@ -308,52 +249,39 @@ export default {
|
|
this.cardName = res.value;
|
|
this.cardName = res.value;
|
|
|
|
|
|
this.$refs.CardDesign.loading();
|
|
this.$refs.CardDesign.loading();
|
|
- window.cardData = {
|
|
|
|
|
|
+ this.cardData = {
|
|
...cardData,
|
|
...cardData,
|
|
createMethod: this.cardCreateMethod,
|
|
createMethod: this.cardCreateMethod,
|
|
type: this.cardType,
|
|
type: this.cardType,
|
|
};
|
|
};
|
|
- const { href } = this.$router.resolve({
|
|
|
|
- name: "CardPreview",
|
|
|
|
- params: {
|
|
|
|
- cardId: 1,
|
|
|
|
- viewType: "frame",
|
|
|
|
- },
|
|
|
|
- query: {
|
|
|
|
- t: Date.now(),
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- this.cardPreviewUrl = href;
|
|
|
|
|
|
+ this.viewType = "print";
|
|
|
|
+ this.$refs.CardPreviewDialog.open();
|
|
},
|
|
},
|
|
- registWindowSubmit() {
|
|
|
|
- window.submitCardTemp = async (htmlContent, model) => {
|
|
|
|
- if (!htmlContent || !model) {
|
|
|
|
- this.$refs.CardDesign.unloading();
|
|
|
|
- window.cardData = null;
|
|
|
|
- this.cardPreviewUrl = "";
|
|
|
|
- this.$message.error("提交失败,请重新尝试!");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this.cardPreviewUrl = "";
|
|
|
|
- const datas = this.$refs.CardDesign.getCardData(htmlContent, model);
|
|
|
|
- const cardInfo = this.getCardInfo(datas);
|
|
|
|
- cardInfo.status = "SUBMIT";
|
|
|
|
- const result = await saveCard(cardInfo, this.getRequestConfig()).catch(
|
|
|
|
- () => {}
|
|
|
|
- );
|
|
|
|
|
|
+ async previewConfirm(content) {
|
|
|
|
+ if (!content) {
|
|
this.$refs.CardDesign.unloading();
|
|
this.$refs.CardDesign.unloading();
|
|
- window.cardData = null;
|
|
|
|
- if (result) {
|
|
|
|
- this.cardName = "";
|
|
|
|
- this.cardId = result;
|
|
|
|
- this.$ls.set("cardId", this.cardId);
|
|
|
|
- this.canSave = false;
|
|
|
|
- this.$message.success("提交成功!");
|
|
|
|
- this.goback();
|
|
|
|
- } else {
|
|
|
|
- this.$message.error("提交失败,请重新尝试!");
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ this.cardData = null;
|
|
|
|
+ this.$message.error("错误:预览,提交失败,请重新尝试!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const { htmlContent, model } = content;
|
|
|
|
+ const datas = this.$refs.CardDesign.getCardData(htmlContent, model);
|
|
|
|
+ const cardInfo = this.getCardInfo(datas);
|
|
|
|
+ cardInfo.status = "SUBMIT";
|
|
|
|
+
|
|
|
|
+ const result = await saveCard(cardInfo, this.getRequestConfig()).catch(
|
|
|
|
+ () => {}
|
|
|
|
+ );
|
|
|
|
+ this.$refs.CardDesign.unloading();
|
|
|
|
+ if (result) {
|
|
|
|
+ this.cardName = "";
|
|
|
|
+ this.cardId = result;
|
|
|
|
+ this.$ls.set("cardId", this.cardId);
|
|
|
|
+ this.$message.success("提交成功!");
|
|
|
|
+ this.goback();
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error("提交失败,请重新尝试!");
|
|
|
|
+ }
|
|
},
|
|
},
|
|
toExit() {
|
|
toExit() {
|
|
this.$confirm(
|
|
this.$confirm(
|
|
@@ -379,8 +307,6 @@ export default {
|
|
beforeDestroy() {
|
|
beforeDestroy() {
|
|
this.$ls.remove("cardId");
|
|
this.$ls.remove("cardId");
|
|
this.$ls.remove("prepareTcPCard");
|
|
this.$ls.remove("prepareTcPCard");
|
|
- window.removeEventListener("resize", this.initFrameStyle);
|
|
|
|
- delete window.submitCardTemp;
|
|
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|