Browse Source

feature_20250926_数字题型&单行文本题型

zhujindu 2 months ago
parent
commit
14d26f3d43
1 changed files with 18 additions and 22 deletions
  1. 18 22
      src/views/deviceWithin/addStoreVisit.vue

+ 18 - 22
src/views/deviceWithin/addStoreVisit.vue

@@ -3577,29 +3577,25 @@ export default {
       }
       }
     },
     },
     numberFn(val, index, type) {
     numberFn(val, index, type) {
-      if (type == 'A') {
-        if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(this.collectionItemList[index].answerValue)) {
-          this.collectionItemList[index].answerValue = this.collectionItemList[
-            index
-          ].answerValue.replace(
-            /\.\d{2,}$/,
-            this.collectionItemList[index].answerValue.substr(
-              this.collectionItemList[index].answerValue.indexOf('.'),
-              3
-            )
-          );
+      let value = this.collectionItemList[index].answerValue;
+      if (value && !/^[+-]?\d*\.{0,1}\d{0,1}$/.test(value)) {
+        value = this.collectionItemList[index].answerValue.replace(
+          /\.\d{2,}$/,
+          value.substr(value.indexOf('.'), 3)
+        );
+        // 最大值
+        let maxValue = this.collectionItemList[index].collectionOptionList[0].maxValue;
+        if (maxValue) {
+          if (value > maxValue) {
+            this.$toast(this.collectionItemList[index].collectionName + '输入内容不合法');
+          }
         }
         }
-      } else {
-        if (!/^[+-]?\d*\.{0,1}\d{0,1}$/.test(this.collectionItemList[index].answerValue)) {
-          this.collectionItemList[index].answerValue = this.collectionItemList[
-            index
-          ].answerValue.replace(
-            /\.\d{2,}$/,
-            this.collectionItemList[index].answerValue.substr(
-              this.collectionItemList[index].answerValue.indexOf('.'),
-              3
-            )
-          );
+        //最小值
+        let minValue = this.collectionItemList[index].collectionOptionList[0].minValue;
+        if (minValue) {
+          if (value < minValue) {
+            this.$toast(this.collectionItemList[index].collectionName + '输入内容不合法');
+          }
         }
         }
       }
       }
     },
     },