695593266@qq.com 8 месяцев назад
Родитель
Сommit
6ab769bcb3

+ 89 - 6
pages/pda/jobBooking/components/batchJobBom.vue

@@ -147,6 +147,38 @@
           </view>
         </view>
 
+        <view class="item rx-sc">
+          <view class="rx ww55">
+            <view class="lable lable150 rx-cc">损耗数量</view>
+            <view class="content content_num">
+              <!-- //详情 -->
+              <input
+                class="uni-input"
+                v-model="item.workReportInfo.lossQuantity"
+                type="digit"
+                :disabled="isDetails"
+                @input="changeNum(item.workReportInfo.lossQuantity)"
+              />
+
+              <view class="unit">{{ item.unit }}</view>
+            </view>
+          </view>
+
+          <view class="rx ww45">
+            <view class="lable rx-cc ww80">重量</view>
+            <view class="content content_num">
+              <input
+                class="uni-input"
+                v-model="item.workReportInfo.lossWeight"
+                type="digit"
+                :disabled="isDetails"
+              />
+
+              <view class="unit">{{ item.weightUnit }}</view>
+            </view>
+          </view>
+        </view>
+
         <view class="item rx-sc">
           <view class="rx ww55">
             <view class="lable lable150 rx-cc">报工备注</view>
@@ -306,23 +338,42 @@ export default {
         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.isQualified ||
+                item.extInfo.isQualified == 1 ||
+                item.extInfo.isQualified == 3) &&
+              !item.extInfo.isLoss
             ) {
               formedNum = formedNum + Number(item.feedQuantity);
-            } else {
-              notFormedNum = notFormedNum + 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, "不合格数量:" + notFormedNum);
+          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);
@@ -547,6 +598,38 @@ export default {
       });
     },
 
+    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() {
       if (!this.item.workReportInfo.formedNum)
         return uni.showToast({

+ 199 - 5
pages/pda/jobBooking/components/batchProductJobBom.vue

@@ -219,7 +219,7 @@
 
             <view class="content content_num">
               <view v-if="isDetails">{{ it.feedQuantity }}</view>
-              <view>{{ it.feedQuantity }}</view>
+              <input class="uni-input" v-else v-model="it.feedQuantity" />
             </view>
           </view>
         </view>
@@ -316,6 +316,16 @@
         </view>
 
         <view class="item rx-sc">
+          <view class="rx ww50">
+            <view class="lable lable150 rx-cc">损耗</view>
+            <view class="content content_num">
+              <view v-if="it.extInfo.isLoss && it.extInfo.isLoss == 1">是</view>
+              <view v-else>否</view>
+            </view>
+          </view>
+        </view>
+
+        <view class="item rx-sc" v-if="!isDetails">
           <view class="rx">
             <view class="lable lable150 rx-cc">操作</view>
             <view class="content rx-bc">
@@ -336,6 +346,20 @@
                   style="margin-left: 20px"
                   >删除</u-button
                 >
+
+                <u-button
+                  size="small"
+                  class="u-reset-button"
+                  type="warning"
+                  style="margin-left: 20px"
+                  @click="openLoss(it, idx)"
+                  v-if="
+                    ![2, 3, 6].includes(Number(item.currentTaskDiagram.type)) &&
+                    !it.extInfo.isLoss &&
+                    item.currentTaskDiagram.isFirstTask != 1
+                  "
+                  >损耗</u-button
+                >
               </view>
             </view>
           </view>
@@ -641,6 +665,37 @@
         </view>
       </view>
     </uni-popup>
+
+    <uni-popup ref="lossDialog" type="center" :animation="false">
+      <view class="popup-content">
+        <view style="font-size: 18px; margin-bottom: 10px">损耗数</view>
+        <uni-forms
+          ref="lossForm"
+          :modelValue="lossForm"
+          label-position="left"
+          label-align="center"
+        >
+          <uni-forms-item label="批次号:" label-width="100" prop="batchNo">
+            <uni-easyinput
+              v-model="lossForm.batchNo"
+              placeholder="请输入批次号"
+            />
+          </uni-forms-item>
+
+          <uni-forms-item label="损耗数:" label-width="100" prop="quantity">
+            <uni-easyinput
+              v-model="lossForm.quantity"
+              placeholder="请输入损耗数"
+            />
+          </uni-forms-item>
+        </uni-forms>
+
+        <view class="button-group">
+          <button type="primary" size="mini" @click="handleClose">取消</button>
+          <button type="primary" size="mini" @click="getLossParam">确定</button>
+        </view>
+      </view>
+    </uni-popup>
   </view>
 </template>
 
@@ -794,6 +849,15 @@ export default {
       },
       bacthData: {},
       bacthIndex: "",
+      lossForm: {
+        batchNo: "",
+        quantity: "",
+        unit: "",
+        isLoss: 1,
+      },
+      lossVisible: false,
+      lossData: {},
+      lossIndex: "",
     };
   },
   created() {
@@ -926,14 +990,41 @@ export default {
       // console.log('this.list33333',this.list)
     },
     sumweight(arr) {
+      // let formedWeight = 0;
+      // let noFormedWeight = 0;
+      // arr.map((s, i) => {
+      //   if (s.extInfo.reportWeight) {
+      //     if (s.extInfo.isQualified == 1) {
+      //       formedWeight += s.extInfo.reportWeight * 1;
+      //     } else {
+      //       noFormedWeight += s.extInfo.reportWeight * 1;
+      //     }
+      //   } else {
+      //     s.extInfo.reportWeight = null;
+      //   }
+      //   this.$set(this.list[i].extInfo, "reportWeight", s.extInfo.reportWeight);
+      // });
+
+      // if (this.item.workReportInfo) {
+      //   this.item.workReportInfo.formedWeight = parseFloat(
+      //     formedWeight.toFixed(4)
+      //   );
+      //   this.item.workReportInfo.notFormedWeight = parseFloat(
+      //     noFormedWeight.toFixed(4)
+      //   );
+      // }
+
       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;
@@ -943,12 +1034,15 @@ export default {
 
       if (this.item.workReportInfo) {
         this.item.workReportInfo.formedWeight = parseFloat(
-          formedWeight.toFixed(2)
+          formedWeight.toFixed(4)
         );
         this.item.workReportInfo.notFormedWeight = parseFloat(
-          noFormedWeight.toFixed(2)
+          noFormedWeight.toFixed(4)
         );
+        this.item.workReportInfo.lossWeight = parseFloat(lossWeight.toFixed(4));
       }
+
+      console.log(this.item.workReportInfo, "this.item.workReportInfo");
     },
 
     sunTj() {
@@ -962,6 +1056,10 @@ export default {
       }
     },
 
+    openLoss(item, index) {},
+
+    getLossParam() {},
+
     cancel() {
       this.show = false;
       this.reportWeight = 0;
@@ -1022,7 +1120,9 @@ export default {
 
     handleClose() {
       this.$refs.inputDialog.close();
+      this.$refs.lossDialog.close();
     },
+
     async timeoutCauseConfirm() {
       if (!this.batchForm.quantity) {
         uni.showToast({
@@ -1103,6 +1203,100 @@ export default {
       this.$refs.inputDialog.close();
     },
 
+    openLoss(item, index) {
+      this.lossForm.quantity = "";
+      this.lossForm.unit = "";
+      this.lossForm.batchNo = "";
+      this.lossData = item;
+      this.lossIndex = index;
+      this.lossForm.batchNo = item.batchNo;
+      this.lossForm.unit = item.unit;
+      this.$refs.lossDialog.open();
+    },
+
+    async getLossParam() {
+      if (this.lossForm.quantity && this.lossForm.batchNo) {
+        if (
+          Number(this.lossData.feedQuantity) < Number(this.lossForm.quantity)
+        ) {
+          this.$message.warning("损耗数不能大于数量");
+          return;
+        }
+
+        let dataList = [];
+        await splitBatch({
+          product: this.lossData,
+          splitQt: Number(this.lossForm.quantity),
+          batchNo: this.lossForm.batchNo,
+          isLoss: 1,
+        }).then((res) => {
+          res.forEach((item) => {
+            dataList.push(this.deepCopy(item));
+          });
+
+          if (dataList.length != 0) {
+            this.refreshLossData(dataList);
+          }
+        });
+      }
+
+      this.$refs.lossDialog.close();
+    },
+
+    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;
+    },
+
+    refreshLossData(list) {
+      const number =
+        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 =
+        (Number(this.list[this.lossIndex].extInfo.newWeight) * 100000) /
+          100000 -
+        (Number(list[0].extInfo.newWeight) * 100000) / 100000;
+
+      list.forEach((item) => {
+        item.childBatch = 1;
+      });
+      const newList = this.list.filter((item) => item.feedQuantity != 0);
+      let _arr = [...newList, ...list];
+      this.$set(newList, newList.length, ...list);
+      this.$set(this.item, "product", _arr);
+      this.$forceUpdate();
+      this.$refs.inputDialog.close();
+    },
+
     isChange(val) {
       if (val == "合格") {
         this.batchForm.notType = "";

+ 32 - 0
pages/pda/jobBooking/components/jobBom.vue

@@ -122,6 +122,38 @@
             </view>
           </view>
         </view>
+
+        <view class="item rx-sc">
+          <view class="rx ww55">
+            <view class="lable lable150 rx-cc">损耗数量</view>
+            <view class="content content_num">
+              <!-- //详情 -->
+              <input
+                class="uni-input"
+                v-model="item.workReportInfo.lossQuantity"
+                type="digit"
+                :disabled="isDetails"
+                @input="changeNum(item.workReportInfo.lossQuantity)"
+              />
+
+              <view class="unit">{{ item.unit }}</view>
+            </view>
+          </view>
+
+          <view class="rx ww45">
+            <view class="lable rx-cc ww80">重量</view>
+            <view class="content content_num">
+              <input
+                class="uni-input"
+                v-model="item.workReportInfo.lossWeight"
+                type="digit"
+                :disabled="isDetails"
+              />
+
+              <view class="unit">{{ item.weightUnit }}</view>
+            </view>
+          </view>
+        </view>
         <view class="item rx-sc">
           <view class="rx ww55">
             <view class="lable lable150 rx-cc">报工备注</view>

+ 2 - 0
pages/pda/jobBooking/index/index.vue

@@ -847,6 +847,8 @@ export default {
             formedWeight: null,
             taskId: this.taskId,
             executorTime: "",
+            lossNum: null,
+            lossWeight: null,
           };
 
           this.objData.notFormedList = [