Commit f487e64e by zhuzhequan

添加自动打印逻辑

parents 259b924d ee10b4cf
...@@ -25,7 +25,7 @@ yarn-error.log* ...@@ -25,7 +25,7 @@ yarn-error.log*
/dist_electron /dist_electron
# 排除 print/Input 目录下的 .bat 文件 # 排除 print/Input 目录下的 .bat 文件
!/print/Input/*.bat /print/Input/*.png
print/Profile/* print/Profile/*
/logs /logs
\ No newline at end of file
{ {
"apiApiHost":"http://10.168.31.142:8060/api", "apiApiHost":"http://10.168.31.142:8060/api",
"fileApiUrl":"http://10.168.31.142:80/upload/factory", "fileApiUrl":"http://10.168.31.142:80/upload/factory",
"visionUrl":"https://console.jomalls.com" "visionUrl":"https://console.jomalls.com"
} }
......
...@@ -250,3 +250,51 @@ ...@@ -250,3 +250,51 @@
状态码 :200 状态码 :200
data :{"code":200,"data":false,"message":"操作成功"} data :{"code":200,"data":false,"message":"操作成功"}
[2025-04-28T17:02:14.737] [INFO] log -
时间:2025-04-28 17:02:14
ip : ::1
host : localhost:3000
响应时间 : 0.236 s
method :GET
url :/checkUpdate?version=1.0.8
token :eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzeXNVc2VyIjp7ImlkIjo0NiwiYWNjb3VudCI6IjEyMzQ1NiIsInBhc3N3b3JkIjoiZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2UiLCJzdXBwZXJNYXJrIjoxLCJmYWN0b3J5SWQiOjMzLCJmYWN0b3J5Q29kZSI6IlQzNCIsInN0YXR1cyI6MSwiZmFjdG9yeSI6eyJpZCI6MzMsImJpYW5tYSI6IlQzNCIsInRpdGxlIjoiVDM0NjYiLCJ0eXBlSWQiOjE2LCJuYW1lIjoiMTIzIiwibW9iaWxlIjoiMTIzNDU2IiwiZ29vZHNOdW1iZXIiOjg0LCJhdXRob3JpemVOdW1iZXIiOjAsInN0YXR1cyI6MX19LCJleHAiOjE3NDU4OTM0NjB9.-zK0EZjr3Q2wIykEgls8SFjgU9aQwmw3tKTQ0r1ZGIrivuy7bJdBCMRn29oPTwXkFmRJjpneYi3pLTZErXjCSA
body :{}
状态码 :304
data :{"code":200,"data":false,"message":"操作成功"}
[2025-04-28T17:03:37.996] [INFO] log -
时间:2025-04-28 17:03:37
ip : ::1
host : localhost:3000
响应时间 : 0.284 s
method :GET
url :/checkUpdate?version=1.0.8
token :eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzeXNVc2VyIjp7ImlkIjo0NiwiYWNjb3VudCI6IjEyMzQ1NiIsInBhc3N3b3JkIjoiZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2UiLCJzdXBwZXJNYXJrIjoxLCJmYWN0b3J5SWQiOjMzLCJmYWN0b3J5Q29kZSI6IlQzNCIsInN0YXR1cyI6MSwiZmFjdG9yeSI6eyJpZCI6MzMsImJpYW5tYSI6IlQzNCIsInRpdGxlIjoiVDM0NjYiLCJ0eXBlSWQiOjE2LCJuYW1lIjoiMTIzIiwibW9iaWxlIjoiMTIzNDU2IiwiZ29vZHNOdW1iZXIiOjg0LCJhdXRob3JpemVOdW1iZXIiOjAsInN0YXR1cyI6MX19LCJleHAiOjE3NDU4OTM0NjB9.-zK0EZjr3Q2wIykEgls8SFjgU9aQwmw3tKTQ0r1ZGIrivuy7bJdBCMRn29oPTwXkFmRJjpneYi3pLTZErXjCSA
body :{}
状态码 :304
data :{"code":200,"data":false,"message":"操作成功"}
[2025-04-28T17:03:52.329] [INFO] log -
时间:2025-04-28 17:03:52
ip : ::1
host : localhost:3000
响应时间 : 0.167 s
method :GET
url :/checkUpdate?version=1.0.8
token :eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzeXNVc2VyIjp7ImlkIjo0NiwiYWNjb3VudCI6IjEyMzQ1NiIsInBhc3N3b3JkIjoiZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2UiLCJzdXBwZXJNYXJrIjoxLCJmYWN0b3J5SWQiOjMzLCJmYWN0b3J5Q29kZSI6IlQzNCIsInN0YXR1cyI6MSwiZmFjdG9yeSI6eyJpZCI6MzMsImJpYW5tYSI6IlQzNCIsInRpdGxlIjoiVDM0NjYiLCJ0eXBlSWQiOjE2LCJuYW1lIjoiMTIzIiwibW9iaWxlIjoiMTIzNDU2IiwiZ29vZHNOdW1iZXIiOjg0LCJhdXRob3JpemVOdW1iZXIiOjAsInN0YXR1cyI6MX19LCJleHAiOjE3NDU4OTM0NjB9.-zK0EZjr3Q2wIykEgls8SFjgU9aQwmw3tKTQ0r1ZGIrivuy7bJdBCMRn29oPTwXkFmRJjpneYi3pLTZErXjCSA
body :{}
状态码 :304
data :{"code":200,"data":false,"message":"操作成功"}
[2025-04-28T17:04:15.177] [INFO] log -
时间:2025-04-28 17:04:15
ip : ::1
host : localhost:3000
响应时间 : 0.166 s
method :GET
url :/checkUpdate?version=1.0.8
token :eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzeXNVc2VyIjp7ImlkIjo0NiwiYWNjb3VudCI6IjEyMzQ1NiIsInBhc3N3b3JkIjoiZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2UiLCJzdXBwZXJNYXJrIjoxLCJmYWN0b3J5SWQiOjMzLCJmYWN0b3J5Q29kZSI6IlQzNCIsInN0YXR1cyI6MSwiZmFjdG9yeSI6eyJpZCI6MzMsImJpYW5tYSI6IlQzNCIsInRpdGxlIjoiVDM0NjYiLCJ0eXBlSWQiOjE2LCJuYW1lIjoiMTIzIiwibW9iaWxlIjoiMTIzNDU2IiwiZ29vZHNOdW1iZXIiOjg0LCJhdXRob3JpemVOdW1iZXIiOjAsInN0YXR1cyI6MX19LCJleHAiOjE3NDU4OTM0NjB9.-zK0EZjr3Q2wIykEgls8SFjgU9aQwmw3tKTQ0r1ZGIrivuy7bJdBCMRn29oPTwXkFmRJjpneYi3pLTZErXjCSA
body :{}
状态码 :304
data :{"code":200,"data":false,"message":"操作成功"}
...@@ -36,22 +36,23 @@ async function createWindow() { ...@@ -36,22 +36,23 @@ async function createWindow() {
nodeIntegration: true, nodeIntegration: true,
}, },
}); });
let newWindow = new BrowserWindow({
fullscreen: false, // let newWindow = new BrowserWindow({
width: 1000, // fullscreen: false,
height: 1000, // width: 1000,
webPreferences: { // height: 1000,
nodeIntegration: true, // webPreferences: {
//配置预加载脚本文件(preload),此处起名为preloadOther // nodeIntegration: true,
//p.s.路径为绝对路径 // //配置预加载脚本文件(preload),此处起名为preloadOther
// preload: path.join(__dirname, "./preloadOther.js") // //p.s.路径为绝对路径
}, // // preload: path.join(__dirname, "./preloadOther.js")
}); // },
// });
console.log(winURL + "#" + `/design-detail`); console.log(winURL + "#" + `/design-detail`);
//指定副屏幕打开的网页 // //指定副屏幕打开的网页
await newWindow.loadURL(winURL + "#" + `/design-detail`); // await newWindow.loadURL(winURL + "#" + `/design-detail`);
newWindow.reload(); // newWindow.reload();
// win.on("closed", () => { // win.on("closed", () => {
// //这一段放外面的话,如果你电脑没双屏会报错。 // //这一段放外面的话,如果你电脑没双屏会报错。
// win = null; // win = null;
...@@ -90,11 +91,11 @@ async function createWindow() { ...@@ -90,11 +91,11 @@ async function createWindow() {
win.removeAllListeners(); win.removeAllListeners();
win = null; win = null;
} }
// 确保 newWindow 还未销毁,才执行关闭操作 // // 确保 newWindow 还未销毁,才执行关闭操作
if (newWindow && !newWindow.isDestroyed()) { // if (newWindow && !newWindow.isDestroyed()) {
newWindow.close(); // newWindow.close();
newWindow = null; // newWindow = null;
} // }
}); });
// 自动更新逻辑开始 // 自动更新逻辑开始
...@@ -166,6 +167,16 @@ async function createWindow() { ...@@ -166,6 +167,16 @@ async function createWindow() {
}); });
}); });
}); });
win.on("resize", () => {
const { width, height } = win.getBounds();
win.webContents.send("window-size", { width, height });
});
// 监听窗口的 reload 事件
win.webContents.on("did-finish-load", () => {
const { width, height } = win.getBounds();
win.webContents.send("window-size", { width, height });
});
} }
app.on("activate", async () => { app.on("activate", async () => {
...@@ -176,6 +187,9 @@ app.on("activate", async () => { ...@@ -176,6 +187,9 @@ app.on("activate", async () => {
app.on("ready", async () => { app.on("ready", async () => {
await createWindow(); await createWindow();
// 获取当前窗口的尺寸
const { width, height } = win.getBounds();
win.webContents.send("window-size", { width, height });
globalShortcut.register("F5", () => { globalShortcut.register("F5", () => {
return false; return false;
}); });
......
...@@ -77,7 +77,7 @@ export default { ...@@ -77,7 +77,7 @@ export default {
data, data,
} = await axios.post( } = await axios.post(
`${env}/factory/podJomallOrder/downloadByProduction`, `${env}/factory/podJomallOrder/downloadByProduction`,
params, [req.body[0]],
{ headers: { "jwt-token": token } } { headers: { "jwt-token": token } }
); );
let files = []; let files = [];
...@@ -86,8 +86,8 @@ export default { ...@@ -86,8 +86,8 @@ export default {
files = files.map((el) => { files = files.map((el) => {
return { url: `${fileEnv}${el}` }; return { url: `${fileEnv}${el}` };
}); });
console.log(89, files); // res.json({ code: 200, data: "" });
// return;
if (req.body[1] === 1) { if (req.body[1] === 1) {
downloadImage(files) downloadImage(files)
.then((data) => { .then((data) => {
......
...@@ -13,7 +13,10 @@ export default new Vuex.Store({ ...@@ -13,7 +13,10 @@ export default new Vuex.Store({
state: { state: {
actionList: [], actionList: [],
imgList: [], imgList: [],
productDetail: {},
desktopDevice: 1, //1是兄弟,2是其他 desktopDevice: 1, //1是兄弟,2是其他
WHproportion: 1, //宽高比例
isPreView: false, //宽高比例
actionIndex: -1, actionIndex: -1,
systemSetting: { systemSetting: {
gridShow: 1, gridShow: 1,
...@@ -43,6 +46,15 @@ export default new Vuex.Store({ ...@@ -43,6 +46,15 @@ export default new Vuex.Store({
changeDesktopDevice(state, value) { changeDesktopDevice(state, value) {
state.desktopDevice = value; state.desktopDevice = value;
}, },
setProductDetail(state, value) {
state.productDetail = value;
},
setWHproportion(state, value) {
state.WHproportion = value;
},
setIsPreView(state, value) {
state.isPreView = value;
},
}, },
getters: { getters: {
systemSetting(state) { systemSetting(state) {
......
...@@ -6,7 +6,7 @@ import { Loading } from "element-ui"; ...@@ -6,7 +6,7 @@ import { Loading } from "element-ui";
const service = axios.create({ const service = axios.create({
baseURL: "http://localhost:3000", // url = base url + request url baseURL: "http://localhost:3000", // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests // withCredentials: true, // send cookies when cross-domain requests
timeout: 50000000 // request timeout timeout: 50000000, // request timeout
}); });
let loading; let loading;
...@@ -15,7 +15,7 @@ function startLoading() { ...@@ -15,7 +15,7 @@ function startLoading() {
lock: true, lock: true,
text: "拼命加载中...", text: "拼命加载中...",
spinner: "el-icon-loading", spinner: "el-icon-loading",
background: "rgba(0,0,0,.7)" background: "rgba(0,0,0,.7)",
}); });
} }
...@@ -25,7 +25,7 @@ function endLoading() { ...@@ -25,7 +25,7 @@ function endLoading() {
// Add a request interceptor // Add a request interceptor
service.interceptors.request.use( service.interceptors.request.use(
config => { (config) => {
console.log(Vue.prototype.$dataStore); console.log(Vue.prototype.$dataStore);
const user = Vue.prototype.$dataStore.get("user"); const user = Vue.prototype.$dataStore.get("user");
if (user) { if (user) {
...@@ -34,7 +34,7 @@ service.interceptors.request.use( ...@@ -34,7 +34,7 @@ service.interceptors.request.use(
startLoading(); startLoading();
return config; return config;
}, },
error => { (error) => {
endLoading(); endLoading();
// do something with request error // do something with request error
return Promise.reject(error); return Promise.reject(error);
...@@ -53,7 +53,7 @@ service.interceptors.response.use( ...@@ -53,7 +53,7 @@ service.interceptors.response.use(
* Here is just an example * Here is just an example
* You can also judge the status by HTTP Status Code * You can also judge the status by HTTP Status Code
*/ */
async response => { async (response) => {
// do something with response data // do something with response data
const res = response.data; const res = response.data;
endLoading(); endLoading();
...@@ -66,7 +66,7 @@ service.interceptors.response.use( ...@@ -66,7 +66,7 @@ service.interceptors.response.use(
Vue.prototype.$dataStore.delete("user"); Vue.prototype.$dataStore.delete("user");
Vue.prototype.$message.error({ Vue.prototype.$message.error({
showClose: true, showClose: true,
message: res.msg || res.message || "Error" message: res.msg || res.message || "Error",
}); });
setTimeout(() => { setTimeout(() => {
location.reload(); location.reload();
...@@ -81,7 +81,7 @@ service.interceptors.response.use( ...@@ -81,7 +81,7 @@ service.interceptors.response.use(
} }
Vue.prototype.$message.error({ Vue.prototype.$message.error({
showClose: true, showClose: true,
message: res.msg || res.message || "Error" message: res.msg || res.message || "Error",
}); });
// reject // reject
return Promise.reject(new Error(res.msg || res.message || "Error")); return Promise.reject(new Error(res.msg || res.message || "Error"));
...@@ -91,7 +91,7 @@ service.interceptors.response.use( ...@@ -91,7 +91,7 @@ service.interceptors.response.use(
} }
return Promise.resolve(res); return Promise.resolve(res);
}, },
error => { (error) => {
endLoading(); endLoading();
// do something with response error // do something with response error
return Promise.reject(error); return Promise.reject(error);
...@@ -99,3 +99,4 @@ service.interceptors.response.use( ...@@ -99,3 +99,4 @@ service.interceptors.response.use(
); );
export default service; export default service;
export { startLoading, endLoading };
...@@ -22,13 +22,15 @@ export const grid = [ ...@@ -22,13 +22,15 @@ export const grid = [
value: 1, value: 1,
row: 16, row: 16,
col: 18, col: 18,
h: 542, // h: 540,
w: 482 // w: 480,
} h: 0,
w: 0,
},
// { // {
// label: '16×21', // label: '16×21',#77797a
// value: 0, // value: 0,
// col: 16, // col: 16,
// row: 21 // row: 21
// } // }
]; ];
\ No newline at end of file
...@@ -5,8 +5,10 @@ import { ipcRenderer } from "electron"; ...@@ -5,8 +5,10 @@ import { ipcRenderer } from "electron";
import { grid } from "../data"; import { grid } from "../data";
import pkg from "../../../../package.json"; import pkg from "../../../../package.json";
import UpdateDialog from "@/views/design/updateDialog.vue"; 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";
const uuid = require("uuid");
const fs = require("fs");
export default { export default {
components: { PrintDialog, UpdateDialog }, components: { PrintDialog, UpdateDialog },
...@@ -23,6 +25,7 @@ export default { ...@@ -23,6 +25,7 @@ export default {
return { return {
checkList: [], checkList: [],
desktopDevice: 1, desktopDevice: 1,
checked: false,
cacheList: [ cacheList: [
{ {
label: "清除当前登录信息", label: "清除当前登录信息",
...@@ -216,6 +219,9 @@ export default { ...@@ -216,6 +219,9 @@ export default {
} }
); );
this.detail = findByPodProductionNo.data; this.detail = findByPodProductionNo.data;
console.log(219, this.detail);
this.$store.commit("setProductDetail", findByPodProductionNo.data);
ipcRenderer.send("win-subScreen", findByPodProductionNo.data); ipcRenderer.send("win-subScreen", findByPodProductionNo.data);
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示 // 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
...@@ -223,7 +229,6 @@ export default { ...@@ -223,7 +229,6 @@ export default {
this.detail.id, this.detail.id,
this.$store.state.desktopDevice, this.$store.state.desktopDevice,
]); ]);
console.log("res111", res);
this.imgList = []; this.imgList = [];
res.data.forEach((el) => { res.data.forEach((el) => {
this.imgList = this.imgList.concat(el.list || []); this.imgList = this.imgList.concat(el.list || []);
...@@ -240,9 +245,13 @@ export default { ...@@ -240,9 +245,13 @@ export default {
}); });
} }
}); });
console.log(arr, "arr");
res.data = arr.filter((el) => el.type !== 1); res.data = arr.filter((el) => el.type !== 1);
let newImgList;
if (this.checked) {
newImgList = await this.cutImgFn(res.data);
} else {
newImgList = res.data;
}
// 延迟后强制激活窗口 // 延迟后强制激活窗口
if (this.desktopDevice !== 1) { if (this.desktopDevice !== 1) {
if (this.imgList.length) { if (this.imgList.length) {
...@@ -261,7 +270,7 @@ export default { ...@@ -261,7 +270,7 @@ export default {
console.log(260, res.data); console.log(260, res.data);
let obj = { let obj = {
type: "sendFile", type: "sendFile",
value: res.data, value: newImgList,
} }
if(this.detail.mssWidth && this.detail.mssHeight){ if(this.detail.mssWidth && this.detail.mssHeight){
obj.size = { width: this.detail.mssWidth, height: this.detail.mssHeight } obj.size = { width: this.detail.mssWidth, height: this.detail.mssHeight }
...@@ -356,6 +365,48 @@ export default { ...@@ -356,6 +365,48 @@ export default {
this.$store.commit("changeImgList", []); this.$store.commit("changeImgList", []);
console.log(347, store.state.desktopDevice); console.log(347, store.state.desktopDevice);
}, },
async cutImgFn(arr) {
if (!arr.length) return;
try {
const processQueue = await Promise.all(
arr.map(async (el) => {
try {
const outputDir = path.dirname(el.productionFile);
const outputFileName = `${uuid.v4()}.png`;
const outputPath = path.join(outputDir, outputFileName);
const params = {
inputPath: el.productionFile,
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,
};
} catch (error) {
console.error(`处理失败: ${el.productionFile}`, error);
}
})
);
// 等待所有异步操作完成
await new Promise((resolve) => setTimeout(resolve, 100));
const newMap = new Map(processQueue.map((el) => [el.designId, el]));
processQueue.forEach((el) => {
if (newMap.has(el.designId)) {
el.fileName = newMap.get(el.designId).fileName;
el.productionFile = newMap.get(el.designId).productionFile;
}
});
console.log("processQueue", processQueue);
return processQueue;
} catch (error) {
console.error("错误", error);
return [];
}
},
}, },
}; };
</script> </script>
...@@ -596,6 +647,9 @@ export default { ...@@ -596,6 +647,9 @@ export default {
<el-checkbox v-model="isAutoFinish">自动完成上一单</el-checkbox> <el-checkbox v-model="isAutoFinish">自动完成上一单</el-checkbox>
</div> </div>
</div> </div>
<div style="margin-left: 10px;">
<el-checkbox v-model="checked">自动裁切素材</el-checkbox>
</div>
<el-button <el-button
@click="downloadImage" @click="downloadImage"
size="medium" size="medium"
......
...@@ -6,6 +6,7 @@ import html2canvas from "html2canvas"; ...@@ -6,6 +6,7 @@ import html2canvas from "html2canvas";
import moment from "moment"; import moment from "moment";
import pkg from "../../../../package.json"; import pkg from "../../../../package.json";
import { pxToUnit } from "../../../utils/index"; import { pxToUnit } from "../../../utils/index";
import { mapState } from "vuex";
export default { export default {
data() { data() {
...@@ -123,6 +124,7 @@ export default { ...@@ -123,6 +124,7 @@ export default {
return "1.5"; return "1.5";
} }
}, },
...mapState(["WHproportion"]),
}, },
watch: { watch: {
printSetting: { printSetting: {
...@@ -300,11 +302,11 @@ export default { ...@@ -300,11 +302,11 @@ export default {
const relativeY = imageRect.top - lineRect.top; const relativeY = imageRect.top - lineRect.top;
console.log(dom_id); console.log(dom_id);
// 获取图片的宽高 // 获取图片的宽高
let w = image.clientWidth; // 图片宽 let w = image.clientWidth / this.WHproportion; // 图片宽
let h = image.clientHeight; // 图片高 let h = image.clientHeight / this.WHproportion; // 图片高
console.log(w, h, "w,h"); console.log(w, h, "w,h");
const x = relativeX; const x = relativeX / this.WHproportion;
const y = relativeY; const y = relativeY / this.WHproportion;
const r = this.imgList[0].r; const r = this.imgList[0].r;
console.log(w, h); console.log(w, h);
const x_mm = this.pxToUnit(x, "mm"); const x_mm = this.pxToUnit(x, "mm");
...@@ -370,12 +372,13 @@ export default { ...@@ -370,12 +372,13 @@ export default {
y = this.numberToStr4(y); y = this.numberToStr4(y);
w = this.numberToStr4(w); w = this.numberToStr4(w);
h = this.numberToStr4(h); h = this.numberToStr4(h);
console.log("print", x, y, w, h); console.log("print", w, h);
// console.log(x, "x"); if (w > 4200 || h > 4700) {
// console.log(y, "y"); return this.$message.warning(
// console.log(w, "w"); "打印图片素材宽度不能超过410mm,长度不能超过450mm"
// console.log(h, "h"); );
}
r = Number(r).toFixed(0); r = Number(r).toFixed(0);
const imgFileName = this.imgList[0].fileName; const imgFileName = this.imgList[0].fileName;
let position = ""; // 位置 let position = ""; // 位置
......
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