Commit e8825638 by linjinhong
parents 3b88bd94 29101503
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "JomallProductionAssistant", "name": "JomallProductionAssistant",
"productName": "JomallProductionAssistant", "productName": "JomallProductionAssistant",
"description": "", "description": "",
"version": "1.0.14", "version": "1.0.15",
"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,12 +291,96 @@ export default { ...@@ -287,12 +291,96 @@ 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);
this.$message.success(res.msg); this.$message.success(res.msg);
}, },
async hasDesignImagesCanvasJsonList(designImagesCanvasJsonList){
let imageResList = []
if (this.detail.adjustable && designImagesCanvasJsonList) {
designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList);
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 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;
});
imageResList = Sres.data;
}
}
if(!imageResList.length){
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
let res = await this.$api.post("/downloadBySubOrderNumber", {
ids: [this.detail.id],
device: this.$store.state.desktopDevice,
type: this.factoryType,
});
if (!res.data.length) return this.$message.warning("未找到素材图!");
res.data.forEach((el) => {
imageResList = imageResList.concat(el.list || []);
});
}
if (this.checked) {
imageResList = await this.cutImgFn(imageResList);
imageResList.forEach((el) => {
el.isCut = true;
});
}
// 延迟后强制激活窗口
if (this.desktopDevice !== 1) {
if (imageResList.length) {
let pathUrl = imageResList[0].productionFile;
setTimeout(async () => {
// await this.focusExplorerWindow(pathUrl);
const pathParts = pathUrl.split("\\");
pathParts.pop();
// 使用 join() 将剩余部分重新拼接成路径
const folderPath = pathParts.join("\\");
ipcRenderer.send("select-files", folderPath);
// 删除最后一个部分,即文件名
}, 500);
}
}else{
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);
}
},
async getDataInfo() { async getDataInfo() {
if ( if (
this.detail && this.detail &&
...@@ -308,7 +396,7 @@ export default { ...@@ -308,7 +396,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,127 +405,15 @@ export default { ...@@ -317,127 +405,15 @@ 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); this.imgList = [];
let imageResList = []; let designImagesCanvasJsonList = this.detail.drParam
let designImagesCanvasJsonList = this.detail.drParam await this.hasDesignImagesCanvasJsonList(designImagesCanvasJsonList);
if (designImagesCanvasJsonList) {
designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList);
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;
});
console.log("Sres", Sres);
imageResList = Sres.data;
this.imgList = [];
if (this.checked) {
imageResList = await this.cutImgFn(imageResList);
imageResList.forEach((el) => {
el.isCut = true;
});
}
}
this.$store.commit("setProductDetail", findByPodProductionNo.data); this.$store.commit("setProductDetail", findByPodProductionNo.data);
ipcRenderer.send("win-subScreen", 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);
} else {
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
let res = await this.$api.post("/downloadBySubOrderNumber", {
ids: [this.detail.id],
device: this.$store.state.desktopDevice,
type: this.factoryType,
});
if (res.data.length === 0)
return this.$message.warning("未找到素材图!");
this.imgList = [];
res.data.forEach((el) => {
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);
let newImgList;
if (this.checked) {
newImgList = await this.cutImgFn(res.data);
newImgList.forEach((el) => {
el.isCut = true;
});
} else {
newImgList = res.data;
}
// 延迟后强制激活窗口
if (this.desktopDevice !== 1) {
if (this.imgList.length) {
let pathUrl = this.imgList[0].productionFile;
setTimeout(async () => {
// await this.focusExplorerWindow(pathUrl);
const pathParts = pathUrl.split("\\");
pathParts.pop();
// 使用 join() 将剩余部分重新拼接成路径
const folderPath = pathParts.join("\\");
ipcRenderer.send("select-files", folderPath);
// 删除最后一个部分,即文件名
}, 500);
}
} else {
console.log("newImgList", newImgList);
let obj = {
type: "sendFile",
value: newImgList.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);
}
}
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();
...@@ -489,7 +465,7 @@ export default { ...@@ -489,7 +465,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 +486,8 @@ export default { ...@@ -510,8 +486,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 +507,7 @@ export default { ...@@ -531,7 +507,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] });
}, },
...@@ -544,7 +520,7 @@ export default { ...@@ -544,7 +520,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 {
...@@ -556,14 +532,14 @@ export default { ...@@ -556,14 +532,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 +574,8 @@ export default { ...@@ -598,8 +574,8 @@ export default {
} }
return ""; return "";
}, }
}, }
}; };
</script> </script>
<style scoped> <style scoped>
...@@ -656,7 +632,7 @@ export default { ...@@ -656,7 +632,7 @@ export default {
:disabled="true" :disabled="true"
> >
<el-button style="height: 100%;margin-right: 0" size="small" <el-button style="height: 100%;margin-right: 0" size="small"
>{{ grid[selectGridIndex].label }} >{{ grid[selectGridIndex].label }}
</el-button> </el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="i" v-for="(it, i) in grid" :key="i"> <el-dropdown-item :command="i" v-for="(it, i) in grid" :key="i">
...@@ -783,7 +759,7 @@ export default { ...@@ -783,7 +759,7 @@ export default {
@click="checkUpdate" @click="checkUpdate"
style="margin-left: 15px" style="margin-left: 15px"
type="text" type="text"
>检查更新 >检查更新
</el-button> </el-button>
</el-form-item> </el-form-item>
...@@ -830,7 +806,7 @@ export default { ...@@ -830,7 +806,7 @@ export default {
size="medium" size="medium"
style="margin-left: 10px" style="margin-left: 10px"
type="primary" type="primary"
>查询 >查询
</el-button> </el-button>
<div class="sure-btn"> <div class="sure-btn">
<el-button <el-button
...@@ -838,7 +814,7 @@ export default { ...@@ -838,7 +814,7 @@ export default {
size="medium" size="medium"
style="margin-left: 10px;width: 100%;" style="margin-left: 10px;width: 100%;"
type="success" type="success"
>生产完成 >生产完成
</el-button> </el-button>
<div class="check"> <div class="check">
<el-checkbox v-model="isAutoFinish">自动完成上一单</el-checkbox> <el-checkbox v-model="isAutoFinish">自动完成上一单</el-checkbox>
...@@ -852,7 +828,7 @@ export default { ...@@ -852,7 +828,7 @@ export default {
size="medium" size="medium"
style="margin-left: 15px" style="margin-left: 15px"
type="primary" type="primary"
>下载素材 >下载素材
</el-button> </el-button>
</div> </div>
<div class="right-user"> <div class="right-user">
...@@ -863,8 +839,8 @@ export default { ...@@ -863,8 +839,8 @@ export default {
{{ {{
user.factory.countryCode user.factory.countryCode
? `${user.factory.countryCode}${getCountryName( ? `${user.factory.countryCode}${getCountryName(
user.factory.countryCode user.factory.countryCode
)}` )}`
: "CN(中国)" : "CN(中国)"
}} }}
</div> </div>
...@@ -893,7 +869,7 @@ export default { ...@@ -893,7 +869,7 @@ export default {
:label="item.value" :label="item.value"
v-for="(item, i) in cacheList" v-for="(item, i) in cacheList"
:key="i" :key="i"
>{{ item.label }} >{{ item.label }}
</el-checkbox> </el-checkbox>
</el-checkbox-group> </el-checkbox-group>
<template #footer> <template #footer>
......
...@@ -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