Commit 0a3ee7dc by linjinhong

Merge remote-tracking branch 'origin/test' into ljh

parents e5f73622 f3919697
......@@ -2,12 +2,12 @@ import {
downloadImage,
downloadOtherImage,
toSend,
writeProfileXml,
writeProfileXml
} from "@/server/utils";
const {
cropImageTransparentEdges,
cropTransparentEdges,
processImages,
processImages
} = require("../utils/setImage");
import axios from "axios";
import { returnLogFilePath } from "../utils/log";
......@@ -15,13 +15,11 @@ var request = require("request");
const compressing = require("compressing");
const uuid = require("uuid");
const path = require("path");
const fs = require("fs");
const os = require("os");
const { app } = require("electron");
let fileEnv, env, visionUrl;
axios.defaults.timeout = 12600000;
const multiparty = require("multiparty");
function readEnv() {
......@@ -73,7 +71,7 @@ export default {
const token = req.headers["jwt-token"];
try {
let {
data,
data
} = await axios.post(
`${env}/factory/podJomallOrder/downloadByProduction`,
[req.body[0]],
......@@ -83,26 +81,26 @@ export default {
if (data.code === 200) {
files = data.data;
files = files.map((el) => {
files = files.map(el => {
return { url: `${fileEnv}${el}` };
});
if (req.body[1] === 1) {
downloadImage(files)
.then((data) => {
.then(data => {
res.json({ code: 200, data });
})
.catch((err) => {
.catch(err => {
res.json({ code: 500, msg: err });
});
} else {
downloadOtherImage(files)
.then((data) => {
.then(data => {
console.log(77, data);
res.json({ code: 200, data });
})
.catch((err) => {
.catch(err => {
res.json({ code: 500, msg: err });
});
}
......@@ -122,7 +120,7 @@ export default {
`${env}/factory/podJomallOrderProduct/getSubOrderByThirdSubOrderNumber`,
{
params: q,
headers: { "jwt-token": token },
headers: { "jwt-token": token }
}
);
res.json(data);
......@@ -146,7 +144,7 @@ export default {
const token = req.headers["jwt-token"];
try {
let {
data,
data
} = await axios.post(
`${env}/factory/podJomallOrderProduct/completeDelivery`,
req.body,
......@@ -179,7 +177,7 @@ export default {
console.log("success");
res.json({
code: 200,
msg: q.productionNo + ".zip" + "已下载到桌面",
msg: q.productionNo + ".zip" + "已下载到桌面"
});
})
.on("error", () => {
......@@ -221,8 +219,8 @@ export default {
code: 200,
data: {
fileName,
url: path.join(process.cwd(), "./print/Input/" + fileName),
},
url: path.join(process.cwd(), "./print/Input/" + fileName)
}
});
}
});
......@@ -274,10 +272,10 @@ export default {
console.log(249, body);
toSend(body)
.then((r) => {
.then(r => {
res.send({ code: 200, msg: "操作成功" });
})
.catch((err) => {
.catch(err => {
res.send({ code: 500, msg: err });
});
},
......@@ -316,7 +314,7 @@ export default {
fs.unlinkSync(from);
res.json({ code: 200, msg: "更新成功" });
})
.catch((err) => {
.catch(err => {
res.json({ code: 500, msg: err.message });
});
});
......@@ -357,4 +355,33 @@ export default {
res.json({ code: 500, msg: err.message });
}
},
saveToPng: async (req, res) => {
try {
const p = path.join(process.cwd(), "./print/Input/");
const form = new multiparty.Form({ uploadDir: p });
form.parse(req, function(err, fields, files) {
console.log(fields, files, err);
if (err) {
res.send({ code: 500, err });
} else {
let list = [];
files.files.forEach(file => {
let fileName = uuid.v4() + ".png";
fs.renameSync(file.path, path.join(p, fileName));
list.push({
fileName,
url: path.join(process.cwd(), "./print/Input/" + fileName)
});
});
res.json({
code: 200,
data: list
});
}
});
} catch (err) {
console.log(err);
res.json({ code: 500, msg: err });
}
}
};
......@@ -37,4 +37,7 @@ router.post("/imageListTransparentEdges", fn.imageListTransparentEdges);
// 处理图片并输出结果
router.post("/processImage", fn.processImage);
// 保存生成后得图片返回地址
router.post("/saveToPng", fn.saveToPng);
export { router as default };
......@@ -131,6 +131,7 @@ export default {
actionList: [],
checkList: [],
oldImgList: [],
hasSize: false,
parentWidth: 0,
backColor: "#77797a",
systemSetting: {},
......@@ -361,12 +362,24 @@ export default {
return mm1.width;
},
setDesignImg(title) {
let img = this.selectImgList.find((it) => it.title === title);
if (img) {
console.log(this.detail.designImageSize, "this.detail.size");
this.getBackFile(
{ files: [img], size: this.detail.designImageSize },
(file) => {
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
}
);
}
},
selectImg(it, i) {
// this.selectImgIndexList.push(i)
let item = this.imgList.find((img) => img.fileName === it.fileName);
if (item) return;
// this.selectImgIndexList = Array.from(new Set(this.selectImgIndexList))
this.getBackFile({ files: [it] }, (file) => {
this.getBackFile({ files: [it], size: null }, (file) => {
this.imgHistoryList.push(JSON.parse(JSON.stringify(this.imgList)));
});
},
......@@ -521,18 +534,29 @@ export default {
};
});
},
getComputedName(title) {
let img = this.selectImgList.find((it) => it.title === title);
return img?.fileName;
},
getComputedTitle(title) {
console.log(this.selectImgList, "this.selectImgList");
let img = this.selectImgList.find((it) => it.title === title);
return img?.url;
},
getBackFile({ files, size }, callback) {
let that = this;
let bw = document.getElementById("line").clientWidth;
let bw = window.getComputedStyle(
document.getElementsByClassName("grid")[0]
).width;
bw = Number(bw.replace("px", ""));
for (let i = 0; i < files.length; i++) {
files[i].url = files[i].productionFile;
files[i].url = files[i].productionFile || files[i].url;
that.$nextTick(async () => {
let w = document.getElementById("line").clientWidth / 2;
let w = bw / 2;
let width_px, height_px, rate;
if (size) {
width_px = mmToPx(size.width);
height_px = mmToPx(size.height);
console.log(width_px, height_px, "w,h");
rate = height_px / width_px;
} else {
let data = await that.getImageSize(files[i].url);
......@@ -778,21 +802,26 @@ export default {
});
break;
case "sendFile":
// if (size.width && size.height) {
// this.hasSize = true;
// } else {
// this.hasSize = false;
// }
console.log("sendFile");
if (size) {
this.hasSize = true;
} else {
this.hasSize = false;
}
this.detail.designImageSize = size;
this.imgList = [];
this.selectIndex = -1;
if (value.length > 0) {
this.selectImgList = value;
this.selectImgIndex = 0;
this.getBackFile({ files: [value[0]], size }, (file) => {
this.imgHistoryList.push(
JSON.parse(JSON.stringify(this.imgList))
);
});
this.getBackFile(
{ files: [value[0]], size: this.detail.designImageSize || null },
(file) => {
this.imgHistoryList.push(
JSON.parse(JSON.stringify(this.imgList))
);
}
);
// this.addFile([value[0].file])
}
break;
......@@ -912,6 +941,27 @@ export default {
</el-col>
</el-row>
</el-row>
<el-table border :data="detail.imageAry">
<el-table-column label="打印区域" prop="title"></el-table-column>
<el-table-column label="效果图" prop="title">
<template slot-scope="{ row }">
<img class="full-width" :src="row.url" alt="" />
</template>
</el-table-column>
<el-table-column label="素材图" prop="title">
<template slot-scope="{ row }">
<img
style="cursor: pointer"
@click="setDesignImg(row.title)"
v-if="getComputedTitle(row.title)"
class="full-width"
:src="getComputedTitle(row.title)"
alt=""
/>
<span>{{ getComputedName(row.title) }}</span>
</template>
</el-table-column>
</el-table>
</div>
<div class="product-information">
<div class="title">
......@@ -1150,6 +1200,15 @@ export default {
</div>
</div>
</div>
<div
class="print-tip"
v-if="detail && detail.designImageSize && selectImgList.length"
>
<b style="color: green" v-if="hasSize"
>该生产单无需拖动设计,直接打印</b
>
<b style="color: red" v-else>该生产单需要拖动设计打印</b>
</div>
</div>
<img
......
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