Commit 6df3273f by linjinhong

fix:修改下载素材

parent 56907510
......@@ -243,3 +243,8 @@ export function extractValue(str) {
if (str.includes("_A_")) return "A";
if (str.includes("_B_")) return "B";
}
export function mmToPxFn(mm) {
const px = (Number(mm) / 25.4) * 42;
return Number(px.toFixed(1));
}
......@@ -450,45 +450,45 @@ export default {
let imageResList = [];
//当adjustable有值时 直接赋值宽高
if (
!this.checked &&
this.detail.diyId &&
this.detail.adjustable &&
designImagesCanvasJsonList &&
this.desktopDevice !== 3
) {
designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList);
if (!designImagesCanvasJsonList[0].images) {
this.detail.isCustom = true;
let imageList = await this.canvasToImage(designImagesCanvasJsonList);
let fm = new FormData();
for (let img of imageList) {
let filename = uuid.v4().replace("-", "") + ".png";
fm.append("files", this.base64ToFile(img, filename));
}
// console.log("fm", fm);
let Sres = await this.$api.post("/saveToPng", fm);
Sres.data.forEach((item, i) => {
item.title = designImagesCanvasJsonList[i].options.title;
item.productionFile = item.url;
item.designId = item.designId || i.toString();
});
imageResList = Sres.data;
console.log("imageResList", imageResList);
} else {
// designImagesCanvasJsonList.forEach((el) => {
// el.images.forEach((item) => {
// imageResList.push({
// productionFile: item,
// title: el.title,
// });
// });
// });
// for (let item of imageResList) {
// item.productionFile = await this.saveImgByUrl(item.productionFile);
// }
}
}
// if (
// !this.checked &&
// this.detail.diyId &&
// this.detail.adjustable &&
// designImagesCanvasJsonList &&
// this.desktopDevice !== 3
// ) {
// designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList);
// if (!designImagesCanvasJsonList[0].images) {
// this.detail.isCustom = true;
// let imageList = await this.canvasToImage(designImagesCanvasJsonList);
// let fm = new FormData();
// for (let img of imageList) {
// let filename = uuid.v4().replace("-", "") + ".png";
// fm.append("files", this.base64ToFile(img, filename));
// }
// // console.log("fm", fm);
// let Sres = await this.$api.post("/saveToPng", fm);
// Sres.data.forEach((item, i) => {
// item.title = designImagesCanvasJsonList[i].options.title;
// item.productionFile = item.url;
// item.designId = item.designId || i.toString();
// });
// imageResList = Sres.data;
// console.log("imageResList", imageResList);
// } else {
// // designImagesCanvasJsonList.forEach((el) => {
// // el.images.forEach((item) => {
// // imageResList.push({
// // productionFile: item,
// // title: el.title,
// // });
// // });
// // });
// // for (let item of imageResList) {
// // item.productionFile = await this.saveImgByUrl(item.productionFile);
// // }
// }
// }
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
if (!imageResList.length && !bool) {
......
......@@ -81,6 +81,7 @@ export default {
unitToPx,
getCurrentItem(item) {
// let setting = this.$dataStore.get("setting");
console.log(84, item);
this.item.y = item.y - item.h / 2;
this.item.x = item.x - item.w / 2;
......
......@@ -4,7 +4,7 @@ const { ipcRenderer } = require("electron");
import ImgSetting from "./imgSetting.vue";
import bus from "@/bus";
import PrintDialog from "@/views/design/head/printDialog.vue";
import { mmToPx, extractValue } from "@/utils";
import { mmToPx, mmToPxFn, extractValue } from "@/utils";
const { checkImageOutsideGrid } = require("../../../server/utils/setImage");
const { pathMap } = require("@/config/index.js");
......@@ -539,7 +539,7 @@ export default {
// this.selectImgIndexList.push(i)
let item = this.imgList.find((img) => img.fileName === it.fileName);
if (item) return;
this.currentImgIndex = index;
this.selectImgIndex = index;
// console.log(this.detail.designImageSize);
let size = null;
if (
......@@ -614,7 +614,6 @@ export default {
case "x_center":
this.$set(this.imgList[this.selectIndex], "x", Number(w));
// this.$set(this.imgList[this.selectIndex], "y", 0);
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
break;
case "y_center":
......@@ -785,6 +784,7 @@ export default {
if (size && !files[i].isCut) {
console.log("size", size);
console.log("data", data);
if (this.newDesktopDevice == 3) {
const scale = bh / data.height;
width_px = data.width * scale;
......@@ -793,10 +793,10 @@ export default {
y = h;
rate = height_px / width_px;
} else {
width_px = mmToPx(size.width);
height_px = mmToPx(size.height);
width_px = mmToPxFn(size.width);
height_px = mmToPxFn(size.height);
x = w;
y = h;
y = height_px / 2;
rate = height_px / width_px;
}
} else {
......@@ -806,13 +806,11 @@ export default {
if (rate > 1) {
height_px = bh * (7.5 / 10);
// width_px = height_px / rate > bw ? bw : height_px / rate;
width_px = height_px / rate;
x = w;
y = height_px / 2;
} else {
width_px = bw * (2 / 3);
// height_px = width_px * rate > bh ? bh : width_px * rate;
height_px = width_px * rate;
x = width_px / 2;
y = height_px / 2;
......@@ -837,18 +835,15 @@ export default {
that.selectIndex = that.imgList.length - 1;
that.showImgSetting = true;
if (this.newDesktopDevice != 3) {
if (size && !files[i].isCut) {
console.log(7898, this.detail);
this.detail.isCustom ? that.ev("center") : that.ev("cover");
} else {
that.ev("x_center");
}
that.ev("x_center");
// if (size && !files[i].isCut) {
// console.log(7898, this.detail);
// this.detail.isCustom ? that.ev("center") : that.ev("cover");
// } else {
// that.ev("x_center");
// }
}
// setTimeout(() => {
// that.ev("center");
// }, 1000);
if (i === files.length - 1) {
callback && callback();
}
......@@ -1790,14 +1785,14 @@ export default {
></div>
</div>
</vue-drag-resize-rotate>
<div style="position: relative;">
<!-- <div style="position: relative;">
<button @click="checkOutsidePixel" class="detect-btn">
检测超出区域是否有像素
</button>
<div class="result" v-if="detectResult !== null">
检测结果:{{ detectResult ? "有" : "无" }}
</div>
</div>
</div> -->
<!-- 隐藏的Canvas(用于像素检测) -->
<canvas ref="pixelCanvas" style="display: none"></canvas>
......
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