Commit 4dfa24d6 by linjinhong

feat:添加监听

parent b0182596
...@@ -80,13 +80,13 @@ module.exports = { ...@@ -80,13 +80,13 @@ module.exports = {
if (newData instanceof Map) { if (newData instanceof Map) {
newObjArray = mapToArray(newData); newObjArray = mapToArray(newData);
} else if (Array.isArray(newData)) { } else if (Array.isArray(newData)) {
const isValidObjArray = newData.every( // const isValidObjArray = newData.every(
(item) => typeof item === "object" && item !== null, // (item) => typeof item === "object" && item !== null,
); // );
if (!isValidObjArray) { // if (!isValidObjArray) {
console.warn("setOrderInfo 要求数组内所有元素都是对象类型"); // console.warn("setOrderInfo 要求数组内所有元素都是对象类型");
return; // return;
} // }
newObjArray = newData; newObjArray = newData;
} else { } else {
console.warn("setOrderInfo 要求传入数组或 Map 类型,当前传入值无效"); console.warn("setOrderInfo 要求传入数组或 Map 类型,当前传入值无效");
......
...@@ -3,7 +3,8 @@ import bus from "@/bus"; ...@@ -3,7 +3,8 @@ import bus from "@/bus";
// import PrintDialog from "./printDialog.vue"; // import PrintDialog from "./printDialog.vue";
// import { getProductCnByFactorySubOrderNumberApi } from "../../../api/index.js"; // import { getProductCnByFactorySubOrderNumberApi } from "../../../api/index.js";
import { ipcRenderer } from "electron"; import { ipcRenderer } from "electron";
// import { grid } from "../data"; import { copySingleImage } from "@/server/utils/index.js";
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 模块
...@@ -23,6 +24,8 @@ const { ...@@ -23,6 +24,8 @@ const {
addToOrderInfo, addToOrderInfo,
updateOrderInfoItem, updateOrderInfoItem,
removeFromOrderInfo, removeFromOrderInfo,
setOrderInfo,
getLocation,
} = require("@/server/utils/store"); } = require("@/server/utils/store");
export default { export default {
...@@ -151,6 +154,38 @@ export default { ...@@ -151,6 +154,38 @@ export default {
desktopDevice(val) { desktopDevice(val) {
this.checked = false; this.checked = false;
}, },
imgList: {
handler(value) {
if (this.detail && value?.length && this.desktopDevice === 3) {
const item = this.detail?.saveImgList?.find(
(el) => el.fileName == value[0].fileName,
);
if (item) {
item.power = true;
try {
copySingleImage(
item.productionFile,
getLocation("downloadLocation1"),
);
copySingleImage(
item.productionFile,
getLocation("downloadLocation2"),
);
this.$message.success("图片已发送目标文件夹下");
} catch (error) {
this.$message.error("发送失败");
console.log(error);
}
updateOrderInfoItem(this.detail.newId, this.detail);
}
console.log("updateOrderInfoItemitem", item);
console.log("本地数据updateOrderInfoItem:", getOrderInfo());
}
},
// deep: true,
},
}, },
methods: { methods: {
checkUpdate() { checkUpdate() {
...@@ -201,7 +236,7 @@ export default { ...@@ -201,7 +236,7 @@ export default {
if (canCallApi) { if (canCallApi) {
console.log("生产完成数据", data); console.log("生产完成数据", data);
console.log("本地数据:", getOrderInfo()); console.log("本地数据removeFromOrderInfo:", getOrderInfo());
removeFromOrderInfo(data.newId); removeFromOrderInfo(data.newId);
return; return;
await this.$api.post("/completeDelivery", params); await this.$api.post("/completeDelivery", params);
...@@ -393,7 +428,7 @@ export default { ...@@ -393,7 +428,7 @@ export default {
orderType: this.orderType, orderType: this.orderType,
}); });
console.log("downloadBySubOrderNumber", res); // console.log("downloadBySubOrderNumber", res);
if (!res.data.length) return this.$message.warning("未找到素材图!"); if (!res.data.length) return this.$message.warning("未找到素材图!");
res.data.forEach((el) => { res.data.forEach((el) => {
...@@ -401,6 +436,7 @@ export default { ...@@ -401,6 +436,7 @@ export default {
}); });
} else if (bool) { } else if (bool) {
imageResList = this.detail?.saveImgList || []; imageResList = this.detail?.saveImgList || [];
console.log("imageResList", imageResList);
} }
if (this.checked) { if (this.checked) {
...@@ -473,29 +509,22 @@ export default { ...@@ -473,29 +509,22 @@ export default {
height: this.detail.mssHeight, height: this.detail.mssHeight,
}; };
} }
if (newImgList.length > 1 && !bool) { if (!this.detail["saveImgList"]?.length) {
const templateobj = { ...this.detail }; this.detail["saveImgList"] = [...newImgList].map((el) => {
templateobj["saveImgList"] = [...newImgList].map((el) => {
el.power = false; el.power = false;
return { ...el }; return { ...el };
}); });
addToOrderInfo(templateobj); }
console.log("本地数据:", getOrderInfo());
if (newImgList.length > 1 && !bool) {
addToOrderInfo(this.detail);
console.log("本地数据addToOrderInfo", getOrderInfo());
} }
bus.$emit("busEmit", obj); bus.$emit("busEmit", obj);
} }
}, },
async getDataInfo() { async getDataInfo() {
if (this.detail && this.imgList?.length && this.desktopDevice === 3) {
const item = this.detail?.saveImgList?.find(
(el) => el.fileName == this.imgList[0].fileName,
);
if (item) item.power = true;
updateOrderInfoItem(this.detail.newId, this.detail);
console.log("本地数据:", getOrderInfo());
}
if ( if (
this.detail && this.detail &&
Object.keys(this.detail).length > 0 && Object.keys(this.detail).length > 0 &&
...@@ -542,7 +571,9 @@ export default { ...@@ -542,7 +571,9 @@ export default {
try { try {
const arr = await getOrderInfo(); const arr = await getOrderInfo();
const localItem = getOrderInfoItem(this.productionNo); const localItem = getOrderInfoItem(this.productionNo)
? { data: getOrderInfoItem(this.productionNo) }
: null;
let findByPodProductionNo; let findByPodProductionNo;
const apiRequestParams = { const apiRequestParams = {
...@@ -553,7 +584,7 @@ export default { ...@@ -553,7 +584,7 @@ export default {
if (this.desktopDevice === 3) { if (this.desktopDevice === 3) {
if (arr.length > 0) { if (arr.length > 0) {
findByPodProductionNo = findByPodProductionNo =
{ data: { ...localItem } } || localItem ||
(await this.$api.post( (await this.$api.post(
"/findByPodProductionNo", "/findByPodProductionNo",
apiRequestParams, apiRequestParams,
...@@ -571,8 +602,6 @@ export default { ...@@ -571,8 +602,6 @@ export default {
); );
} }
console.log("findByPodProductionNo", findByPodProductionNo);
this.detail = findByPodProductionNo.data; this.detail = findByPodProductionNo.data;
this.detail["newId"] = this.productionNo; this.detail["newId"] = this.productionNo;
...@@ -814,6 +843,9 @@ export default { ...@@ -814,6 +843,9 @@ export default {
return null; return null;
} }
}, },
clearArray() {
setOrderInfo([]);
},
}, },
}; };
</script> </script>
...@@ -1001,6 +1033,13 @@ export default { ...@@ -1001,6 +1033,13 @@ export default {
</div> </div>
</div> </div>
<div class="center-input"> <div class="center-input">
<el-button
@click="clearArray"
size="medium"
style="margin-right: 10px"
type="primary"
>清空本地数据
</el-button>
<el-input <el-input
@keyup.enter.native="getDataInfo" @keyup.enter.native="getDataInfo"
style="width: 40%;" style="width: 40%;"
......
...@@ -9,7 +9,6 @@ import { mmToPx, extractValue } from "@/utils"; ...@@ -9,7 +9,6 @@ import { mmToPx, extractValue } from "@/utils";
const path = require("path"); const path = require("path");
const fs = require("fs"); const fs = require("fs");
const uuid = require("uuid"); const uuid = require("uuid");
import { copySingleImage } from "@/server/utils/index.js";
import { mapState } from "vuex"; import { mapState } from "vuex";
...@@ -1256,18 +1255,26 @@ export default { ...@@ -1256,18 +1255,26 @@ export default {
this.selectIndex = -1; this.selectIndex = -1;
if (value.length > 0) { if (value.length > 0) {
this.selectImgList = value; this.selectImgList = value;
// console.log(816, this.selectImgList);
// console.log(99999, value); if (this.newDesktopDevice == 3) {
this.selectImgIndex = 0; const index = this.selectImgList.findIndex(
(el) => el.power === false,
);
this.selectImgIndex = index;
} else {
this.selectImgIndex = 0;
}
this.getBackFile( this.getBackFile(
{ files: [value[0]], size: this.detail.designImageSize || null }, {
files: [value[this.selectImgIndex]],
size: this.detail.designImageSize || null,
},
() => { () => {
this.imgHistoryList.push( this.imgHistoryList.push(
JSON.parse(JSON.stringify(this.imgList)), JSON.parse(JSON.stringify(this.imgList)),
); );
}, },
); );
// this.addFile([value[0].file])
} }
break; break;
default: default:
...@@ -1362,7 +1369,9 @@ export default { ...@@ -1362,7 +1369,9 @@ export default {
v-for="(img, i) in selectImgList" v-for="(img, i) in selectImgList"
:key="i" :key="i"
class="img-item" class="img-item"
@click.stop.prevent="selectImg(img, i)" @click.stop.prevent="
newDesktopDevice !== 3 && selectImg(img, i)
"
> >
<img v-if="img.productionFile" :src="img.productionFile" /> <img v-if="img.productionFile" :src="img.productionFile" />
<div v-if="img.title && img.title.length < 2" class="imgTitle"> <div v-if="img.title && img.title.length < 2" class="imgTitle">
......
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