Commit cde2e19f authored by 何远江's avatar 何远江

生产发料bug修改

parent 175256b7
......@@ -138,10 +138,6 @@ export default {
})
.then((res) => {
if (res && res.code - 200 === 0) {
// list 第二层显示 也是最后提交的数据(改动最小)
// goodsList 第一层显示
// 第二层显示的数据和第一层必须属于同一个物料 itemCode一样
// this.list = res.rows
this.goodsList = res.rows.reduce((pre, cur) => {
if (pre.length === 0) {
pre.push({
......@@ -161,13 +157,6 @@ export default {
}
return pre;
}, []);
console.log("----goodsList----", this.goodsList);
// const data = res.rows
// const result = data.filter((item, index, self) => {
// return self.findIndex(t => t.sapItemCode === item.sapItemCode) === index;
// });
// this.goodsList = [...result]
} else {
this.$u.toast(res.msg);
}
......@@ -187,10 +176,12 @@ export default {
});
},
goSubmit() {
if (this.list.length === 0) {
return;
}
let arr = this.list.filter((ele) => ele.vista);
// let arr = this.goodsList.filter((ele) => ele.details.some(v => v.vista)).map(v =>);
let arr = this.goodsList.reduce((acc, cur) => {
acc.push(...cur.details)
return acc
}, [])
// "windCase": null,是否结案 Y是 N否
arr.forEach((ele, index) => {
......@@ -263,7 +254,6 @@ export default {
this.$u.toast("已经存在当前条码");
return;
}
// this.factorial({...res.BLPL[0]},plnr,0)
this.handleDetails(res.BLPL, plnr);
......@@ -301,7 +291,7 @@ export default {
v.PLNR = plnr;
v.LGORT = ele.LGORT;
v.LGOBE = ele.LGOBE;
v.NLPLA = ele.NLPLA;
v.NLPLA = ele.NLPLA;
// 添加两个字段,使用数量和剩余数量
v.usedNum = v.vista;
v.remainNum = +(v.applyNum - v.usedNum).toFixed(3);
......@@ -324,7 +314,7 @@ export default {
PLNR: plnr,
LGORT: ele.LGORT,
LGOBE: ele.LGOBE,
NLPLA: ele.NLPLA,
NLPLA: ele.NLPLA,
usedNum: +(v.usedNum + vista).toFixed(3),
remainNum: +(v.remainNum - vista).toFixed(3),
vista,
......@@ -341,169 +331,6 @@ export default {
this.$u.toast("没有物料");
}
});
console.log("----goodsList--------", this.goodsList);
},
handleAddList(idx, vista, res) {
const newCard = {
...this.list[idx],
vista,
// vista : ((this.list[idx].applyNum - 0)-(this.list[idx].vista-0)).toFixed(3),
add: "1",
...res,
};
this.list.splice(idx + 1, 0, newCard);
},
factorial(res, plnr, idx, num = 0) {
// 找出符合条件的数组长度
const count = this.list.filter(
(item) => item.sapItemCode == res.MATNR
).length;
if (!count) {
this.$u.toast("没有匹配到对应物料");
return;
}
// PACMG包装数量 applyNum申请数量 vista这一个工单分配了多少数量
// 总的来说逻辑是
// 1)
// 录入一个pl接口返回的数据 里面有包装数量 size 仓位
// 如果第一个applyNum申请数量满足不到 就把当前pl数据和第一个数据整合
// 再扫第二个 检查第一个是否满足,不满足 就先满足第一个,剩余的满足第二个
// 2)
// 如果满足第一个工单applyNum申请数量 就要往下满足 直到分配完。
for (let m = 0; m < this.list.length; m++) {
if (this.list[m].sapItemCode == res.MATNR) {
// 递归的方法 满足下一个
if (idx) {
if (this.list[idx]) {
if (num > this.list[idx].applyNum) {
this.$set(this.list, idx, {
...this.list[idx],
vista: this.list[idx].applyNum,
...res,
});
this.factorial(
res,
plnr,
idx + 1,
num - this.list[idx].applyNum
);
} else {
this.$set(this.list, idx, {
...this.list[idx],
vista: num,
...res,
});
this.factorial(res, plnr, idx + 1, 0);
}
}
return;
}
// 没有填入数据的
if (!this.list[m].vista) {
// 上一位的数据是否满足
if (
this.list[m - 1] &&
this.list[m - 1].vista < this.list[m - 1].applyNum
) {
this.handleAddList(
m,
this.list[m - 1].applyNum - 0 - (this.list[m - 1].vista - 0),
res
);
if (
res.PACMG >
this.list[m - 1].applyNum - this.list[m - 1].vista
) {
this.factorial(
res,
plnr,
m + 1,
res.PACMG -
(this.list[m - 1].applyNum - this.list[m - 1].vista)
);
}
return;
}
// 只有一个
// if(count === 1){
// this.$set(this.list,m,{...this.list[m],vista : res.PACMG,... res})
// }else{
// 包装数量大于申请数量
if (res.PACMG > this.list[m].applyNum) {
// 最后一个工单处理
if (count === m) {
this.$set(this.list, m, {
...this.list[m],
vista: res.PACMG,
...res,
});
return;
}
this.list[m].vista = this.list[m].applyNum;
this.$set(this.list, m, {
...this.list[m],
vista: this.list[m].applyNum,
...res,
});
this.factorial(
res,
plnr,
m + 1,
res.PACMG - this.list[m].applyNum
);
return;
} else {
// 包装数量小于等于申请数量
this.$set(this.list, m, {
...this.list[m],
vista: res.PACMG,
...res,
});
return;
}
// }
} else {
// 当前填入的数量小于申请数量 就把当前所有工单找出来 一个个的去检查是否满足
if (this.list[m].vista < this.list[m].applyNum) {
let arr = [];
this.list.forEach((ele) => {
if (ele.workorderCode === this.list[m].workorderCode) {
arr.push(ele);
}
});
// 工单申请数量
let totalApplyNum = arr[0].applyNum - 0;
// 当前工单已经录入了总数量 vista是每一个录入数量
let totalVista = 0;
arr.forEach((ele) => {
totalVista = totalVista + (ele.vista ? ele.vista - 0 : 0);
});
// 最终填入的数量
let endVista = 0;
endVista = (
this.list[m].applyNum -
0 -
(this.list[m].vista - 0)
).toFixed(3);
// 处理最后一行
if (m === this.list.length - 1) {
endVista = res.PACMG - 0;
}
// 工单录入数量总和小于总的申请数量 那就要新增一行
if (totalVista < totalApplyNum) {
this.handleAddList(m, endVista, res);
// 当前包装数量 大于(总的申请数量 减 工单录入数量总)就要往下一个分配
if (res.PACMG - 0 - endVista > 0) {
this.factorial(res, plnr, m + 2, res.PACMG - 0 - endVista);
}
return;
}
} else {
this.$u.toast("暂无剩余物料");
}
}
}
}
},
},
};
......
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