Commit 9dfa01d0 by wusiyi

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

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