Commit 5c58f588 by zhuzhequan

扫码逻辑代码整理

parent 4e672b59
...@@ -297,41 +297,20 @@ export default { ...@@ -297,41 +297,20 @@ export default {
let res = await this.$api.post("/downloadByDesignId", params); let res = await this.$api.post("/downloadByDesignId", params);
this.$message.success(res.msg); this.$message.success(res.msg);
}, },
async getDataInfo() { async hasDesignImagesCanvasJsonList(designImagesCanvasJsonList){
if ( let imageResList = []
this.detail && if (this.detail.adjustable && designImagesCanvasJsonList) {
Object.keys(this.detail).length > 0 &&
this.isAutoFinish
) {
await this.setData(this.detail);
}
if (this.productionNo === "")
return this.$message.warning("请录入生产单号");
if (!this.isAutoFinish && !this.isFirst)
this.$confirm("请注意自动完成上一单未勾选", "提示", {
confirmButtonText: "确定",
type: "warning"
});
try {
//查找生产单号信息传给第二个显示器
const findByPodProductionNo = await this.$api.post(
"/findByPodProductionNo",
{
thirdSubOrderNumber: this.productionNo,
type: this.factoryType
}
);
this.detail = findByPodProductionNo.data;
// console.log("detail111111", findByPodProductionNo);
let imageResList = [];
this.imgList = [];
let designImagesCanvasJsonList = this.detail.drParam
if (designImagesCanvasJsonList) {
designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList); designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList);
if (this.detail.adjustable) { if(designImagesCanvasJsonList[0].images){
designImagesCanvasJsonList.forEach((el) => {
el.images.forEach((item) => {
imageResList.push({
productionFile: item,
title: el.title
});
});
});
}else{
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) {
...@@ -345,49 +324,9 @@ export default { ...@@ -345,49 +324,9 @@ export default {
item.productionFile = item.url; item.productionFile = item.url;
}); });
imageResList = Sres.data; imageResList = Sres.data;
this.imgList = [];
if (this.checked) {
imageResList = await this.cutImgFn(imageResList);
imageResList.forEach((el) => {
el.isCut = true;
});
} }
} else {
this.imgList = [];
designImagesCanvasJsonList.forEach((el) => {
el.images.forEach((item) => {
this.imgList.push({
productionFile: item,
title: el.title
});
});
});
}
}
this.$store.commit("setProductDetail", findByPodProductionNo.data);
ipcRenderer.send("win-subScreen", findByPodProductionNo.data);
if (imageResList && imageResList.length) {
let obj = {
type: "sendFile",
value: imageResList.map((el, index) => {
el.designId = el.designId || index;
return el;
})
};
if (
this.detail.mssWidth &&
this.detail.adjustable &&
this.detail.mssHeight
) {
obj.size = {
width: this.detail.mssWidth,
height: this.detail.mssHeight
};
} }
bus.$emit("busEmit", obj); if(!imageResList.length){
} else {
if(!this.imgList.length){
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示 // 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
let res = await this.$api.post("/downloadBySubOrderNumber", { let res = await this.$api.post("/downloadBySubOrderNumber", {
ids: [this.detail.id], ids: [this.detail.id],
...@@ -396,28 +335,22 @@ export default { ...@@ -396,28 +335,22 @@ export default {
}); });
if (res.data.length === 0) if (res.data.length === 0)
return this.$message.warning("未找到素材图!"); return this.$message.warning("未找到素材图!");
this.imgList = [];
res.data.forEach((el) => { res.data.forEach((el) => {
this.imgList = this.imgList.concat(el.list || []); imageResList = imageResList.concat(el.list || []);
}); });
} }
// res.data = arr.filter((el) => el.type !== 1);
let newImgList;
if(this.imgList.length)
if (this.checked) { if (this.checked) {
newImgList = await this.cutImgFn(this.imgList); imageResList = await this.cutImgFn(imageResList);
newImgList.forEach((el) => { imageResList.forEach((el) => {
el.isCut = true; el.isCut = true;
}); });
} else {
newImgList = this.imgList;
} }
// 延迟后强制激活窗口 // 延迟后强制激活窗口
if (this.desktopDevice !== 1) { if (this.desktopDevice !== 1) {
if (this.imgList.length) { if (imageResList.length) {
let pathUrl = this.imgList[0].productionFile; let pathUrl = imageResList[0].productionFile;
setTimeout(async () => { setTimeout(async () => {
// await this.focusExplorerWindow(pathUrl); // await this.focusExplorerWindow(pathUrl);
const pathParts = pathUrl.split("\\"); const pathParts = pathUrl.split("\\");
...@@ -428,11 +361,10 @@ export default { ...@@ -428,11 +361,10 @@ export default {
// 删除最后一个部分,即文件名 // 删除最后一个部分,即文件名
}, 500); }, 500);
} }
} else { }else{
console.log("newImgList", newImgList);
let obj = { let obj = {
type: "sendFile", type: "sendFile",
value: newImgList.map((el, index) => { value: imageResList.map((el, index) => {
el.designId = el.designId || index; el.designId = el.designId || index;
return el; return el;
}) })
...@@ -449,7 +381,41 @@ export default { ...@@ -449,7 +381,41 @@ export default {
} }
bus.$emit("busEmit", obj); bus.$emit("busEmit", obj);
} }
},
async getDataInfo() {
if (
this.detail &&
Object.keys(this.detail).length > 0 &&
this.isAutoFinish
) {
await this.setData(this.detail);
} }
if (this.productionNo === "")
return this.$message.warning("请录入生产单号");
if (!this.isAutoFinish && !this.isFirst)
this.$confirm("请注意自动完成上一单未勾选", "提示", {
confirmButtonText: "确定",
type: "warning"
});
try {
//查找生产单号信息传给第二个显示器
const findByPodProductionNo = await this.$api.post(
"/findByPodProductionNo",
{
thirdSubOrderNumber: this.productionNo,
type: this.factoryType
}
);
this.detail = findByPodProductionNo.data;
this.imgList = [];
let designImagesCanvasJsonList = this.detail.drParam
await this.hasDesignImagesCanvasJsonList(designImagesCanvasJsonList);
this.$store.commit("setProductDetail", findByPodProductionNo.data);
ipcRenderer.send("win-subScreen", findByPodProductionNo.data);
this.$dataStore.set("production_no", this.productionNo); this.$dataStore.set("production_no", this.productionNo);
this.productionNo = ""; this.productionNo = "";
this.$refs.searchRef.focus(); this.$refs.searchRef.focus();
...@@ -556,7 +522,7 @@ export default { ...@@ -556,7 +522,7 @@ export default {
console.log(347, store.state.desktopDevice); console.log(347, store.state.desktopDevice);
}, },
async cutImgFn(arr) { async cutImgFn(arr) {
if (!arr.length) return; if (!arr.length) return arr;
console.log(arr); console.log(arr);
try { try {
......
...@@ -652,7 +652,6 @@ export default { ...@@ -652,7 +652,6 @@ export default {
that.$nextTick(async () => { that.$nextTick(async () => {
let w = bw / 2; let w = bw / 2;
let h = bh / 2; let h = bh / 2;
let width_px, height_px, rate, x, y; let width_px, height_px, rate, x, y;
if (size && !files[i].isCut) { if (size && !files[i].isCut) {
width_px = that.WHproportion * mmToPx(size.width); width_px = that.WHproportion * mmToPx(size.width);
...@@ -1053,12 +1052,7 @@ export default { ...@@ -1053,12 +1052,7 @@ export default {
}); });
break; break;
case "sendFile": case "sendFile":
console.log("sendFile"); this.hasSize = !!size;
if (size) {
this.hasSize = true;
} else {
this.hasSize = false;
}
this.detail.designImageSize = size; this.detail.designImageSize = size;
console.log(this.detail, "this.detail"); console.log(this.detail, "this.detail");
this.imgList = []; this.imgList = [];
......
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