Commit e774c720 by linjinhong

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

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