|
@@ -17,8 +17,7 @@
|
|
import CardView from "../../../../card/components/CardView";
|
|
import CardView from "../../../../card/components/CardView";
|
|
import CardFreeView from "../../../../card/modules/free/components/CardFreeView";
|
|
import CardFreeView from "../../../../card/modules/free/components/CardFreeView";
|
|
import { cardDetail } from "../api";
|
|
import { cardDetail } from "../api";
|
|
-import { deepCopy } from "@/plugins/utils";
|
|
|
|
-const JsBarcode = require("jsbarcode");
|
|
|
|
|
|
+import { deepCopy, getBase64Barcode } from "@/plugins/utils";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "card-preview",
|
|
name: "card-preview",
|
|
@@ -99,6 +98,13 @@ export default {
|
|
fieldInfos.paperTypeName = "${paperTypeName}";
|
|
fieldInfos.paperTypeName = "${paperTypeName}";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 保存题卡时,清除src,使用占位字符,以便后台使用变量填充
|
|
|
|
+ // 编辑预览题卡时,则使用给定内容
|
|
|
|
+ if (!cardConfig.courseCodeBarcodeSrc) {
|
|
|
|
+ cardConfig.courseCodeBarcodeSrc =
|
|
|
|
+ "data:image/png;base64,${courseCodeBarcodeSrc}";
|
|
|
|
+ cardConfig.courseCodeBarcodeName = "${courseCodeBarcodeName}";
|
|
|
|
+ }
|
|
|
|
|
|
this.cardConfig = cardConfig;
|
|
this.cardConfig = cardConfig;
|
|
this.pages = this.appendFieldInfo(pages, fieldInfos);
|
|
this.pages = this.appendFieldInfo(pages, fieldInfos);
|
|
@@ -145,6 +151,11 @@ export default {
|
|
const { cardConfig, pages } = JSON.parse(detData.content);
|
|
const { cardConfig, pages } = JSON.parse(detData.content);
|
|
const fieldInfos = this.fetchFieldInfos(cardConfig, {});
|
|
const fieldInfos = this.fetchFieldInfos(cardConfig, {});
|
|
|
|
|
|
|
|
+ if (detData.courseCode) {
|
|
|
|
+ cardConfig.courseCodeBarcodeSrc = getBase64Barcode(detData.courseCode);
|
|
|
|
+ cardConfig.courseCodeBarcodeName = detData.courseCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
this.cardConfig = cardConfig;
|
|
this.cardConfig = cardConfig;
|
|
this.pages = this.appendFieldInfo(pages, fieldInfos);
|
|
this.pages = this.appendFieldInfo(pages, fieldInfos);
|
|
},
|
|
},
|
|
@@ -173,13 +184,13 @@ export default {
|
|
});
|
|
});
|
|
if (this.cardCreateMethod === "STANDARD") {
|
|
if (this.cardCreateMethod === "STANDARD") {
|
|
if (isPrintExamNumber) {
|
|
if (isPrintExamNumber) {
|
|
- fieldInfos.examNumber = this.getBase64Barcode(
|
|
|
|
|
|
+ fieldInfos.examNumber = getBase64Barcode(
|
|
stdInfo["examNumber"] || defNumber
|
|
stdInfo["examNumber"] || defNumber
|
|
);
|
|
);
|
|
fieldInfos.examNumberStr = stdInfo["examNumber"] || defNumber;
|
|
fieldInfos.examNumberStr = stdInfo["examNumber"] || defNumber;
|
|
}
|
|
}
|
|
if (cardConfig.aOrB && cardConfig.paperType === "PRINT") {
|
|
if (cardConfig.aOrB && cardConfig.paperType === "PRINT") {
|
|
- fieldInfos.paperType = this.getBase64Barcode(
|
|
|
|
|
|
+ fieldInfos.paperType = getBase64Barcode(
|
|
stdInfo["paperType"] || defNumber
|
|
stdInfo["paperType"] || defNumber
|
|
);
|
|
);
|
|
fieldInfos.paperTypeName = stdInfo["paperTypeName"] || "A";
|
|
fieldInfos.paperTypeName = stdInfo["paperTypeName"] || "A";
|
|
@@ -188,20 +199,6 @@ export default {
|
|
|
|
|
|
return fieldInfos;
|
|
return fieldInfos;
|
|
},
|
|
},
|
|
- getBase64Barcode(str) {
|
|
|
|
- const canvas = document.createElement("CANVAS");
|
|
|
|
- JsBarcode(canvas, str, {
|
|
|
|
- width: 2,
|
|
|
|
- height: 30,
|
|
|
|
- displayValue: false,
|
|
|
|
- marginLeft: 20,
|
|
|
|
- marginRight: 20,
|
|
|
|
- marginTop: 0,
|
|
|
|
- marginBottom: 0,
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- return canvas.toDataURL();
|
|
|
|
- },
|
|
|
|
appendFieldInfo(pages, fieldInfos) {
|
|
appendFieldInfo(pages, fieldInfos) {
|
|
if (this.cardCreateMethod === "STANDARD") {
|
|
if (this.cardCreateMethod === "STANDARD") {
|
|
pages.forEach((page, pageNo) => {
|
|
pages.forEach((page, pageNo) => {
|