Kaynağa Gözat

修改聚仁bug

695593266@qq.com 9 ay önce
ebeveyn
işleme
4d76011bcc

+ 20 - 2
src/views/produce/components/feeding/components/batchProductsBom.vue

@@ -80,7 +80,7 @@
           <el-input v-model="form.batchNo"></el-input>
         </el-form-item>
         <el-form-item label="拆批数">
-          <el-input v-model="form.quantity"></el-input>
+          <el-input v-model="form.quantity" @input="batchInput"></el-input>
         </el-form-item>
       </el-form>
       <span slot="footer" class="dialog-footer">
@@ -270,6 +270,24 @@
         this.dialogVisible = true;
       },
 
+      batchInput(val) {
+        let newVal = val.replace(/[^\d.]/g, '');
+
+        if (newVal.startsWith('.')) {
+          newVal = '';
+        }
+
+        const firstDotIndex = newVal.indexOf('.');
+        if (firstDotIndex !== -1) {
+          newVal =
+            newVal.slice(0, firstDotIndex + 1) +
+            newVal.slice(firstDotIndex + 1).replace(/\./g, '');
+        }
+
+        const match = newVal.match(/^(\d+)(\.\d{0,4})?/);
+        this.form.quantity = match ? match[0] : '';
+      },
+
       async getQualityParam() {
         if (this.form.quantity && this.form.batchNo) {
           if (Number(this.itemData.feedQuantity) == 0) {
@@ -305,7 +323,7 @@
         //   Number(this.form.quantity);
         const number = this.sub(
           Number(this.list[this.itemIndex].feedQuantity),
-          Number(this.batchForm.quantity)
+          Number(this.form.quantity)
         );
         this.list[this.itemIndex].extInfo.sourceQuantity = number;
         this.list[this.itemIndex].feedQuantity = number;

+ 45 - 28
src/views/produce/components/jobBooking/components/batchSemiProductJobBom.vue

@@ -552,6 +552,7 @@
           <el-input
             v-model="batchForm.quantity"
             style="width: 220px"
+            @change="batchInput"
           ></el-input>
           {{ batchForm.unit }}
         </el-form-item>
@@ -648,7 +649,11 @@
           <el-input v-model="lossForm.batchNo" style="width: 220px"></el-input>
         </el-form-item>
         <el-form-item label="损耗数">
-          <el-input v-model="lossForm.quantity" style="width: 220px"></el-input>
+          <el-input
+            v-model="lossForm.quantity"
+            style="width: 220px"
+            @input="lossInput"
+          ></el-input>
           {{ lossForm.unit }}
         </el-form-item>
       </el-form>
@@ -1268,13 +1273,13 @@
 
         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(2)
+            lossWeight.toFixed(4)
           );
         }
 
@@ -1413,20 +1418,26 @@
         this.batchVisible = true;
       },
 
+      batchInput(val) {
+        let newVal = val.replace(/[^\d.]/g, '');
+
+        if (newVal.startsWith('.')) {
+          newVal = '';
+        }
+
+        const firstDotIndex = newVal.indexOf('.');
+        if (firstDotIndex !== -1) {
+          newVal =
+            newVal.slice(0, firstDotIndex + 1) +
+            newVal.slice(firstDotIndex + 1).replace(/\./g, '');
+        }
+
+        const match = newVal.match(/^(\d+)(\.\d{0,4})?/);
+        this.batchForm.quantity = match ? match[0] : '';
+      },
+
       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;
@@ -1546,20 +1557,26 @@
         this.lossVisible = true;
       },
 
+      lossInput(val) {
+        let newVal = val.replace(/[^\d.]/g, '');
+
+        if (newVal.startsWith('.')) {
+          newVal = '';
+        }
+
+        const firstDotIndex = newVal.indexOf('.');
+        if (firstDotIndex !== -1) {
+          newVal =
+            newVal.slice(0, firstDotIndex + 1) +
+            newVal.slice(firstDotIndex + 1).replace(/\./g, '');
+        }
+
+        const match = newVal.match(/^(\d+)(\.\d{0,4})?/);
+        this.lossForm.quantity = match ? match[0] : '';
+      },
+
       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)
           ) {

+ 2 - 2
src/views/produce/components/jobBooking/components/jobBom.vue

@@ -110,7 +110,7 @@
 
         <div class="item rx-sc">
           <div class="rx ww40">
-            <div class="lable lable100 rx-cc">损耗数</div>
+            <div class="lable lable100 rx-cc">损耗数</div>
             <div class="content content_num rx-sc">
               <el-input
                 size="mini"
@@ -124,7 +124,7 @@
           </div>
 
           <div class="rx ww40">
-            <div class="lable rx-cc">损耗数重量</div>
+            <div class="lable rx-cc">重量</div>
             <div class="content content_num rx-sc">
               <el-input
                 size="mini"

+ 2 - 2
src/views/produce/components/jobBooking/components/semiProductJobBom.vue

@@ -1033,10 +1033,10 @@
 
           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)
             );
           }
         }