Commit 6df3273f by linjinhong

fix:修改下载素材

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