Commit 9dfa01d0 by wusiyi

feat: 调整订单生产完成逻辑

parent 33b2c721
...@@ -69,7 +69,7 @@ export default { ...@@ -69,7 +69,7 @@ export default {
selectGridIndex: 0, selectGridIndex: 0,
pkg, pkg,
actionIndex: -1, actionIndex: -1,
isAutoFinish: true, // isAutoFinish: true,
isForcedProduction: false, isForcedProduction: false,
cacheVisible: false, cacheVisible: false,
showPrintDialog: false, showPrintDialog: false,
...@@ -106,7 +106,8 @@ export default { ...@@ -106,7 +106,8 @@ export default {
], ],
faceType: "A", faceType: "A",
dialogVisible: false, dialogVisible: false,
showforcedProduc: false showforcedProduc: false,
completingOrderId: null
}; };
}, },
computed: { computed: {
...@@ -170,7 +171,7 @@ export default { ...@@ -170,7 +171,7 @@ export default {
const item = this.detail?.saveImgList?.find( const item = this.detail?.saveImgList?.find(
el => el.fileName == value[0].fileName el => el.fileName == value[0].fileName
); );
if (item) { if (item && !item.power) {
item.power = true; item.power = true;
try { try {
//复制图片到当前文件夹下 //复制图片到当前文件夹下
...@@ -189,12 +190,20 @@ export default { ...@@ -189,12 +190,20 @@ export default {
} }
//更新数据到本地数据 //更新数据到本地数据
updateOrderInfoItem(this.detail.newId, this.detail, this.faceType); updateOrderInfoItem(this.detail.newId, this.detail, this.faceType);
this.checkAndCompleteProduction(this.detail);
} }
console.log("updateOrderInfoItemitem", item); console.log("updateOrderInfoItemitem", item);
console.log("本地数据updateOrderInfoItem:", getOrderInfoMap()); console.log("本地数据updateOrderInfoItem:", getOrderInfoMap());
} }
} }
// deep: true, // deep: true,
},
"detail.saveImgList": {
handler(list) {
if (this.desktopDevice !== 3 || !this.detail || !list?.length) return;
this.checkAndCompleteProduction(this.detail);
},
deep: true
} }
}, },
methods: { methods: {
...@@ -229,8 +238,35 @@ export default { ...@@ -229,8 +238,35 @@ export default {
break; break;
} }
}, },
canCompleteProduction(data) {
if (!data) return false;
if (this.desktopDevice !== 3) return true;
const list = data?.saveImgList;
if (!list?.length) return false;
return list.every(el => el.power);
},
checkAndCompleteProduction(data) {
if (this.desktopDevice !== 3 || !this.canCompleteProduction(data)) return;
this.setData(data);
},
// 扫码后直接调用scanProduce转至生产中(惠立彩需确保所有面下载完成)
// 点击生产完成按钮,调用completeDelivery转至待配货
async setData(data, type) { async setData(data, type) {
if (!data) return this.$message.warning("请扫描生产单号/操作单号"); if (!data) return this.$message.warning("请扫描生产单号/操作单号");
if (!this.canCompleteProduction(data)) {
if (type == "btn") {
const item = data.saveImgList?.find(el => !el.power);
this.$message.warning(
`该订单${item?.title || ""}面未打印,无法生产完成`
);
}
return;
}
if (this.completingOrderId === data.id) return;
this.completingOrderId = data.id;
let params = { let params = {
id: data.id, id: data.id,
orderType: this.orderType orderType: this.orderType
...@@ -242,42 +278,43 @@ export default { ...@@ -242,42 +278,43 @@ export default {
} else if (this.orderType === "OP") { } else if (this.orderType === "OP") {
params.data = { ...data }; params.data = { ...data };
} }
//如果为惠立彩则判断当前saveImgList字段中的power是否全是true 是则生产完成
const canCallApi =
this.desktopDevice != 3 ||
(data.saveImgList?.every(el => el.power) ?? false);
if (canCallApi) { try {
console.log("生产完成"); console.log("生产完成");
if (this.desktopDevice == 3) {
await removeFromOrderInfo(data.newId);
bus.$emit("busEmit", { value: data.newId, type: "completeMessage" });
}
console.log("本地数据removeFromOrderInfo:", getOrderInfoMap()); console.log("本地数据removeFromOrderInfo:", getOrderInfoMap());
//生产完成后在本地删除
if ( if (type == "btn") {
this.orderType == "OP" && await this.$api.post(
(this.detail.status == "PENDING_PICK" || pathMap["completeDelivery"][this.orderType],
this.detail.status == "PENDING_REPLENISH") params
) { );
const { code, data } = await this.$api.post( await removeFromOrderInfo(data.newId);
bus.$emit("busEmit", {
value: data.newId,
type: "completeMessage"
});
} else if (this.orderType == "OP") {
bus.$emit("busEmit", {
value: data.newId,
type: "productingMessage"
});
const { code, data: resData } = await this.$api.post(
pathMap["scanProduce"][this.orderType], pathMap["scanProduce"][this.orderType],
{ id: params.id, status: params.data.status } { id: params.id, status: params.data.status }
); );
if (code == 301) { if (code == 301) {
this.$confirm( this.$confirm(
`库存不足,无法进入生产!请联系仓库管理人员核对库存。</br> `库存不足,无法进入生产!请联系仓库管理人员核对库存。</br>
库存数量:${data.availableInventory || 0} 库存数量:${resData.availableInventory || 0}
生产中数量:${data.inventory || 0} 生产中数量:${resData.inventory || 0}
<span style="color: red;">可调配库存: <span style="color: red;">可调配库存:
${data.inventory || 0}</span>`, ${resData.inventory || 0}</span>`,
"提示", "提示",
{ {
confirmButtonText: "确定", confirmButtonText: "确定",
type: "error", type: "error",
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
// 🔥 关键:添加自定义类名
customClass: "custom-inventory-msgbox" customClass: "custom-inventory-msgbox"
} }
); );
...@@ -291,14 +328,18 @@ export default { ...@@ -291,14 +328,18 @@ export default {
pathMap["completeDelivery"][this.orderType], pathMap["completeDelivery"][this.orderType],
params params
); );
if (this.desktopDevice == 3) {
await removeFromOrderInfo(data.newId);
bus.$emit("busEmit", {
value: data.newId,
type: "completeMessage"
});
}
} }
this.$message.success("操作成功"); this.$message.success("操作成功");
} else { } finally {
if (type == "btn") { this.completingOrderId = null;
const item = data.saveImgList?.find(el => !el.power);
this.$message.warning(`该订单${item.title}面未打印,无法生产完成`);
}
} }
}, },
async sureData() { async sureData() {
...@@ -615,48 +656,23 @@ export default { ...@@ -615,48 +656,23 @@ export default {
}, },
async getDataInfo(e, isForcedProduction) { async getDataInfo(e, isForcedProduction) {
//查询后先检查当前是否有数据,有则先走生产完成
if (
this.detail &&
Object.keys(this.detail).length > 0 &&
this.isAutoFinish
) {
try {
await this.setData(this.detail);
} catch (err) {
console.error("setData 执行失败", err);
}
}
if (this.detail && !this.isAutoFinish && this.desktopDevice == 3) {
//惠立彩判断是否全部图片都已经打印完成
const canCallApi =
this.detail.saveImgList?.every(el => el.power) ?? false;
if (canCallApi) {
bus.$emit("busEmit", {
value: this.detail.newId,
type: "completeFail"
});
}
}
//判断生产单号是否为空 //判断生产单号是否为空
if (this.productionNo === "") if (this.productionNo === "")
return this.$message.warning("请录入生产单号/操作单号"); return this.$message.warning("请录入生产单号/操作单号");
const today = moment(new Date()).format("YYYY-MM-DD"); // const today = moment(new Date()).format("YYYY-MM-DD");
//判断上一单未勾选添加当天日期是否跳过 //判断上一单未勾选添加当天日期是否跳过
if (!this.isAutoFinish && today != getNowDate()) { // if (!this.isAutoFinish && today != getNowDate()) {
this.$confirm("请注意自动完成上一单未勾选", "提示", { // this.$confirm("请注意自动完成上一单未勾选", "提示", {
confirmButtonText: "跳过提示", // confirmButtonText: "跳过提示",
type: "warning" // type: "warning"
}).then(res => { // }).then(res => {
if (res == "confirm") { // if (res == "confirm") {
setNowDate(today); // setNowDate(today);
} // }
}); // });
} // }
//判断生产单号是US CN GC(老pod),并设置 setOrderType //判断生产单号是US CN GC(老pod),并设置 setOrderType
if (this.productionNo.includes("_")) { if (this.productionNo.includes("_")) {
...@@ -767,6 +783,11 @@ export default { ...@@ -767,6 +783,11 @@ export default {
isForcedProduction isForcedProduction
); );
this.$store.commit("setProductDetail", this.detail); this.$store.commit("setProductDetail", this.detail);
if (this.desktopDevice !== 3) {
await this.setData(this.detail);
} else {
this.checkAndCompleteProduction(this.detail);
}
ipcRenderer.send("win-subScreen", findByPodProductionNo.data); ipcRenderer.send("win-subScreen", findByPodProductionNo.data);
this.$dataStore.set("production_no", this.productionNo); this.$dataStore.set("production_no", this.productionNo);
this.productionNo = ""; this.productionNo = "";
...@@ -1195,7 +1216,7 @@ export default { ...@@ -1195,7 +1216,7 @@ export default {
</el-button> </el-button>
</div> </div>
<div style="margin-left: 10px;"> <div style="margin-left: 10px;">
<el-checkbox v-model="isAutoFinish">自动完成上一单</el-checkbox> <!-- <el-checkbox v-model="isAutoFinish">自动完成上一单</el-checkbox> -->
</div> </div>
<div style="margin-left: 10px;" v-if="desktopDevice == 3"> <div style="margin-left: 10px;" v-if="desktopDevice == 3">
<el-checkbox v-model="isForcedProduction" style="color: red;" <el-checkbox v-model="isForcedProduction" style="color: red;"
......
...@@ -1228,7 +1228,7 @@ export default { ...@@ -1228,7 +1228,7 @@ export default {
`订单:${this.detail.newId}`, `订单:${this.detail.newId}`,
`<strong>订单:${this.detail.newId}</strong>` `<strong>订单:${this.detail.newId}</strong>`
) )
.replace(/生产中/, '<span style="color:#E6A23C">生产中</span>')
.replace(/生产完成/, '<span style="color:#85ce61">生产完成</span>') .replace(/生产完成/, '<span style="color:#85ce61">生产完成</span>')
.replace(/未生产完成/, '<span style="color:#f56c79">未生产完成</span>'); .replace(/未生产完成/, '<span style="color:#f56c79">未生产完成</span>');
}, },
...@@ -1268,6 +1268,10 @@ export default { ...@@ -1268,6 +1268,10 @@ export default {
let { type, value, size, productMark } = v; let { type, value, size, productMark } = v;
switch (type) { switch (type) {
case "productingMessage":
this.logList.unshift(`订单:${value}生产中`);
this.localeData = getOrderInfoMap();
break;
case "completeMessage": case "completeMessage":
this.logList.unshift(`订单:${value}生产完成`); this.logList.unshift(`订单:${value}生产完成`);
this.localeData = getOrderInfoMap(); this.localeData = getOrderInfoMap();
......
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