|
@@ -92,6 +92,9 @@ const fields = computed(() => {
|
|
{ value: 200, label: "200" },
|
|
{ value: 200, label: "200" },
|
|
],
|
|
],
|
|
disabled: cardJson.value?.dpi,
|
|
disabled: cardJson.value?.dpi,
|
|
|
|
+ onChange: () => {
|
|
|
|
+ compareSize();
|
|
|
|
+ },
|
|
},
|
|
},
|
|
}
|
|
}
|
|
: null,
|
|
: null,
|
|
@@ -147,13 +150,29 @@ const rules = {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
],
|
|
|
|
+ dpi: [
|
|
|
|
+ {
|
|
|
|
+ validator: async () => {
|
|
|
|
+ if (!isJson) {
|
|
|
|
+ return Promise.reject("卡格式json文件内容异常,请检查");
|
|
|
|
+ } else {
|
|
|
|
+ if (cardJson.value && !cardSizePass.value) {
|
|
|
|
+ return Promise.reject("卡格式图片dpi异常!");
|
|
|
|
+ } else {
|
|
|
|
+ return Promise.resolve();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
};
|
|
};
|
|
let pageSizeStr = "";
|
|
let pageSizeStr = "";
|
|
-const compareSize = (content: any, img: any) => {
|
|
|
|
- let target = content[pageSizeStr];
|
|
|
|
- console.log(content, img.width, img.height);
|
|
|
|
- let w = img.width / params.dpi / 0.0394;
|
|
|
|
- let h = img.height / params.dpi / 0.0394;
|
|
|
|
|
|
+let contentRecord: any = null;
|
|
|
|
+let imgRecord: any = null;
|
|
|
|
+const compareSize = () => {
|
|
|
|
+ let target = contentRecord?.[pageSizeStr];
|
|
|
|
+ let w = imgRecord?.width / params.dpi / 0.0394;
|
|
|
|
+ let h = imgRecord?.height / params.dpi / 0.0394;
|
|
if (Math.abs(w - target.width) > 10 || Math.abs(h - target.height) > 10) {
|
|
if (Math.abs(w - target.width) > 10 || Math.abs(h - target.height) > 10) {
|
|
cardSizePass.value = false;
|
|
cardSizePass.value = false;
|
|
} else {
|
|
} else {
|
|
@@ -171,7 +190,9 @@ const validateCardSize = async (json: any) => {
|
|
const img = new Image();
|
|
const img = new Image();
|
|
img.onload = () => {
|
|
img.onload = () => {
|
|
pageSizeStr = json.pages[0].exchange["page_size"];
|
|
pageSizeStr = json.pages[0].exchange["page_size"];
|
|
- compareSize(content, img);
|
|
|
|
|
|
+ contentRecord = content;
|
|
|
|
+ imgRecord = img;
|
|
|
|
+ compareSize();
|
|
};
|
|
};
|
|
img.onerror = function () {
|
|
img.onerror = function () {
|
|
window.$message.error("卡格式json文件里的图片base64无效!");
|
|
window.$message.error("卡格式json文件里的图片base64无效!");
|