|
@@ -335,50 +335,99 @@ export default {
|
|
|
deep: true,
|
|
deep: true,
|
|
|
handler(newVal) {
|
|
handler(newVal) {
|
|
|
console.log(newVal, "newVal");
|
|
console.log(newVal, "newVal");
|
|
|
- if (newVal.product && newVal.product.length != 0) {
|
|
|
|
|
- let formedNum = 0;
|
|
|
|
|
- let notFormedNum = 0;
|
|
|
|
|
- let lossNum = 0;
|
|
|
|
|
-
|
|
|
|
|
- newVal.product.forEach((item) => {
|
|
|
|
|
- if (
|
|
|
|
|
- (!item.extInfo.isQualified ||
|
|
|
|
|
- item.extInfo.isQualified == 1 ||
|
|
|
|
|
- item.extInfo.isQualified == 3) &&
|
|
|
|
|
- !item.extInfo.isLoss
|
|
|
|
|
- ) {
|
|
|
|
|
- formedNum = formedNum + Number(item.feedQuantity);
|
|
|
|
|
- // formedNum = this.add(formedNum, Number(item.feedQuantity));
|
|
|
|
|
- } else if (!item.extInfo.isLoss) {
|
|
|
|
|
- if (item.extInfo.notType == 5 || item.extInfo.notType == 8) {
|
|
|
|
|
- formedNum = formedNum + Number(item.feedQuantity);
|
|
|
|
|
-
|
|
|
|
|
- // formedNum = this.add(formedNum, Number(item.feedQuantity));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (newVal.product && newVal.product.length !== 0) {
|
|
|
|
|
+ const product = newVal.product;
|
|
|
|
|
+
|
|
|
|
|
+ const finalList = product.some((it) => it.confirm == 1)
|
|
|
|
|
+ ? product.filter((it) => it.confirm == 1)
|
|
|
|
|
+ : product;
|
|
|
|
|
+
|
|
|
|
|
+ const isLoss = (item) => item.extInfo.isLoss == 1;
|
|
|
|
|
+
|
|
|
|
|
+ const isFormed = (item) => {
|
|
|
|
|
+ const { isQualified, notType } = item.extInfo;
|
|
|
|
|
+ return (
|
|
|
|
|
+ !isQualified ||
|
|
|
|
|
+ isQualified == 1 ||
|
|
|
|
|
+ isQualified == 3 ||
|
|
|
|
|
+ notType == 5 ||
|
|
|
|
|
+ notType == 8
|
|
|
|
|
+ );
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const getQty = (item) => Number(item.feedQuantity);
|
|
|
|
|
+
|
|
|
|
|
+ const result = finalList.reduce(
|
|
|
|
|
+ (acc, item) => {
|
|
|
|
|
+ const qty = getQty(item);
|
|
|
|
|
+
|
|
|
|
|
+ if (isLoss(item)) {
|
|
|
|
|
+ acc.lossNum = this.add(acc.lossNum, qty);
|
|
|
|
|
+ } else if (isFormed(item)) {
|
|
|
|
|
+ acc.formedNum = this.add(acc.formedNum, qty);
|
|
|
} else {
|
|
} else {
|
|
|
- notFormedNum = notFormedNum + Number(item.feedQuantity);
|
|
|
|
|
- // if (!item.extInfo.isLoss) {
|
|
|
|
|
- // notFormedNum = this.add(
|
|
|
|
|
- // notFormedNum,
|
|
|
|
|
- // Number(item.feedQuantity)
|
|
|
|
|
- // );
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ acc.notFormedNum = this.add(acc.notFormedNum, qty);
|
|
|
}
|
|
}
|
|
|
- } else if (item.extInfo.isLoss == 1) {
|
|
|
|
|
- // lossNum = this.add(lossNum, Number(item.feedQuantity));
|
|
|
|
|
- lossNum = lossNum + Number(item.feedQuantity);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
- console.log(formedNum, "formedNumformedNumformedNum");
|
|
|
|
|
-
|
|
|
|
|
- this.$set(this.item.workReportInfo, "formedNum", formedNum);
|
|
|
|
|
- this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
|
|
|
|
|
- this.$set(this.item.workReportInfo, "lossQuantity", lossNum);
|
|
|
|
|
|
|
+ return acc;
|
|
|
|
|
+ },
|
|
|
|
|
+ { formedNum: 0, notFormedNum: 0, lossNum: 0 }
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
- // console.log(this.item.workReportInfo);
|
|
|
|
|
- this.item.workReportInfo = this.deepCopy(this.item.workReportInfo);
|
|
|
|
|
|
|
+ this.$set(this.item.workReportInfo, "formedNum", result.formedNum);
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.item.workReportInfo,
|
|
|
|
|
+ "notFormedNum",
|
|
|
|
|
+ result.notFormedNum
|
|
|
|
|
+ );
|
|
|
|
|
+ this.$set(this.item.workReportInfo, "lossQuantity", result.lossNum);
|
|
|
this.$forceUpdate();
|
|
this.$forceUpdate();
|
|
|
}
|
|
}
|
|
|
|
|
+ // if (newVal.product && newVal.product.length != 0) {
|
|
|
|
|
+ // let formedNum = 0;
|
|
|
|
|
+ // let notFormedNum = 0;
|
|
|
|
|
+ // let lossNum = 0;
|
|
|
|
|
+
|
|
|
|
|
+ // newVal.product.forEach((item) => {
|
|
|
|
|
+ // if (
|
|
|
|
|
+ // (!item.extInfo.isQualified ||
|
|
|
|
|
+ // item.extInfo.isQualified == 1 ||
|
|
|
|
|
+ // item.extInfo.isQualified == 3) &&
|
|
|
|
|
+ // !item.extInfo.isLoss
|
|
|
|
|
+ // ) {
|
|
|
|
|
+ // formedNum = formedNum + Number(item.feedQuantity);
|
|
|
|
|
+ // // formedNum = this.add(formedNum, Number(item.feedQuantity));
|
|
|
|
|
+ // } else if (!item.extInfo.isLoss) {
|
|
|
|
|
+ // if (item.extInfo.notType == 5 || item.extInfo.notType == 8) {
|
|
|
|
|
+ // formedNum = formedNum + Number(item.feedQuantity);
|
|
|
|
|
+
|
|
|
|
|
+ // // formedNum = this.add(formedNum, Number(item.feedQuantity));
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // notFormedNum = notFormedNum + Number(item.feedQuantity);
|
|
|
|
|
+ // // if (!item.extInfo.isLoss) {
|
|
|
|
|
+ // // notFormedNum = this.add(
|
|
|
|
|
+ // // notFormedNum,
|
|
|
|
|
+ // // Number(item.feedQuantity)
|
|
|
|
|
+ // // );
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // } else if (item.extInfo.isLoss == 1) {
|
|
|
|
|
+ // // lossNum = this.add(lossNum, Number(item.feedQuantity));
|
|
|
|
|
+ // lossNum = lossNum + Number(item.feedQuantity);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+
|
|
|
|
|
+ // console.log(formedNum, "formedNumformedNumformedNum");
|
|
|
|
|
+
|
|
|
|
|
+ // this.$set(this.item.workReportInfo, "formedNum", formedNum);
|
|
|
|
|
+ // this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
|
|
|
|
|
+ // this.$set(this.item.workReportInfo, "lossQuantity", lossNum);
|
|
|
|
|
+
|
|
|
|
|
+ // // console.log(this.item.workReportInfo);
|
|
|
|
|
+ // this.item.workReportInfo = this.deepCopy(this.item.workReportInfo);
|
|
|
|
|
+ // this.$forceUpdate();
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
// if (
|
|
// if (
|
|
|
// this.clientEnvironmentId == 3 &&
|
|
// this.clientEnvironmentId == 3 &&
|
|
@@ -630,6 +679,38 @@ export default {
|
|
|
return (num.toString().split(".")[1] || "").length;
|
|
return (num.toString().split(".")[1] || "").length;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ 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;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
singleBatchTg() {
|
|
singleBatchTg() {
|
|
|
if (!this.item.workReportInfo.formedNum)
|
|
if (!this.item.workReportInfo.formedNum)
|
|
|
return uni.showToast({
|
|
return uni.showToast({
|