Просмотр исходного кода

修复质检工单合格数不能输小数的问题

695593266@qq.com 8 месяцев назад
Родитель
Сommit
fa268708c7
2 измененных файлов с 331 добавлено и 312 удалено
  1. 27 8
      src/views/inspectionWork/components/baseInfo.vue
  2. 304 304
      yarn.lock

+ 27 - 8
src/views/inspectionWork/components/baseInfo.vue

@@ -168,9 +168,8 @@
             v-if="showArrange == '1'"
           >
             <el-input
-              type="number"
               :min="0"
-              @input="limitation('qualifiedNumber')"
+              @input="limitation('qualifiedNumber', form.qualifiedNumber)"
               @blur="quantityCalculation('qualifiedNumber')"
               v-model="form.qualifiedNumber"
               placeholder="请输入"
@@ -184,9 +183,8 @@
             v-if="showArrange == '1'"
           >
             <el-input
-              type="number"
               :min="0"
-              @input="limitation('noQualifiedNumber')"
+              @input="limitation('noQualifiedNumber', form.noQualifiedNumber)"
               @blur="quantityCalculation('noQualifiedNumber')"
               v-model="form.noQualifiedNumber"
               placeholder="请输入"
@@ -511,9 +509,30 @@
         });
       },
       // *** 只能输入大于0的数字
-      limitation(val) {
-        this.form[val] =
-          this.form[val].replace(/[^\d]/g, '').replace(/^0+/, '') || '0';
+      limitation(val, num) {
+        let newVal = num.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,9})?/);
+        if (val == 'qualifiedNumber') {
+          this.form.qualifiedNumber = match ? match[0] : '';
+        }
+
+        if (val == 'noQualifiedNumber') {
+          this.form.noQualifiedNumber = match ? match[0] : '';
+        }
+        // this.form[val] =
+        //   this.form[val].replace(/[^\d]/g, '').replace(/^0+/, '') || '0';
       },
       // *** 计算合格数 不合格数
       quantityCalculation(e, noSetSampleList) {
@@ -710,7 +729,7 @@
       },
       //抽检需要重新计算
       selectResult() {
-        console.log(this.form.qualityMode,'this.form.qualityMode')
+        console.log(this.form.qualityMode, 'this.form.qualityMode');
         if (this.form.qualityMode == 2) {
           this.$emit('quantityAssignment');
         }

Разница между файлами не показана из-за своего большого размера
+ 304 - 304
yarn.lock


Некоторые файлы не были показаны из-за большого количества измененных файлов