Commit 4e672b59 by zhuzhequan

修改图片获取逻辑,添加erp存储dr_param自动获取图片

parent 443d230e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "JomallProductionAssistant", "name": "JomallProductionAssistant",
"productName": "JomallProductionAssistant", "productName": "JomallProductionAssistant",
"description": "", "description": "",
"version": "1.0.13", "version": "1.0.14",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"electron-updater": "^6.2.1", "electron-updater": "^6.2.1",
"element-ui": "^2.13.0", "element-ui": "^2.13.0",
"express": "^4.17.1", "express": "^4.17.1",
"fabric": "^5.2.4", "fabric": "^6.7.0",
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
"lodash-id": "^0.14.0", "lodash-id": "^0.14.0",
"log4js": "^6.9.1", "log4js": "^6.9.1",
......
...@@ -8,6 +8,7 @@ import UpdateDialog from "@/views/design/updateDialog.vue"; ...@@ -8,6 +8,7 @@ import UpdateDialog from "@/views/design/updateDialog.vue";
import path from "path"; // 引入 path 模块 import path from "path"; // 引入 path 模块
import store from "@/store/index.js"; import store from "@/store/index.js";
import axios from "axios"; import axios from "axios";
const uuid = require("uuid"); const uuid = require("uuid");
const fs = require("fs"); const fs = require("fs");
import { mapState } from "vuex"; import { mapState } from "vuex";
...@@ -18,11 +19,11 @@ export default { ...@@ -18,11 +19,11 @@ export default {
user: { user: {
default: { default: {
avatar: "", avatar: "",
factory: {}, factory: {}
}, },
type: Object, type: Object
}, },
factoryType: { type: String, default: "CN" }, factoryType: { type: String, default: "CN" }
}, },
data() { data() {
return { return {
...@@ -33,20 +34,20 @@ export default { ...@@ -33,20 +34,20 @@ export default {
cacheList: [ cacheList: [
{ {
label: "清除当前登录信息", label: "清除当前登录信息",
value: "token", value: "token"
}, },
{ {
label: "登录记录", label: "登录记录",
value: "userList", value: "userList"
}, },
{ {
label: "打印预设", label: "打印预设",
value: "print-setting", value: "print-setting"
}, },
{ {
label: "系统设置", label: "系统设置",
value: "setting", value: "setting"
}, }
], ],
selectGridIndex: 0, selectGridIndex: 0,
pkg, pkg,
...@@ -61,7 +62,7 @@ export default { ...@@ -61,7 +62,7 @@ export default {
unit: "inch", unit: "inch",
language: "cn", language: "cn",
autoPrint: false, autoPrint: false,
gridSpacing: 1, gridSpacing: 1
}, },
imgList: [], imgList: [],
detail: null, detail: null,
...@@ -80,8 +81,8 @@ export default { ...@@ -80,8 +81,8 @@ export default {
"hsva(120, 40, 94, 0.5)", "hsva(120, 40, 94, 0.5)",
"hsl(181, 100%, 37%)", "hsl(181, 100%, 37%)",
"hsla(209, 100%, 56%, 0.73)", "hsla(209, 100%, 56%, 0.73)",
"#c7158577", "#c7158577"
], ]
}; };
}, },
computed: { computed: {
...@@ -89,7 +90,7 @@ export default { ...@@ -89,7 +90,7 @@ export default {
return this.$store.getters.getActionList; return this.$store.getters.getActionList;
}, },
...mapState(["grid", "defaultProportion", "countryList"]), ...mapState(["grid", "defaultProportion", "countryList"])
}, },
mounted() { mounted() {
// console.log(pkg, "pkg"); // console.log(pkg, "pkg");
...@@ -114,8 +115,8 @@ export default { ...@@ -114,8 +115,8 @@ export default {
bus.$emit("busEmit", { type: "updateSystemSetting" }); bus.$emit("busEmit", { type: "updateSystemSetting" });
}, },
deep: true, deep: true
}, }
}, },
methods: { methods: {
checkUpdate() { checkUpdate() {
...@@ -134,13 +135,14 @@ export default { ...@@ -134,13 +135,14 @@ export default {
this.$confirm("是否退出登录?", "提示", { this.$confirm("是否退出登录?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning"
}) })
.then(() => { .then(() => {
this.$dataStore.delete("user"); this.$dataStore.delete("user");
this.$router.push("/"); this.$router.push("/");
}) })
.catch(() => {}); .catch(() => {
});
break; break;
case "cache": case "cache":
...@@ -155,9 +157,10 @@ export default { ...@@ -155,9 +157,10 @@ export default {
.post("/completeDelivery", { .post("/completeDelivery", {
id: data.id, id: data.id,
type: this.factoryType, type: this.factoryType,
podJomallOrderUsId: data.podJomallOrderUsId, podJomallOrderUsId: data.podJomallOrderUsId
}) })
.then(() => {}); .then(() => {
});
this.$message.success("操作成功"); this.$message.success("操作成功");
}, },
async sureData() { async sureData() {
...@@ -167,7 +170,7 @@ export default { ...@@ -167,7 +170,7 @@ export default {
this.$confirm(`确定生产完成?`, "提示", { this.$confirm(`确定生产完成?`, "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning"
}).then(async () => { }).then(async () => {
await this.setData(this.detail); await this.setData(this.detail);
}); });
...@@ -179,7 +182,7 @@ export default { ...@@ -179,7 +182,7 @@ export default {
this.$confirm("是否确定清除?", "提示", { this.$confirm("是否确定清除?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning"
}) })
.then(() => { .then(() => {
for (let k of this.checkList) { for (let k of this.checkList) {
...@@ -201,14 +204,15 @@ export default { ...@@ -201,14 +204,15 @@ export default {
} }
window.location.reload(); window.location.reload();
}) })
.catch(() => {}); .catch(() => {
});
}, },
drawImage(canvas, item) { drawImage(canvas, item) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
axios axios
.get(item?.src, { .get(item?.src, {
responseType: "blob", responseType: "blob"
}) })
.then((res) => { .then((res) => {
// console.log("item", item); // console.log("item", item);
...@@ -287,7 +291,7 @@ export default { ...@@ -287,7 +291,7 @@ export default {
return this.$message.warning("请扫描生产单号"); return this.$message.warning("请扫描生产单号");
let params = { let params = {
productionNo: this.detail.factorySubOrderNumber, productionNo: this.detail.factorySubOrderNumber,
imgList: this.imgList, imgList: this.imgList
}; };
let res = await this.$api.post("/downloadByDesignId", params); let res = await this.$api.post("/downloadByDesignId", params);
...@@ -308,7 +312,7 @@ export default { ...@@ -308,7 +312,7 @@ export default {
if (!this.isAutoFinish && !this.isFirst) if (!this.isAutoFinish && !this.isFirst)
this.$confirm("请注意自动完成上一单未勾选", "提示", { this.$confirm("请注意自动完成上一单未勾选", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
type: "warning", type: "warning"
}); });
try { try {
...@@ -317,15 +321,17 @@ export default { ...@@ -317,15 +321,17 @@ export default {
"/findByPodProductionNo", "/findByPodProductionNo",
{ {
thirdSubOrderNumber: this.productionNo, thirdSubOrderNumber: this.productionNo,
type: this.factoryType, type: this.factoryType
} }
); );
this.detail = findByPodProductionNo.data; this.detail = findByPodProductionNo.data;
// console.log("detail111111", findByPodProductionNo); // console.log("detail111111", findByPodProductionNo);
let imageResList = []; let imageResList = [];
this.imgList = [];
let designImagesCanvasJsonList = this.detail.drParam let designImagesCanvasJsonList = this.detail.drParam
if (designImagesCanvasJsonList) { if (designImagesCanvasJsonList) {
designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList); designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList);
if (this.detail.adjustable) {
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) {
...@@ -338,8 +344,6 @@ export default { ...@@ -338,8 +344,6 @@ export default {
item.title = designImagesCanvasJsonList[i].options.title; item.title = designImagesCanvasJsonList[i].options.title;
item.productionFile = item.url; item.productionFile = item.url;
}); });
console.log("Sres", Sres);
imageResList = Sres.data; imageResList = Sres.data;
this.imgList = []; this.imgList = [];
if (this.checked) { if (this.checked) {
...@@ -348,6 +352,17 @@ export default { ...@@ -348,6 +352,17 @@ export default {
el.isCut = true; 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); this.$store.commit("setProductDetail", findByPodProductionNo.data);
ipcRenderer.send("win-subScreen", findByPodProductionNo.data); ipcRenderer.send("win-subScreen", findByPodProductionNo.data);
...@@ -358,7 +373,7 @@ export default { ...@@ -358,7 +373,7 @@ export default {
value: imageResList.map((el, index) => { value: imageResList.map((el, index) => {
el.designId = el.designId || index; el.designId = el.designId || index;
return el; return el;
}), })
}; };
if ( if (
this.detail.mssWidth && this.detail.mssWidth &&
...@@ -367,11 +382,12 @@ export default { ...@@ -367,11 +382,12 @@ export default {
) { ) {
obj.size = { obj.size = {
width: this.detail.mssWidth, width: this.detail.mssWidth,
height: this.detail.mssHeight, height: this.detail.mssHeight
}; };
} }
bus.$emit("busEmit", obj); bus.$emit("busEmit", obj);
} else { } 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],
...@@ -380,27 +396,23 @@ export default { ...@@ -380,27 +396,23 @@ 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 || []); this.imgList = this.imgList.concat(el.list || []);
}); });
let arr = [];
res.data.forEach((el) => {
if (el.list) {
el.list.forEach((it) => {
arr.push(it);
});
} }
});
res.data = arr.filter((el) => el.type !== 1); // res.data = arr.filter((el) => el.type !== 1);
let newImgList; let newImgList;
if(this.imgList.length)
if (this.checked) { if (this.checked) {
newImgList = await this.cutImgFn(res.data); newImgList = await this.cutImgFn(this.imgList);
newImgList.forEach((el) => { newImgList.forEach((el) => {
el.isCut = true; el.isCut = true;
}); });
} else { } else {
newImgList = res.data; newImgList = this.imgList;
} }
// 延迟后强制激活窗口 // 延迟后强制激活窗口
if (this.desktopDevice !== 1) { if (this.desktopDevice !== 1) {
...@@ -423,7 +435,7 @@ export default { ...@@ -423,7 +435,7 @@ export default {
value: newImgList.map((el, index) => { value: newImgList.map((el, index) => {
el.designId = el.designId || index; el.designId = el.designId || index;
return el; return el;
}), })
}; };
if ( if (
this.detail.mssWidth && this.detail.mssWidth &&
...@@ -432,7 +444,7 @@ export default { ...@@ -432,7 +444,7 @@ export default {
) { ) {
obj.size = { obj.size = {
width: this.detail.mssWidth, width: this.detail.mssWidth,
height: this.detail.mssHeight, height: this.detail.mssHeight
}; };
} }
bus.$emit("busEmit", obj); bus.$emit("busEmit", obj);
...@@ -489,7 +501,7 @@ export default { ...@@ -489,7 +501,7 @@ export default {
unit: "mm", unit: "mm",
language: "cn", language: "cn",
autoPrint: false, autoPrint: false,
gridSpacing: 10, gridSpacing: 10
}; };
this.$message.success("重置应用程序设置成功"); this.$message.success("重置应用程序设置成功");
}, },
...@@ -510,8 +522,8 @@ export default { ...@@ -510,8 +522,8 @@ export default {
formData.append("file", f); formData.append("file", f);
let { data } = await this.$api.post("/uploadImage", formData, { let { data } = await this.$api.post("/uploadImage", formData, {
headers: { headers: {
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded"
}, }
}); });
bus.$emit("busEmit", { type: "uploadImage", value: data }); bus.$emit("busEmit", { type: "uploadImage", value: data });
return false; return false;
...@@ -531,7 +543,7 @@ export default { ...@@ -531,7 +543,7 @@ export default {
this.$store.commit("updateSystemSetting", { this.$store.commit("updateSystemSetting", {
field: "gridValue", field: "gridValue",
value: this.grid[i], value: this.grid[i]
}); });
bus.$emit("busEmit", { type: "grid", value: this.grid[i] }); bus.$emit("busEmit", { type: "grid", value: this.grid[i] });
}, },
...@@ -556,14 +568,14 @@ export default { ...@@ -556,14 +568,14 @@ export default {
const outputPath = path.join(outputDir, outputFileName); const outputPath = path.join(outputDir, outputFileName);
const params = { const params = {
inputPath: el.productionFile, inputPath: el.productionFile,
outputPath: outputPath, outputPath: outputPath
}; };
const res = await this.$api.post("/processImage", params); const res = await this.$api.post("/processImage", params);
fs.unlinkSync(el.productionFile); fs.unlinkSync(el.productionFile);
return { return {
fileName: outputFileName, fileName: outputFileName,
productionFile: res.msg[0]?.outputPath, productionFile: res.msg[0]?.outputPath,
designId: el.designId || index, designId: el.designId || index
}; };
} catch (error) { } catch (error) {
console.error(`处理失败: ${el.productionFile}`, error); console.error(`处理失败: ${el.productionFile}`, error);
...@@ -598,8 +610,8 @@ export default { ...@@ -598,8 +610,8 @@ export default {
} }
return ""; return "";
}, }
}, }
}; };
</script> </script>
<style scoped> <style scoped>
......
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