Commit e8825638 by linjinhong
parents 3b88bd94 29101503
......@@ -2,7 +2,7 @@
"name": "JomallProductionAssistant",
"productName": "JomallProductionAssistant",
"description": "",
"version": "1.0.14",
"version": "1.0.15",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
......@@ -29,7 +29,7 @@
"electron-updater": "^6.2.1",
"element-ui": "^2.13.0",
"express": "^4.17.1",
"fabric": "^5.2.4",
"fabric": "^6.7.0",
"html2canvas": "^1.4.1",
"lodash-id": "^0.14.0",
"log4js": "^6.9.1",
......
......@@ -8,6 +8,7 @@ import UpdateDialog from "@/views/design/updateDialog.vue";
import path from "path"; // 引入 path 模块
import store from "@/store/index.js";
import axios from "axios";
const uuid = require("uuid");
const fs = require("fs");
import { mapState } from "vuex";
......@@ -18,11 +19,11 @@ export default {
user: {
default: {
avatar: "",
factory: {},
factory: {}
},
type: Object,
type: Object
},
factoryType: { type: String, default: "CN" },
factoryType: { type: String, default: "CN" }
},
data() {
return {
......@@ -33,20 +34,20 @@ export default {
cacheList: [
{
label: "清除当前登录信息",
value: "token",
value: "token"
},
{
label: "登录记录",
value: "userList",
value: "userList"
},
{
label: "打印预设",
value: "print-setting",
value: "print-setting"
},
{
label: "系统设置",
value: "setting",
},
value: "setting"
}
],
selectGridIndex: 0,
pkg,
......@@ -61,7 +62,7 @@ export default {
unit: "inch",
language: "cn",
autoPrint: false,
gridSpacing: 1,
gridSpacing: 1
},
imgList: [],
detail: null,
......@@ -80,8 +81,8 @@ export default {
"hsva(120, 40, 94, 0.5)",
"hsl(181, 100%, 37%)",
"hsla(209, 100%, 56%, 0.73)",
"#c7158577",
],
"#c7158577"
]
};
},
computed: {
......@@ -89,7 +90,7 @@ export default {
return this.$store.getters.getActionList;
},
...mapState(["grid", "defaultProportion", "countryList"]),
...mapState(["grid", "defaultProportion", "countryList"])
},
mounted() {
// console.log(pkg, "pkg");
......@@ -114,8 +115,8 @@ export default {
bus.$emit("busEmit", { type: "updateSystemSetting" });
},
deep: true,
},
deep: true
}
},
methods: {
checkUpdate() {
......@@ -134,13 +135,14 @@ export default {
this.$confirm("是否退出登录?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
type: "warning"
})
.then(() => {
this.$dataStore.delete("user");
this.$router.push("/");
})
.catch(() => {});
.catch(() => {
});
break;
case "cache":
......@@ -155,9 +157,10 @@ export default {
.post("/completeDelivery", {
id: data.id,
type: this.factoryType,
podJomallOrderUsId: data.podJomallOrderUsId,
podJomallOrderUsId: data.podJomallOrderUsId
})
.then(() => {});
.then(() => {
});
this.$message.success("操作成功");
},
async sureData() {
......@@ -167,7 +170,7 @@ export default {
this.$confirm(`确定生产完成?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
type: "warning"
}).then(async () => {
await this.setData(this.detail);
});
......@@ -179,7 +182,7 @@ export default {
this.$confirm("是否确定清除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
type: "warning"
})
.then(() => {
for (let k of this.checkList) {
......@@ -201,14 +204,15 @@ export default {
}
window.location.reload();
})
.catch(() => {});
.catch(() => {
});
},
drawImage(canvas, item) {
return new Promise((resolve, reject) => {
try {
axios
.get(item?.src, {
responseType: "blob",
responseType: "blob"
})
.then((res) => {
// console.log("item", item);
......@@ -287,12 +291,96 @@ export default {
return this.$message.warning("请扫描生产单号");
let params = {
productionNo: this.detail.factorySubOrderNumber,
imgList: this.imgList,
imgList: this.imgList
};
let res = await this.$api.post("/downloadByDesignId", params);
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() {
if (
this.detail &&
......@@ -308,7 +396,7 @@ export default {
if (!this.isAutoFinish && !this.isFirst)
this.$confirm("请注意自动完成上一单未勾选", "提示", {
confirmButtonText: "确定",
type: "warning",
type: "warning"
});
try {
......@@ -317,127 +405,15 @@ export default {
"/findByPodProductionNo",
{
thirdSubOrderNumber: this.productionNo,
type: this.factoryType,
type: this.factoryType
}
);
this.detail = findByPodProductionNo.data;
// console.log("detail111111", findByPodProductionNo);
let imageResList = [];
let designImagesCanvasJsonList = this.detail.drParam
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.imgList = [];
let designImagesCanvasJsonList = this.detail.drParam
await this.hasDesignImagesCanvasJsonList(designImagesCanvasJsonList);
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);
} 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.productionNo = "";
this.$refs.searchRef.focus();
......@@ -489,7 +465,7 @@ export default {
unit: "mm",
language: "cn",
autoPrint: false,
gridSpacing: 10,
gridSpacing: 10
};
this.$message.success("重置应用程序设置成功");
},
......@@ -510,8 +486,8 @@ export default {
formData.append("file", f);
let { data } = await this.$api.post("/uploadImage", formData, {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
"Content-Type": "application/x-www-form-urlencoded"
}
});
bus.$emit("busEmit", { type: "uploadImage", value: data });
return false;
......@@ -531,7 +507,7 @@ export default {
this.$store.commit("updateSystemSetting", {
field: "gridValue",
value: this.grid[i],
value: this.grid[i]
});
bus.$emit("busEmit", { type: "grid", value: this.grid[i] });
},
......@@ -544,7 +520,7 @@ export default {
console.log(347, store.state.desktopDevice);
},
async cutImgFn(arr) {
if (!arr.length) return;
if (!arr.length) return arr;
console.log(arr);
try {
......@@ -556,14 +532,14 @@ export default {
const outputPath = path.join(outputDir, outputFileName);
const params = {
inputPath: el.productionFile,
outputPath: outputPath,
outputPath: outputPath
};
const res = await this.$api.post("/processImage", params);
fs.unlinkSync(el.productionFile);
return {
fileName: outputFileName,
productionFile: res.msg[0]?.outputPath,
designId: el.designId || index,
designId: el.designId || index
};
} catch (error) {
console.error(`处理失败: ${el.productionFile}`, error);
......@@ -598,8 +574,8 @@ export default {
}
return "";
},
},
}
}
};
</script>
<style scoped>
......@@ -656,7 +632,7 @@ export default {
:disabled="true"
>
<el-button style="height: 100%;margin-right: 0" size="small"
>{{ grid[selectGridIndex].label }}
>{{ grid[selectGridIndex].label }}
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="i" v-for="(it, i) in grid" :key="i">
......@@ -783,7 +759,7 @@ export default {
@click="checkUpdate"
style="margin-left: 15px"
type="text"
>检查更新
>检查更新
</el-button>
</el-form-item>
......@@ -830,7 +806,7 @@ export default {
size="medium"
style="margin-left: 10px"
type="primary"
>查询
>查询
</el-button>
<div class="sure-btn">
<el-button
......@@ -838,7 +814,7 @@ export default {
size="medium"
style="margin-left: 10px;width: 100%;"
type="success"
>生产完成
>生产完成
</el-button>
<div class="check">
<el-checkbox v-model="isAutoFinish">自动完成上一单</el-checkbox>
......@@ -852,7 +828,7 @@ export default {
size="medium"
style="margin-left: 15px"
type="primary"
>下载素材
>下载素材
</el-button>
</div>
<div class="right-user">
......@@ -863,8 +839,8 @@ export default {
{{
user.factory.countryCode
? `${user.factory.countryCode}${getCountryName(
user.factory.countryCode
)}`
user.factory.countryCode
)}`
: "CN(中国)"
}}
</div>
......@@ -893,7 +869,7 @@ export default {
:label="item.value"
v-for="(item, i) in cacheList"
:key="i"
>{{ item.label }}
>{{ item.label }}
</el-checkbox>
</el-checkbox-group>
<template #footer>
......
......@@ -652,7 +652,6 @@ export default {
that.$nextTick(async () => {
let w = bw / 2;
let h = bh / 2;
let width_px, height_px, rate, x, y;
if (size && !files[i].isCut) {
width_px = that.WHproportion * mmToPx(size.width);
......@@ -1053,12 +1052,7 @@ export default {
});
break;
case "sendFile":
console.log("sendFile");
if (size) {
this.hasSize = true;
} else {
this.hasSize = false;
}
this.hasSize = !!size;
this.detail.designImageSize = size;
console.log(this.detail, "this.detail");
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