|
@@ -1474,224 +1474,387 @@
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ // chooseTime(current, clonedTimeList, currentIndex) {
|
|
|
|
|
+ // if (clonedTimeList.length === 0) {
|
|
|
|
|
+ // this.timeList = [];
|
|
|
|
|
+ // this.attributeData.formedNumLast = 0;
|
|
|
|
|
+ // this.pickOutInListSelect = [];
|
|
|
|
|
+
|
|
|
|
|
+ // this.$nextTick(() => {
|
|
|
|
|
+ // if (this.$refs.pickOutRef) {
|
|
|
|
|
+ // this.$refs.pickOutRef.clearSelection();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+
|
|
|
|
|
+ // return;
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // if (
|
|
|
|
|
+ // this.workData.list[0].singleReport == 1 ||
|
|
|
|
|
+ // this.pickOutInList.length > 1
|
|
|
|
|
+ // ) {
|
|
|
|
|
+ // this.timeList = clonedTimeList.map((item) => item);
|
|
|
|
|
+ // const selectedIds = new Set();
|
|
|
|
|
+ // for (let item of this.timeList) {
|
|
|
|
|
+ // for (let it of item.pickOutInList) {
|
|
|
|
|
+ // selectedIds.add(it.id);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // this.attributeData.formedNumLast = this.timeList.reduce(
|
|
|
|
|
+ // (acc, pro) => {
|
|
|
|
|
+ // const num = parseFloat(pro.purchaseQuantity);
|
|
|
|
|
+ // return acc + (isNaN(num) ? 0 : num);
|
|
|
|
|
+ // },
|
|
|
|
|
+ // 0
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // const unassignedList = this.pickOutInList.filter(
|
|
|
|
|
+ // (item) => !selectedIds.has(item.id)
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // const totalNum = this.pickOutInList.reduce(
|
|
|
|
|
+ // (sum, item) => sum + Number(item.feedQuantity || 0),
|
|
|
|
|
+ // 0
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // if (unassignedList.length > 0) {
|
|
|
|
|
+ // const number = unassignedList.reduce(
|
|
|
|
|
+ // (sum, item) => sum + Number(item.feedQuantity || 0),
|
|
|
|
|
+ // 0
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // const data = {
|
|
|
|
|
+ // batchNo: '一次性到货',
|
|
|
|
|
+ // requireDeliveryTime: null,
|
|
|
|
|
+ // purchaseQuantity: number,
|
|
|
|
|
+ // pickOutInList: unassignedList,
|
|
|
|
|
+ // bomMaterialList: [],
|
|
|
|
|
+ // standardOutputList: [],
|
|
|
|
|
+ // isParent: 1
|
|
|
|
|
+ // };
|
|
|
|
|
+
|
|
|
|
|
+ // const exists = this.timeList.some((t) => t.batchNo == '一次性到货');
|
|
|
|
|
+
|
|
|
|
|
+ // if (!exists) {
|
|
|
|
|
+ // this.timeList.unshift(data);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // const index = this.timeList.findIndex(
|
|
|
|
|
+ // (t) => t.batchNo == '一次性到货'
|
|
|
|
|
+ // );
|
|
|
|
|
+ // this.timeList.splice(index, 1, data);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // if (this.bomMaterialList.length != 0) {
|
|
|
|
|
+ // for (let item of this.bomMaterialList) {
|
|
|
|
|
+ // for (let it of this.timeList) {
|
|
|
|
|
+ // const proportion = this.div(it.purchaseQuantity, totalNum);
|
|
|
|
|
+ // const allocatedQuantity = this.mul(
|
|
|
|
|
+ // proportion,
|
|
|
|
|
+ // item.demandQuantity
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // const materialItem = {
|
|
|
|
|
+ // ...item,
|
|
|
|
|
+ // demandQuantity: allocatedQuantity
|
|
|
|
|
+ // };
|
|
|
|
|
+
|
|
|
|
|
+ // it.bomMaterialList.push(materialItem);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // if (this.standardOutputList.length != 0) {
|
|
|
|
|
+ // for (let item of this.standardOutputList) {
|
|
|
|
|
+ // for (let it of this.timeList) {
|
|
|
|
|
+ // const proportion = this.div(it.purchaseQuantity, totalNum);
|
|
|
|
|
+ // const allocatedQuantity = this.mul(
|
|
|
|
|
+ // proportion,
|
|
|
|
|
+ // item.demandQuantity
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // const materialItem = {
|
|
|
|
|
+ // ...item,
|
|
|
|
|
+ // demandQuantity: allocatedQuantity
|
|
|
|
|
+ // };
|
|
|
|
|
+
|
|
|
|
|
+ // it.standardOutputList.push(materialItem);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // this.timeList[0].innerActive = '0';
|
|
|
|
|
+ // this.activeBatch = this.timeList[0].batchNo;
|
|
|
|
|
+ // this.pickOutInListSelect = [];
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // if (this.pickOutInList.length == 1) {
|
|
|
|
|
+ // this.timeList = clonedTimeList.map((item) => {
|
|
|
|
|
+ // item.pickOutInList = [this.deepCopy(this.pickOutInListSelect[0])];
|
|
|
|
|
+
|
|
|
|
|
+ // return item;
|
|
|
|
|
+ // });
|
|
|
|
|
+
|
|
|
|
|
+ // this.attributeData.formedNumLast = this.timeList.reduce(
|
|
|
|
|
+ // (acc, pro) => {
|
|
|
|
|
+ // const num = parseFloat(pro.purchaseQuantity);
|
|
|
|
|
+ // return acc + (isNaN(num) ? 0 : num);
|
|
|
|
|
+ // },
|
|
|
|
|
+ // 0
|
|
|
|
|
+ // );
|
|
|
|
|
+ // const totalNum = this.pickOutInList.reduce(
|
|
|
|
|
+ // (sum, item) => sum + Number(item.feedQuantity || 0),
|
|
|
|
|
+ // 0
|
|
|
|
|
+ // );
|
|
|
|
|
+ // const batchNum = this.timeList.reduce(
|
|
|
|
|
+ // (sum, item) => sum + Number(item.purchaseQuantity || 0),
|
|
|
|
|
+ // 0
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // let singleWeight = 0;
|
|
|
|
|
+
|
|
|
|
|
+ // if (
|
|
|
|
|
+ // this.pickOutInList[0].newWeight ||
|
|
|
|
|
+ // this.pickOutInList[0].newWeight == 0
|
|
|
|
|
+ // ) {
|
|
|
|
|
+ // singleWeight = this.div(
|
|
|
|
|
+ // this.pickOutInList[0].newWeight,
|
|
|
|
|
+ // totalNum
|
|
|
|
|
+ // );
|
|
|
|
|
+ // }
|
|
|
|
|
+ // const remainderNum = this.sub(totalNum, batchNum);
|
|
|
|
|
+ // if (remainderNum != 0) {
|
|
|
|
|
+ // const data = {
|
|
|
|
|
+ // batchNo: '一次性到货',
|
|
|
|
|
+ // requireDeliveryTime: null,
|
|
|
|
|
+ // purchaseQuantity: remainderNum,
|
|
|
|
|
+ // pickOutInList: [this.deepCopy(this.pickOutInListSelect[0])],
|
|
|
|
|
+ // bomMaterialList: [],
|
|
|
|
|
+ // standardOutputList: [],
|
|
|
|
|
+ // isParent: 1
|
|
|
|
|
+ // };
|
|
|
|
|
+ // const exists = this.timeList.some(
|
|
|
|
|
+ // (t) => t.batchNo == '一次性到货'
|
|
|
|
|
+ // );
|
|
|
|
|
+ // if (!exists) {
|
|
|
|
|
+ // this.timeList.unshift(data);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // const index = this.timeList.findIndex(
|
|
|
|
|
+ // (t) => t.batchNo == '一次性到货'
|
|
|
|
|
+ // );
|
|
|
|
|
+ // this.timeList.splice(index, 1, data);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (this.bomMaterialList.length != 0) {
|
|
|
|
|
+ // for (let item of this.bomMaterialList) {
|
|
|
|
|
+ // for (let it of this.timeList) {
|
|
|
|
|
+ // const proportion = this.div(it.purchaseQuantity, totalNum);
|
|
|
|
|
+ // const allocatedQuantity = this.mul(
|
|
|
|
|
+ // proportion,
|
|
|
|
|
+ // item.demandQuantity
|
|
|
|
|
+ // );
|
|
|
|
|
+ // const materialItem = {
|
|
|
|
|
+ // ...item,
|
|
|
|
|
+ // demandQuantity: allocatedQuantity
|
|
|
|
|
+ // };
|
|
|
|
|
+ // it.bomMaterialList.push(materialItem);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (this.standardOutputList.length != 0) {
|
|
|
|
|
+ // for (let item of this.standardOutputList) {
|
|
|
|
|
+ // for (let it of this.timeList) {
|
|
|
|
|
+ // const proportion = this.div(it.purchaseQuantity, totalNum);
|
|
|
|
|
+ // const allocatedQuantity = this.mul(
|
|
|
|
|
+ // proportion,
|
|
|
|
|
+ // item.demandQuantity
|
|
|
|
|
+ // );
|
|
|
|
|
+ // const materialItem = {
|
|
|
|
|
+ // ...item,
|
|
|
|
|
+ // demandQuantity: allocatedQuantity
|
|
|
|
|
+ // };
|
|
|
|
|
+ // it.standardOutputList.push(materialItem);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // this.timeList = this.timeList.map((it) => {
|
|
|
|
|
+ // it.pickOutInList.forEach((item) => {
|
|
|
|
|
+ // item.feedQuantity = it.purchaseQuantity;
|
|
|
|
|
+ // item.newWeight = this.mul(singleWeight, it.purchaseQuantity);
|
|
|
|
|
+ // });
|
|
|
|
|
+
|
|
|
|
|
+ // return it;
|
|
|
|
|
+ // });
|
|
|
|
|
+
|
|
|
|
|
+ // this.timeList[0].innerActive = '0';
|
|
|
|
|
+ // this.activeBatch = this.timeList[0].batchNo;
|
|
|
|
|
+ // this.pickOutInListSelect = [];
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // },
|
|
|
|
|
+
|
|
|
chooseTime(current, clonedTimeList, currentIndex) {
|
|
chooseTime(current, clonedTimeList, currentIndex) {
|
|
|
if (clonedTimeList.length === 0) {
|
|
if (clonedTimeList.length === 0) {
|
|
|
- this.timeList = [];
|
|
|
|
|
- this.attributeData.formedNumLast = 0;
|
|
|
|
|
- this.pickOutInListSelect = [];
|
|
|
|
|
|
|
+ this.resetAll();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
|
- if (this.$refs.pickOutRef) {
|
|
|
|
|
- this.$refs.pickOutRef.clearSelection();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const isSingleReport = this.workData.list[0].singleReport == 1;
|
|
|
|
|
+ const isMultiSelect = this.pickOutInList.length > 1;
|
|
|
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ if (isSingleReport || isMultiSelect) {
|
|
|
|
|
+ this.handleMulti(clonedTimeList);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.handleSingle(clonedTimeList);
|
|
|
}
|
|
}
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- if (
|
|
|
|
|
- this.workData.list[0].singleReport == 1 ||
|
|
|
|
|
- this.pickOutInList.length > 1
|
|
|
|
|
- ) {
|
|
|
|
|
- this.timeList = clonedTimeList.map((item) => item);
|
|
|
|
|
- const selectedIds = new Set();
|
|
|
|
|
- for (let item of this.timeList) {
|
|
|
|
|
- for (let it of item.pickOutInList) {
|
|
|
|
|
- selectedIds.add(it.id);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ resetAll() {
|
|
|
|
|
+ this.timeList = [];
|
|
|
|
|
+ this.attributeData.formedNumLast = 0;
|
|
|
|
|
+ this.pickOutInListSelect = [];
|
|
|
|
|
|
|
|
- this.attributeData.formedNumLast = this.timeList.reduce(
|
|
|
|
|
- (acc, pro) => {
|
|
|
|
|
- const num = parseFloat(pro.purchaseQuantity);
|
|
|
|
|
- return acc + (isNaN(num) ? 0 : num);
|
|
|
|
|
- },
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ this.$refs.pickOutRef && this.$refs.pickOutRef.clearSelection();
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- const unassignedList = this.pickOutInList.filter(
|
|
|
|
|
- (item) => !selectedIds.has(item.id)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ calcTotal(list, key) {
|
|
|
|
|
+ return list.reduce((sum, item) => sum + Number(item[key] || 0), 0);
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- const totalNum = this.pickOutInList.reduce(
|
|
|
|
|
- (sum, item) => sum + Number(item.feedQuantity || 0),
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ insertOrUpdateOnce(timeList, data) {
|
|
|
|
|
+ const index = timeList.findIndex((t) => t.batchNo === '一次性到货');
|
|
|
|
|
+ if (index === -1) {
|
|
|
|
|
+ timeList.unshift(data);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ timeList.splice(index, 1, data);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- if (unassignedList.length > 0) {
|
|
|
|
|
- const number = unassignedList.reduce(
|
|
|
|
|
- (sum, item) => sum + Number(item.feedQuantity || 0),
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ assignMaterialLists(timeList, totalNum, bomList, outputList) {
|
|
|
|
|
+ for (let it of timeList) {
|
|
|
|
|
+ it.bomMaterialList = [];
|
|
|
|
|
+ it.standardOutputList = [];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const data = {
|
|
|
|
|
- batchNo: '一次性到货',
|
|
|
|
|
- requireDeliveryTime: null,
|
|
|
|
|
- purchaseQuantity: number,
|
|
|
|
|
- pickOutInList: unassignedList,
|
|
|
|
|
- bomMaterialList: [],
|
|
|
|
|
- standardOutputList: [],
|
|
|
|
|
- isParent: 1
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- const exists = this.timeList.some((t) => t.batchNo == '一次性到货');
|
|
|
|
|
-
|
|
|
|
|
- if (!exists) {
|
|
|
|
|
- this.timeList.unshift(data);
|
|
|
|
|
- } else {
|
|
|
|
|
- const index = this.timeList.findIndex(
|
|
|
|
|
- (t) => t.batchNo == '一次性到货'
|
|
|
|
|
- );
|
|
|
|
|
- this.timeList.splice(index, 1, data);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const assign = (sourceList, targetKey) => {
|
|
|
|
|
+ if (!sourceList.length) return;
|
|
|
|
|
|
|
|
- if (this.bomMaterialList.length != 0) {
|
|
|
|
|
- for (let item of this.bomMaterialList) {
|
|
|
|
|
- for (let it of this.timeList) {
|
|
|
|
|
- const proportion = this.div(it.purchaseQuantity, totalNum);
|
|
|
|
|
- const allocatedQuantity = this.mul(
|
|
|
|
|
- proportion,
|
|
|
|
|
- item.demandQuantity
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- const materialItem = {
|
|
|
|
|
- ...item,
|
|
|
|
|
- demandQuantity: allocatedQuantity
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- it.bomMaterialList.push(materialItem);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for (let item of sourceList) {
|
|
|
|
|
+ for (let it of timeList) {
|
|
|
|
|
+ const proportion = this.div(it.purchaseQuantity, totalNum);
|
|
|
|
|
+ const allocated = this.mul(proportion, item.demandQuantity);
|
|
|
|
|
|
|
|
- if (this.standardOutputList.length != 0) {
|
|
|
|
|
- for (let item of this.standardOutputList) {
|
|
|
|
|
- for (let it of this.timeList) {
|
|
|
|
|
- const proportion = this.div(it.purchaseQuantity, totalNum);
|
|
|
|
|
- const allocatedQuantity = this.mul(
|
|
|
|
|
- proportion,
|
|
|
|
|
- item.demandQuantity
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- const materialItem = {
|
|
|
|
|
- ...item,
|
|
|
|
|
- demandQuantity: allocatedQuantity
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- it.standardOutputList.push(materialItem);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ it[targetKey].push({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ demandQuantity: allocated
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- this.timeList[0].innerActive = '0';
|
|
|
|
|
- this.activeBatch = this.timeList[0].batchNo;
|
|
|
|
|
- this.pickOutInListSelect = [];
|
|
|
|
|
- } else {
|
|
|
|
|
- if (this.pickOutInList.length == 1) {
|
|
|
|
|
- this.timeList = clonedTimeList.map((item) => {
|
|
|
|
|
- item.pickOutInList = [this.deepCopy(this.pickOutInListSelect[0])];
|
|
|
|
|
|
|
+ assign(bomList, 'bomMaterialList');
|
|
|
|
|
+ assign(outputList, 'standardOutputList');
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- return item;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ setActive() {
|
|
|
|
|
+ this.timeList[0].innerActive = '0';
|
|
|
|
|
+ this.activeBatch = this.timeList[0].batchNo;
|
|
|
|
|
+ this.pickOutInListSelect = [];
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- this.attributeData.formedNumLast = this.timeList.reduce(
|
|
|
|
|
- (acc, pro) => {
|
|
|
|
|
- const num = parseFloat(pro.purchaseQuantity);
|
|
|
|
|
- return acc + (isNaN(num) ? 0 : num);
|
|
|
|
|
- },
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
- const totalNum = this.pickOutInList.reduce(
|
|
|
|
|
- (sum, item) => sum + Number(item.feedQuantity || 0),
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
- const batchNum = this.timeList.reduce(
|
|
|
|
|
- (sum, item) => sum + Number(item.purchaseQuantity || 0),
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ handleSingle(clonedTimeList) {
|
|
|
|
|
+ const selected = this.deepCopy(this.pickOutInListSelect[0]);
|
|
|
|
|
+
|
|
|
|
|
+ this.timeList = clonedTimeList.map((item) => ({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ pickOutInList: [selected]
|
|
|
|
|
+ }));
|
|
|
|
|
+
|
|
|
|
|
+ const totalNum = this.calcTotal(this.pickOutInList, 'feedQuantity');
|
|
|
|
|
+ const batchNum = this.calcTotal(this.timeList, 'purchaseQuantity');
|
|
|
|
|
+
|
|
|
|
|
+ this.attributeData.formedNumLast = batchNum;
|
|
|
|
|
+
|
|
|
|
|
+ const remain = this.sub(totalNum, batchNum);
|
|
|
|
|
+ if (remain != 0) {
|
|
|
|
|
+ const data = {
|
|
|
|
|
+ batchNo: '一次性到货',
|
|
|
|
|
+ requireDeliveryTime: null,
|
|
|
|
|
+ purchaseQuantity: remain,
|
|
|
|
|
+ pickOutInList: [{ ...selected, selected: false }],
|
|
|
|
|
+ bomMaterialList: [],
|
|
|
|
|
+ standardOutputList: [],
|
|
|
|
|
+ isParent: 1
|
|
|
|
|
+ };
|
|
|
|
|
+ this.insertOrUpdateOnce(this.timeList, data);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- let singleWeight = 0;
|
|
|
|
|
|
|
+ this.assignMaterialLists(
|
|
|
|
|
+ this.timeList,
|
|
|
|
|
+ totalNum,
|
|
|
|
|
+ this.bomMaterialList,
|
|
|
|
|
+ this.standardOutputList
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- if (
|
|
|
|
|
- this.pickOutInList[0].newWeight ||
|
|
|
|
|
- this.pickOutInList[0].newWeight == 0
|
|
|
|
|
- ) {
|
|
|
|
|
- singleWeight = this.div(
|
|
|
|
|
- this.pickOutInList[0].newWeight,
|
|
|
|
|
- totalNum
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
- const remainderNum = this.sub(totalNum, batchNum);
|
|
|
|
|
- if (remainderNum != 0) {
|
|
|
|
|
- const data = {
|
|
|
|
|
- batchNo: '一次性到货',
|
|
|
|
|
- requireDeliveryTime: null,
|
|
|
|
|
- purchaseQuantity: remainderNum,
|
|
|
|
|
- pickOutInList: [this.deepCopy(this.pickOutInListSelect[0])],
|
|
|
|
|
- bomMaterialList: [],
|
|
|
|
|
- standardOutputList: [],
|
|
|
|
|
- isParent: 1
|
|
|
|
|
- };
|
|
|
|
|
- const exists = this.timeList.some(
|
|
|
|
|
- (t) => t.batchNo == '一次性到货'
|
|
|
|
|
- );
|
|
|
|
|
- if (!exists) {
|
|
|
|
|
- this.timeList.unshift(data);
|
|
|
|
|
- } else {
|
|
|
|
|
- const index = this.timeList.findIndex(
|
|
|
|
|
- (t) => t.batchNo == '一次性到货'
|
|
|
|
|
- );
|
|
|
|
|
- this.timeList.splice(index, 1, data);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (this.bomMaterialList.length != 0) {
|
|
|
|
|
- for (let item of this.bomMaterialList) {
|
|
|
|
|
- for (let it of this.timeList) {
|
|
|
|
|
- const proportion = this.div(it.purchaseQuantity, totalNum);
|
|
|
|
|
- const allocatedQuantity = this.mul(
|
|
|
|
|
- proportion,
|
|
|
|
|
- item.demandQuantity
|
|
|
|
|
- );
|
|
|
|
|
- const materialItem = {
|
|
|
|
|
- ...item,
|
|
|
|
|
- demandQuantity: allocatedQuantity
|
|
|
|
|
- };
|
|
|
|
|
- it.bomMaterialList.push(materialItem);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (this.standardOutputList.length != 0) {
|
|
|
|
|
- for (let item of this.standardOutputList) {
|
|
|
|
|
- for (let it of this.timeList) {
|
|
|
|
|
- const proportion = this.div(it.purchaseQuantity, totalNum);
|
|
|
|
|
- const allocatedQuantity = this.mul(
|
|
|
|
|
- proportion,
|
|
|
|
|
- item.demandQuantity
|
|
|
|
|
- );
|
|
|
|
|
- const materialItem = {
|
|
|
|
|
- ...item,
|
|
|
|
|
- demandQuantity: allocatedQuantity
|
|
|
|
|
- };
|
|
|
|
|
- it.standardOutputList.push(materialItem);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let singleWeight = 0;
|
|
|
|
|
+ if (selected.newWeight || selected.newWeight === 0) {
|
|
|
|
|
+ singleWeight = this.div(selected.newWeight, totalNum);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- this.timeList = this.timeList.map((it) => {
|
|
|
|
|
- it.pickOutInList.forEach((item) => {
|
|
|
|
|
- item.feedQuantity = it.purchaseQuantity;
|
|
|
|
|
- item.newWeight = this.mul(singleWeight, it.purchaseQuantity);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ this.timeList = this.timeList.map((it) => {
|
|
|
|
|
+ it.pickOutInList.forEach((item) => {
|
|
|
|
|
+ item.feedQuantity = it.purchaseQuantity;
|
|
|
|
|
+ item.newWeight = this.mul(singleWeight, it.purchaseQuantity);
|
|
|
|
|
+ });
|
|
|
|
|
+ return it;
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- return it;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ this.setActive();
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
- this.timeList[0].innerActive = '0';
|
|
|
|
|
- this.activeBatch = this.timeList[0].batchNo;
|
|
|
|
|
- this.pickOutInListSelect = [];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ handleMulti(clonedTimeList) {
|
|
|
|
|
+ this.timeList = clonedTimeList.map((i) => i);
|
|
|
|
|
+
|
|
|
|
|
+ const selectedIds = new Set();
|
|
|
|
|
+ this.timeList.forEach((t) =>
|
|
|
|
|
+ t.pickOutInList.forEach((i) => selectedIds.add(i.id))
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ const totalNum = this.calcTotal(this.pickOutInList, 'feedQuantity');
|
|
|
|
|
+ this.attributeData.formedNumLast = this.calcTotal(
|
|
|
|
|
+ this.timeList,
|
|
|
|
|
+ 'purchaseQuantity'
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ const unassigned = this.pickOutInList.filter(
|
|
|
|
|
+ (i) => !selectedIds.has(i.id)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ if (unassigned.length > 0) {
|
|
|
|
|
+ const number = this.calcTotal(unassigned, 'feedQuantity');
|
|
|
|
|
+ const data = {
|
|
|
|
|
+ batchNo: '一次性到货',
|
|
|
|
|
+ requireDeliveryTime: null,
|
|
|
|
|
+ purchaseQuantity: number,
|
|
|
|
|
+ pickOutInList: unassigned.map((i) => ({ ...i, selected: false })),
|
|
|
|
|
+ bomMaterialList: [],
|
|
|
|
|
+ standardOutputList: [],
|
|
|
|
|
+ isParent: 1
|
|
|
|
|
+ };
|
|
|
|
|
+ this.insertOrUpdateOnce(this.timeList, data);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ this.assignMaterialLists(
|
|
|
|
|
+ this.timeList,
|
|
|
|
|
+ totalNum,
|
|
|
|
|
+ this.bomMaterialList,
|
|
|
|
|
+ this.standardOutputList
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ this.setActive();
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
getDecimalLength(num) {
|
|
getDecimalLength(num) {
|