Commit e774c720 by linjinhong

新增下载原素材按钮以及完成上一单提示

parent 97e0fb09
{ {
"apiApiHost":"http://10.168.31.142:8060/api", "apiApiHost":"https://factory.jomalls.com/api",
"fileApiUrl":"http://10.168.31.142:80/upload/factory", "fileApiUrl":"https://factory.jomalls.com/upload/factory",
"visionUrl":"https://console.jomalls.com" "visionUrl":"https://console.jomalls.com"
} }
...@@ -17,33 +17,34 @@ export default { ...@@ -17,33 +17,34 @@ export default {
user: { user: {
default: { default: {
avatar: "", avatar: "",
factory: {} factory: {},
}, },
type: Object type: Object,
} },
}, },
data() { data() {
return { return {
checkList: [], checkList: [],
desktopDevice: 1, desktopDevice: 1,
checked: false, checked: false,
isFirst: true,
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,
...@@ -58,7 +59,7 @@ export default { ...@@ -58,7 +59,7 @@ export default {
unit: "mm", unit: "mm",
language: "cn", language: "cn",
autoPrint: false, autoPrint: false,
gridSpacing: 10 gridSpacing: 10,
}, },
imgList: [], imgList: [],
detail: null, detail: null,
...@@ -77,15 +78,15 @@ export default { ...@@ -77,15 +78,15 @@ 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",
], ],
grid grid,
}; };
}, },
computed: { computed: {
actionList() { actionList() {
return this.$store.getters.getActionList; return this.$store.getters.getActionList;
} },
}, },
mounted() { mounted() {
// console.log(pkg, "pkg"); // console.log(pkg, "pkg");
...@@ -106,12 +107,12 @@ export default { ...@@ -106,12 +107,12 @@ export default {
this.$dataStore.set("setting", this.setting); this.$dataStore.set("setting", this.setting);
bus.$emit("busEmit", { type: "updateSystemSetting" }); bus.$emit("busEmit", { type: "updateSystemSetting" });
}, },
deep: true deep: true,
} },
}, },
methods: { methods: {
checkUpdate() { checkUpdate() {
this.$refs.updateDialog.checkUpdate().then(data => { this.$refs.updateDialog.checkUpdate().then((data) => {
if (data) { if (data) {
// 有新版本更新 // 有新版本更新
this.$refs.updateDialog.open(data); this.$refs.updateDialog.open(data);
...@@ -126,7 +127,7 @@ export default { ...@@ -126,7 +127,7 @@ export default {
this.$confirm("是否退出登录?", "提示", { this.$confirm("是否退出登录?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning",
}) })
.then(() => { .then(() => {
this.$dataStore.delete("user"); this.$dataStore.delete("user");
...@@ -153,7 +154,7 @@ export default { ...@@ -153,7 +154,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);
}); });
...@@ -165,15 +166,15 @@ export default { ...@@ -165,15 +166,15 @@ 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) {
if (k === "print-setting" || k === "deviceId") { if (k === "print-setting" || k === "deviceId") {
let list = Object.keys(this.$dataStore.store).filter(el => let list = Object.keys(this.$dataStore.store).filter((el) =>
el.includes(k) el.includes(k)
); );
list.forEach(el => { list.forEach((el) => {
this.$dataStore.delete(el); this.$dataStore.delete(el);
}); });
} else if (k === "token") { } else if (k === "token") {
...@@ -194,9 +195,9 @@ export default { ...@@ -194,9 +195,9 @@ export default {
try { try {
axios axios
.get(item?.src, { .get(item?.src, {
responseType: "blob" responseType: "blob",
}) })
.then(res => { .then((res) => {
var url = URL.createObjectURL(res.data); var url = URL.createObjectURL(res.data);
let img = new Image(); let img = new Image();
img.crossorigin = ""; img.crossorigin = "";
...@@ -215,7 +216,7 @@ export default { ...@@ -215,7 +216,7 @@ export default {
resolve(); resolve();
}; };
}) })
.catch(e => { .catch((e) => {
console.log(e); console.log(e);
reject(e); reject(e);
}); });
...@@ -235,7 +236,7 @@ export default { ...@@ -235,7 +236,7 @@ export default {
canvas.width = canvasItem.canvasWidth; canvas.width = canvasItem.canvasWidth;
canvas.height = canvasItem.canvasHeight; canvas.height = canvasItem.canvasHeight;
let objects = canvasItem.options.objects.filter( let objects = canvasItem.options.objects.filter(
el => el.type === "image" (el) => el.type === "image"
); );
let list = []; let list = [];
for (let i in objects) { for (let i in objects) {
...@@ -269,7 +270,7 @@ export default { ...@@ -269,7 +270,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);
...@@ -286,17 +287,24 @@ export default { ...@@ -286,17 +287,24 @@ export default {
if (this.productionNo === "") if (this.productionNo === "")
return this.$message.warning("请录入生产单号"); return this.$message.warning("请录入生产单号");
if (!this.isAutoFinish && !this.isFirst)
this.$confirm("请注意自动完成上一单未勾选", "提示", {
confirmButtonText: "确定",
type: "warning",
});
try { try {
//查找生产单号信息传给第二个显示器 //查找生产单号信息传给第二个显示器
const findByPodProductionNo = await this.$api.post( const findByPodProductionNo = await this.$api.post(
"/findByPodProductionNo", "/findByPodProductionNo",
{ {
thirdSubOrderNumber: this.productionNo thirdSubOrderNumber: this.productionNo,
} }
); );
this.detail = findByPodProductionNo.data; this.detail = findByPodProductionNo.data;
let imageResList = []; let imageResList = [];
let designImagesCanvasJsonList = this.detail.drParam; let designImagesCanvasJsonList = this.detail.drParam;
if (designImagesCanvasJsonList) { if (designImagesCanvasJsonList) {
designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList); designImagesCanvasJsonList = JSON.parse(designImagesCanvasJsonList);
let imageList = await this.canvasToImage(designImagesCanvasJsonList); let imageList = await this.canvasToImage(designImagesCanvasJsonList);
...@@ -314,9 +322,9 @@ export default { ...@@ -314,9 +322,9 @@ export default {
this.imgList = []; this.imgList = [];
if (this.checked) { if (this.checked) {
imageResList = await this.cutImgFn(imageResList); imageResList = await this.cutImgFn(imageResList);
imageResList.forEach(el=>{ imageResList.forEach((el) => {
el.isCut = true el.isCut = true;
}) });
} }
} }
this.$store.commit("setProductDetail", findByPodProductionNo.data); this.$store.commit("setProductDetail", findByPodProductionNo.data);
...@@ -325,7 +333,7 @@ export default { ...@@ -325,7 +333,7 @@ export default {
if (imageResList && imageResList.length) { if (imageResList && imageResList.length) {
let obj = { let obj = {
type: "sendFile", type: "sendFile",
value: imageResList value: imageResList,
}; };
if ( if (
this.detail.mssWidth && this.detail.mssWidth &&
...@@ -334,7 +342,7 @@ export default { ...@@ -334,7 +342,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);
...@@ -342,29 +350,29 @@ export default { ...@@ -342,29 +350,29 @@ export default {
// 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示 // 根据生产单号查找 素材图片 下载到本地 然后返回本地地址去显示
let res = await this.$api.post("/downloadBySubOrderNumber", [ let res = await this.$api.post("/downloadBySubOrderNumber", [
this.detail.id, this.detail.id,
this.$store.state.desktopDevice this.$store.state.desktopDevice,
]); ]);
if (res.data.length === 0) if (res.data.length === 0)
return this.$message.warning("未找到素材图!"); return this.$message.warning("未找到素材图!");
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 || []);
}); });
let arr = []; let arr = [];
res.data.forEach(el => { res.data.forEach((el) => {
if (el.list) { if (el.list) {
el.list.forEach(it => { el.list.forEach((it) => {
arr.push(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.checked) { if (this.checked) {
newImgList = await this.cutImgFn(res.data); newImgList = await this.cutImgFn(res.data);
newImgList.forEach(el=>{ newImgList.forEach((el) => {
el.isCut = true el.isCut = true;
}) });
} else { } else {
newImgList = res.data; newImgList = res.data;
} }
...@@ -386,7 +394,7 @@ export default { ...@@ -386,7 +394,7 @@ export default {
console.log(260, res.data); console.log(260, res.data);
let obj = { let obj = {
type: "sendFile", type: "sendFile",
value: newImgList value: newImgList,
}; };
if ( if (
this.detail.mssWidth && this.detail.mssWidth &&
...@@ -395,7 +403,7 @@ export default { ...@@ -395,7 +403,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);
...@@ -408,6 +416,8 @@ export default { ...@@ -408,6 +416,8 @@ export default {
console.log(err); console.log(err);
this.productionNo = ""; this.productionNo = "";
this.$refs.searchRef.focus(); this.$refs.searchRef.focus();
} finally {
this.isFirst = false;
} }
}, },
// // 聚焦资源管理器窗口(Windows) // // 聚焦资源管理器窗口(Windows)
...@@ -417,7 +427,7 @@ export default { ...@@ -417,7 +427,7 @@ export default {
const command = `start explorer /select, "${path}"`; const command = `start explorer /select, "${path}"`;
// 检查路径是否存在 // 检查路径是否存在
if (fs.existsSync(path)) { if (fs.existsSync(path)) {
exec(`cmd /c "${command}"`, err => { exec(`cmd /c "${command}"`, (err) => {
if (err) console.error("激活窗口失败:", err); if (err) console.error("激活窗口失败:", err);
}); });
} else { } else {
...@@ -445,7 +455,7 @@ export default { ...@@ -445,7 +455,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("重置应用程序设置成功");
}, },
...@@ -466,8 +476,8 @@ export default { ...@@ -466,8 +476,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;
...@@ -477,7 +487,7 @@ export default { ...@@ -477,7 +487,7 @@ export default {
this.setting.gridValue = i; this.setting.gridValue = i;
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] });
}, },
...@@ -493,21 +503,21 @@ export default { ...@@ -493,21 +503,21 @@ export default {
if (!arr.length) return; if (!arr.length) return;
try { try {
const processQueue = await Promise.all( const processQueue = await Promise.all(
arr.map(async el => { arr.map(async (el) => {
try { try {
const outputDir = path.dirname(el.productionFile); const outputDir = path.dirname(el.productionFile);
const outputFileName = `${uuid.v4()}.png`; const outputFileName = `${uuid.v4()}.png`;
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 designId: el.designId,
}; };
} catch (error) { } catch (error) {
console.error(`处理失败: ${el.productionFile}`, error); console.error(`处理失败: ${el.productionFile}`, error);
...@@ -516,9 +526,9 @@ export default { ...@@ -516,9 +526,9 @@ export default {
); );
// 等待所有异步操作完成 // 等待所有异步操作完成
await new Promise(resolve => setTimeout(resolve, 100)); await new Promise((resolve) => setTimeout(resolve, 100));
const newMap = new Map(processQueue.map(el => [el.designId, el])); const newMap = new Map(processQueue.map((el) => [el.designId, el]));
processQueue.forEach(el => { processQueue.forEach((el) => {
if (newMap.has(el.designId)) { if (newMap.has(el.designId)) {
el.fileName = newMap.get(el.designId).fileName; el.fileName = newMap.get(el.designId).fileName;
el.productionFile = newMap.get(el.designId).productionFile; el.productionFile = newMap.get(el.designId).productionFile;
...@@ -530,8 +540,8 @@ export default { ...@@ -530,8 +540,8 @@ export default {
console.error("错误", error); console.error("错误", error);
return []; return [];
} }
} },
} },
}; };
</script> </script>
<style scoped> <style scoped>
...@@ -649,7 +659,7 @@ export default { ...@@ -649,7 +659,7 @@ export default {
> >
<el-form-item prop="setting" label="网格显示"> <el-form-item prop="setting" label="网格显示">
<el-select <el-select
@change="e => settingChange('gridShow', e)" @change="(e) => settingChange('gridShow', e)"
clearable clearable
v-model="setting.gridShow" v-model="setting.gridShow"
> >
...@@ -659,7 +669,7 @@ export default { ...@@ -659,7 +669,7 @@ export default {
</el-form-item> </el-form-item>
<el-form-item prop="gridSpacing" label="单位"> <el-form-item prop="gridSpacing" label="单位">
<el-select <el-select
@change="e => settingChange('unit', e)" @change="(e) => settingChange('unit', e)"
clearable clearable
v-model="setting.unit" v-model="setting.unit"
> >
...@@ -669,7 +679,7 @@ export default { ...@@ -669,7 +679,7 @@ export default {
</el-form-item> </el-form-item>
<el-form-item prop="gridSpacing" label="网格间隔"> <el-form-item prop="gridSpacing" label="网格间隔">
<el-select <el-select
@change="e => settingChange('gridSpacing', e)" @change="(e) => settingChange('gridSpacing', e)"
clearable clearable
v-model="setting.gridSpacing" v-model="setting.gridSpacing"
> >
...@@ -697,7 +707,7 @@ export default { ...@@ -697,7 +707,7 @@ export default {
</el-form-item> </el-form-item>
<el-form-item prop="language" label="语言设置"> <el-form-item prop="language" label="语言设置">
<el-select <el-select
@change="e => settingChange('language', e)" @change="(e) => settingChange('language', e)"
clearable clearable
v-model="setting.language" v-model="setting.language"
> >
......
...@@ -813,6 +813,33 @@ export default { ...@@ -813,6 +813,33 @@ export default {
} }
this.$store.commit("setIsPreView", this.isView); this.$store.commit("setIsPreView", this.isView);
}, },
async downloadImg() {
let res = await this.$api.post("/downloadBySubOrderNumber", [
this.detail.id,
this.$store.state.desktopDevice,
]);
if (res.data.length === 0) return this.$message.warning("未找到素材图!");
let imgList = [];
res.data.forEach((el) => {
imgList = 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);
this.selectImgList = [...res.data];
console.log(823, this.selectImgList);
this.imgList = [];
this.selectIndex = -1;
this.selectImgIndex = 0;
this.getBackFile({ files: [this.selectImgList[0]] });
},
}, },
mounted() { mounted() {
this.imgHeight = window.screen.height + "px"; this.imgHeight = window.screen.height + "px";
...@@ -1025,14 +1052,24 @@ export default { ...@@ -1025,14 +1052,24 @@ export default {
</PicScrollbarBox> </PicScrollbarBox>
<PicScrollbarBox boxTitle="素材图" emptyTitle="素材图为空"> <PicScrollbarBox boxTitle="素材图" emptyTitle="素材图为空">
<template #titleRight> <template #titleRight>
<el-button <div>
type="primary" <el-button
size="small" type="primary"
v-if="selectImgList.length" size="small"
style="margin: 10px;" v-if="selectImgList.length"
@click="cutImgFn" style="margin: 5px;"
>裁切</el-button @click="downloadImg"
> >下载原素材</el-button
>
<el-button
type="primary"
size="small"
v-if="selectImgList.length"
style="margin: 5px;"
@click="cutImgFn"
>裁切</el-button
>
</div>
</template> </template>
<template #mainContent> <template #mainContent>
<div <div
......
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