|
|
@@ -1246,12 +1246,15 @@
|
|
|
sumweight(arr) {
|
|
|
let formedWeight = 0;
|
|
|
let noFormedWeight = 0;
|
|
|
+ let lossWeight = 0;
|
|
|
arr.map((s, i) => {
|
|
|
if (s.extInfo.reportWeight) {
|
|
|
- if (s.extInfo.isQualified == 1) {
|
|
|
+ if (s.extInfo.isQualified == 1 && !s.extInfo.isLoss) {
|
|
|
formedWeight += s.extInfo.reportWeight * 1;
|
|
|
- } else {
|
|
|
+ } else if (!s.extInfo.isLoss) {
|
|
|
noFormedWeight += s.extInfo.reportWeight * 1;
|
|
|
+ } else if (s.extInfo.isLoss == 1) {
|
|
|
+ lossWeight += s.extInfo.reportWeight * 1;
|
|
|
}
|
|
|
} else {
|
|
|
s.extInfo.reportWeight = null;
|
|
|
@@ -1270,7 +1273,12 @@
|
|
|
this.item.workReportInfo.notFormedWeight = parseFloat(
|
|
|
noFormedWeight.toFixed(2)
|
|
|
);
|
|
|
+ this.item.workReportInfo.lossWeight = parseFloat(
|
|
|
+ lossWeight.toFixed(2)
|
|
|
+ );
|
|
|
}
|
|
|
+
|
|
|
+ console.log(this.item.workReportInfo, 'this.item.workReportInfo');
|
|
|
},
|
|
|
|
|
|
async getCodeData() {
|
|
|
@@ -1407,6 +1415,18 @@
|
|
|
|
|
|
async getQualityParam() {
|
|
|
if (this.batchForm.quantity && this.batchForm.batchNo) {
|
|
|
+ // const reg = /^(\d+)(\.\d{0,4})?$/;
|
|
|
+ // if (
|
|
|
+ // this.itemData.feedQuantity === '' ||
|
|
|
+ // reg.test(this.itemData.feedQuantity)
|
|
|
+ // ) {
|
|
|
+ // this.itemData.feedQuantity = val;
|
|
|
+ // } else {
|
|
|
+ // // 如果用户输入非法字符,直接去掉非法部分
|
|
|
+ // const match = val.match(/^(\d+)(\.\d{0,4})?/);
|
|
|
+ // this.itemData.feedQuantity = match ? match[0] : '';
|
|
|
+ // }
|
|
|
+
|
|
|
if (Number(this.itemData.feedQuantity) == 0) {
|
|
|
this.$message.warning('拆批数不能等于0');
|
|
|
return;
|
|
|
@@ -1445,9 +1465,13 @@
|
|
|
},
|
|
|
|
|
|
refreshData(list) {
|
|
|
- const number =
|
|
|
- Number(this.list[this.itemIndex].feedQuantity) -
|
|
|
- Number(this.batchForm.quantity);
|
|
|
+ // const number =
|
|
|
+ // Number(this.list[this.itemIndex].feedQuantity) -
|
|
|
+ // Number(this.batchForm.quantity);
|
|
|
+ const number = this.sub(
|
|
|
+ Number(this.list[this.itemIndex].feedQuantity),
|
|
|
+ Number(this.batchForm.quantity)
|
|
|
+ );
|
|
|
this.list[this.itemIndex].extInfo.sourceQuantity = number;
|
|
|
this.list[this.itemIndex].feedQuantity = number;
|
|
|
this.list[this.itemIndex].extInfo.newWeight =
|
|
|
@@ -1479,6 +1503,38 @@
|
|
|
}, result);
|
|
|
},
|
|
|
|
|
|
+ toInteger(num) {
|
|
|
+ const len = this.getDecimalLength(num);
|
|
|
+ return {
|
|
|
+ int: Math.round(num * Math.pow(10, len)),
|
|
|
+ factor: Math.pow(10, len)
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ add(a, b) {
|
|
|
+ const { int: aInt, factor: aFactor } = this.toInteger(a);
|
|
|
+ const { int: bInt, factor: bFactor } = this.toInteger(b);
|
|
|
+ const maxFactor = Math.max(aFactor, bFactor);
|
|
|
+ return (
|
|
|
+ (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
|
|
|
+ maxFactor
|
|
|
+ );
|
|
|
+ },
|
|
|
+
|
|
|
+ sub(a, b) {
|
|
|
+ const { int: aInt, factor: aFactor } = this.toInteger(a);
|
|
|
+ const { int: bInt, factor: bFactor } = this.toInteger(b);
|
|
|
+ const maxFactor = Math.max(aFactor, bFactor);
|
|
|
+ return (
|
|
|
+ (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
|
|
|
+ maxFactor
|
|
|
+ );
|
|
|
+ },
|
|
|
+
|
|
|
+ getDecimalLength(num) {
|
|
|
+ return (num.toString().split('.')[1] || '').length;
|
|
|
+ },
|
|
|
+
|
|
|
openLoss(item, index) {
|
|
|
this.lossForm.quantity = '';
|
|
|
this.lossForm.unit = '';
|
|
|
@@ -1492,6 +1548,18 @@
|
|
|
|
|
|
async getLossParam() {
|
|
|
if (this.lossForm.quantity && this.lossForm.batchNo) {
|
|
|
+ // const reg = /^(\d+)(\.\d{0,4})?$/;
|
|
|
+ // if (
|
|
|
+ // this.lossData.feedQuantity === '' ||
|
|
|
+ // reg.test(this.lossData.feedQuantity)
|
|
|
+ // ) {
|
|
|
+ // this.lossData.feedQuantity = val;
|
|
|
+ // } else {
|
|
|
+ // // 如果用户输入非法字符,直接去掉非法部分
|
|
|
+ // const match = val.match(/^(\d+)(\.\d{0,4})?/);
|
|
|
+ // this.lossData.feedQuantity = match ? match[0] : '';
|
|
|
+ // }
|
|
|
+
|
|
|
if (
|
|
|
Number(this.lossData.feedQuantity) < Number(this.lossForm.quantity)
|
|
|
) {
|
|
|
@@ -1519,9 +1587,13 @@
|
|
|
},
|
|
|
|
|
|
refreshLossData(list) {
|
|
|
- const number =
|
|
|
- Number(this.list[this.lossIndex].feedQuantity) -
|
|
|
- Number(this.lossForm.quantity);
|
|
|
+ // const number =
|
|
|
+ // Number(this.list[this.lossIndex].feedQuantity) -
|
|
|
+ // Number(this.lossForm.quantity);
|
|
|
+ const number = this.sub(
|
|
|
+ Number(this.list[this.lossIndex].feedQuantity),
|
|
|
+ Number(this.lossForm.quantity)
|
|
|
+ );
|
|
|
this.list[this.lossIndex].extInfo.sourceQuantity = number;
|
|
|
this.list[this.lossIndex].feedQuantity = number;
|
|
|
this.list[this.lossIndex].extInfo.newWeight =
|
|
|
@@ -1534,14 +1606,6 @@
|
|
|
});
|
|
|
|
|
|
const newList = this.list.filter((item) => item.feedQuantity != 0);
|
|
|
- console.log(newList, 'newList新数据');
|
|
|
-
|
|
|
- // this.$set(
|
|
|
- // this.item,
|
|
|
- // 'product',
|
|
|
- // this.list.filter((item) => item.feedQuantity != 0)
|
|
|
- // );
|
|
|
-
|
|
|
let _arr = [...newList, ...list];
|
|
|
|
|
|
this.$set(this.item, 'product', _arr);
|