Commit 4dfa24d6 by linjinhong

feat:添加监听

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