Commit 3936606f by linjinhong

feat:【工厂端&生产软件】模型多规格,支持用户在领标进行设计(数据适配)#1006970

parent 10f76288
...@@ -544,15 +544,15 @@ export default { ...@@ -544,15 +544,15 @@ export default {
productMark: this.detail.productMark productMark: this.detail.productMark
}; };
if ( if (this.detail.adjustable && this.detail.specList?.length) {
this.detail.mssWidth && obj.sizeObj = this.detail.specList.reduce((acc, el) => {
this.detail.adjustable == 1 && if (!el?.faceTitle) return acc;
this.detail.mssHeight acc[el.faceTitle] = {
) { width: el.mssWidth || 0, // 默认值防undefined
obj.size = { height: el.mssHeight || 0
width: this.detail.mssWidth,
height: this.detail.mssHeight
}; };
return acc;
}, {});
} }
//设置储存图片的字段,并添加power标识 //设置储存图片的字段,并添加power标识
if (!this.detail["saveImgList"]?.length) { if (!this.detail["saveImgList"]?.length) {
......
...@@ -336,7 +336,7 @@ export default { ...@@ -336,7 +336,7 @@ export default {
if (this.imgList?.length) { if (this.imgList?.length) {
this.getBackFile({ this.getBackFile({
files: this.imgList, files: this.imgList,
size: this.detail.designImageSize || null size: this.detail.sizeObj || null
}); });
} }
}, },
...@@ -511,13 +511,9 @@ export default { ...@@ -511,13 +511,9 @@ export default {
setDesignImg(title) { setDesignImg(title) {
let img = this.selectImgList.find(it => it.title === title); let img = this.selectImgList.find(it => it.title === title);
if (img) { if (img) {
// console.log(this.detail.designImageSize, "this.detail.size"); this.getBackFile({ files: [img], size: this.detail.sizeObj }, () => {
this.getBackFile(
{ files: [img], size: this.detail.designImageSize },
() => {
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
} });
);
} }
}, },
selectImg(it, index) { selectImg(it, index) {
...@@ -529,27 +525,35 @@ export default { ...@@ -529,27 +525,35 @@ export default {
let item = this.imgList.find(img => img.fileName === it.fileName); let item = this.imgList.find(img => img.fileName === it.fileName);
if (item) return; if (item) return;
this.selectImgIndex = index; this.selectImgIndex = index;
// console.log(this.detail.designImageSize); let sizeObj = null;
let size = null; // if (
if ( // this.detail.mssWidth &&
this.detail.mssWidth && // this.detail.adjustable &&
this.detail.adjustable && // this.detail.mssHeight
this.detail.mssHeight // ) {
) { // size = {
size = { // width: this.detail.mssWidth,
width: this.detail.mssWidth, // height: this.detail.mssHeight
height: this.detail.mssHeight // };
// }
if (this.detail.adjustable && this.detail.specList?.length) {
sizeObj = this.detail.specList.reduce((acc, el) => {
if (!el?.faceTitle) return acc;
acc[el.faceTitle] = {
width: el.mssWidth || 0, // 默认值防undefined
height: el.mssHeight || 0
}; };
return acc;
}, {});
} }
this.getBackFile({ files: [it], size }, () => { console.log("selectImg", it);
this.getBackFile({ files: [it], size: sizeObj }, () => {
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList))); this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
}); });
this.imgDom = document.getElementById("imgBox"); this.imgDom = document.getElementById("imgBox");
if (this.imgDom) this.imgDom.style.webkitClipPath = "none"; if (this.imgDom) this.imgDom.style.webkitClipPath = "none";
}); });
// setTimeout(() => {}, 300);
// this.selectImgIndexList = Array.from(new Set(this.selectImgIndexList))
// this.getBackFile({ files: [it], size });
}, },
ev(type) { ev(type) {
if (this.selectIndex < 0 && this.imgList.length) { if (this.selectIndex < 0 && this.imgList.length) {
...@@ -757,7 +761,12 @@ export default { ...@@ -757,7 +761,12 @@ export default {
bw = bw.clientWidth; bw = bw.clientWidth;
this.isView = false; this.isView = false;
this.isMove = false; this.isMove = false;
const keyMap = {
: "A",
: "B",
A: "A",
B: "B"
};
for (let i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
files[i].url = files[i]?.productionFile || files[i].url; files[i].url = files[i]?.productionFile || files[i].url;
await that.$nextTick(); await that.$nextTick();
...@@ -766,14 +775,20 @@ export default { ...@@ -766,14 +775,20 @@ export default {
let width_px, height_px, rate, x, y; let width_px, height_px, rate, x, y;
let data = await that.getImageSize(files[i].url); let data = await that.getImageSize(files[i].url);
const isCut = files[i].isCut; const isCut = files[i].isCut;
console.log("size", size);
console.log("files.title", files[i]);
const title = files[i].title;
const matchKey = keyMap[title] || title;
const templateSize = size[matchKey];
if (size && !isCut) { if (size && !isCut) {
//带黄点模判断是否是cp类,cp类按照newMmToPxFn方法重新计算宽高 //带黄点模判断是否是cp类,cp类按照newMmToPxFn方法重新计算宽高
if (isCp) { if (isCp) {
width_px = newMmToPxFn(size.width); width_px = newMmToPxFn(templateSize.width);
height_px = newMmToPxFn(size.height); height_px = newMmToPxFn(templateSize.height);
} else { } else {
width_px = mmToPx(size.width); width_px = mmToPx(templateSize.width);
height_px = mmToPx(size.height); height_px = mmToPx(templateSize.height);
} }
x = w; x = w;
y = height_px / 2; y = height_px / 2;
...@@ -817,6 +832,7 @@ export default { ...@@ -817,6 +832,7 @@ export default {
h: height_px, h: height_px,
r: 0 r: 0
}); });
console.log("imgList", that.imgList);
that.selectIndex = that.imgList.length - 1; that.selectIndex = that.imgList.length - 1;
that.showImgSetting = true; that.showImgSetting = true;
...@@ -826,21 +842,6 @@ export default { ...@@ -826,21 +842,6 @@ export default {
await this.$nextTick(); await this.$nextTick();
const { hasOutsideValidPixel } = await checkImageOutsideGrid(); const { hasOutsideValidPixel } = await checkImageOutsideGrid();
this.isOver = hasOutsideValidPixel; this.isOver = hasOutsideValidPixel;
// this.$nextTick(async () => {
// //等图片铺上网格后判断是否超过网格
// // if (isImageBiggerThanGrid && hasOutsideValidPixel) {
// // //图大于台版且超过台版有素材
// // this.isOver = hasOutsideValidPixel;
// // } else if (!isImageBiggerThanGrid) {
// // //图小于台版
// // this.isOver = isImageBiggerThanGrid;
// // } else if (isImageBiggerThanGrid && !hasOutsideValidPixel) {
// // //图大于台版且超过台版没有有素材
// // this.isOver = hasOutsideValidPixel;
// // }
// });
if (i === files.length - 1) { if (i === files.length - 1) {
callback && callback(); callback && callback();
} }
...@@ -1265,7 +1266,7 @@ export default { ...@@ -1265,7 +1266,7 @@ export default {
this.systemSetting = this.$dataStore.get("setting"); this.systemSetting = this.$dataStore.get("setting");
bus.$on("busEmit", v => { bus.$on("busEmit", v => {
let { type, value, size, productMark } = v; let { type, value, sizeObj, productMark } = v;
switch (type) { switch (type) {
case "completeMessage": case "completeMessage":
...@@ -1282,14 +1283,19 @@ export default { ...@@ -1282,14 +1283,19 @@ export default {
if ( if (
this.detail && this.detail &&
this.detail.mssWidth &&
this.detail.adjustable && this.detail.adjustable &&
this.detail.mssHeight this.detail.specList?.length
) { ) {
this.detail.designImageSize = { this.detail.sizeObj = this.detail.specList.reduce((acc, el) => {
width: this.detail.mssWidth, // 容错:跳过无效数据
height: this.detail.mssHeight if (!el?.faceTitle) return acc;
// 赋值:动态键名
acc[el.faceTitle] = {
width: el.mssWidth || 0, // 默认值防undefined
height: el.mssHeight || 0
}; };
return acc;
}, {});
} }
break; break;
...@@ -1311,7 +1317,8 @@ export default { ...@@ -1311,7 +1317,8 @@ export default {
}); });
break; break;
case "sendFile": case "sendFile":
this.detail.designImageSize = size; this.detail.sizeObj = sizeObj;
console.log("sizeObj", sizeObj);
this.imgList = []; this.imgList = [];
this.selectImgList = []; this.selectImgList = [];
...@@ -1336,7 +1343,7 @@ export default { ...@@ -1336,7 +1343,7 @@ export default {
this.getBackFile( this.getBackFile(
{ {
files: [value[this.selectImgIndex]], files: [value[this.selectImgIndex]],
size: this.detail.designImageSize || null size: this.detail.sizeObj || null
}, },
() => { () => {
this.imgHistoryList.push( this.imgHistoryList.push(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment