Sfoglia il codice sorgente

Merge branch 'feature_20250926_数字题型&单行文本题型' into uat(dev)

# Conflicts:
#	src/views/deviceWithin/addStoreVisit.vue
zhujindu 1 mese fa
parent
commit
a5e8d7cac0
1 ha cambiato i file con 71 aggiunte e 40 eliminazioni
  1. 71 40
      src/views/deviceWithin/addStoreVisit.vue

+ 71 - 40
src/views/deviceWithin/addStoreVisit.vue

@@ -3518,6 +3518,7 @@ export default {
       currentDate: new Date(1945, 0, 1),
       continuousShoot: '0',
       machineInTheStore: '否',
+      validatorFlag: true, //是否验证通过
     };
   },
   beforeRouteLeave(to, from, next) {
@@ -4003,22 +4004,26 @@ export default {
         let maxValue = item.collectionOptionList[0].maxValue;
         if (maxValue && maxValue != '') {
           if (value > Number(maxValue)) {
-            this.$set(itemData, 'ruleMessage', '最大输入值为:' + maxValue);
-            this.$set(itemData, 'answerValue', '');
-            this.$toast('输入内容不合法');
+            this.$set(itemData, 'ruleMessage', '最大值为:' + maxValue);
+            // this.$set(itemData, 'answerValue', '');
+            // this.$toast('输入内容不合法');
+            this.validatorFlag = false;
+            return;
           }
         }
         //最小值
         let minValue = item.collectionOptionList[0].minValue;
         if (minValue && minValue != '') {
           if (value < Number(minValue)) {
-            this.$set(itemData, 'ruleMessage', '最小输入值为:' + minValue);
-            this.$set(itemData, 'answerValue', '');
-            this.$toast('输入内容不合法');
+            this.$set(itemData, 'ruleMessage', '最小值为:' + minValue);
+            // this.$set(itemData, 'answerValue', '');
+            // this.$toast('输入内容不合法');
+            this.validatorFlag = false;
+            return;
           }
         }
       } else {
-        this.$set(itemData, 'ruleMessage', '请输入数字');
+        // this.$set(itemData, 'ruleMessage', '请输入数字');
       }
     },
     // dhwb 单行文本校验
@@ -4039,9 +4044,10 @@ export default {
         let maxValue = item.collectionOptionList[0].maxValue;
         if (maxValue && maxValue != '') {
           if (value.length > Number(maxValue)) {
-            this.$set(itemData, 'answerValue', '');
-            this.$set(itemData, 'ruleMessage', '最大输入值为:' + maxValue);
-            this.$toast('输入内容不合法');
+            // this.$set(itemData, 'answerValue', '');
+            this.$set(itemData, 'ruleMessage', '最大字数为:' + maxValue);
+            // this.$toast('输入内容不合法');
+            this.validatorFlag = false;
             return;
           }
         }
@@ -4049,9 +4055,10 @@ export default {
         let minValue = item.collectionOptionList[0].minValue;
         if (minValue && minValue != '') {
           if (value.length < Number(minValue)) {
-            this.$set(itemData, 'answerValue', '');
-            this.$set(itemData, 'ruleMessage', '最小输入值为:' + minValue);
-            this.$toast('输入内容不合法');
+            // this.$set(itemData, 'answerValue', '');
+            this.$set(itemData, 'ruleMessage', '最小字数为:' + minValue);
+            // this.$toast('输入内容不合法');
+            this.validatorFlag = false;
             return;
           }
         }
@@ -4059,15 +4066,16 @@ export default {
         let leastOneChinese = item.collectionOptionList[0].leastOneChinese;
         if (leastOneChinese == '1') {
           if (!/[\u4e00-\u9fa5]/.test(value)) {
-            this.$set(itemData, 'answerValue', '');
+            // this.$set(itemData, 'answerValue', '');
             this.$set(itemData, 'ruleMessage', '至少有一个汉字');
-            this.$toast('输入内容不合法,至少有一个汉字');
+            // this.$toast('输入内容不合法,至少有一个汉字');
+            this.validatorFlag = false;
             return;
           }
         }
         this.$set(itemData, 'ruleMessage', '');
       } else {
-        this.$set(itemData, 'ruleMessage', '请输入至少有一个汉字');
+        // this.$set(itemData, 'ruleMessage', '请输入至少有一个汉字');
       }
     },
     // 且只可输入:汉字、数字、字母、标点符号, 特殊字符:空格、换行、表情等不可输入
@@ -4207,14 +4215,14 @@ export default {
                 }
               }
             }
-            // dhwb 初始化内容校验
-            if (collectionItemLists[q].answerType == 'dhwb') {
-              this.DHWBsizeComparison(collectionItemLists[q], 'A');
-            }
-            // sz 初始化内容校验
-            if (collectionItemLists[q].answerType == 'sz') {
-              this.SZsizeComparison(collectionItemLists[q], 'A');
-            }
+            // // dhwb 初始化内容校验
+            // if (collectionItemLists[q].answerType == 'dhwb') {
+            //   this.DHWBsizeComparison(collectionItemLists[q], 'A');
+            // }
+            // // sz 初始化内容校验
+            // if (collectionItemLists[q].answerType == 'sz') {
+            //   this.SZsizeComparison(collectionItemLists[q], 'A');
+            // }
             if (
               collectionItemLists[q].answerType == 'duox' ||
               collectionItemLists[q].answerType == 'dx'
@@ -4251,14 +4259,14 @@ export default {
                           listchild[qq1].answerValue = '';
                         }
                       }
-                      // dhwb 初始化内容校验
-                      if (listchild[qq1].answerType == 'dhwb') {
-                        this.DHWBsizeComparison(listchild[qq1]);
-                      }
-                      // sz 初始化内容校验
-                      if (listchild[qq1].answerType == 'sz') {
-                        this.SZsizeComparison(listchild[qq1]);
-                      }
+                      // // dhwb 初始化内容校验
+                      // if (listchild[qq1].answerType == 'dhwb') {
+                      //   this.DHWBsizeComparison(listchild[qq1]);
+                      // }
+                      // // sz 初始化内容校验
+                      // if (listchild[qq1].answerType == 'sz') {
+                      //   this.SZsizeComparison(listchild[qq1]);
+                      // }
                       if (listchild[qq1].answerType == 'sm') {
                         listchild[qq1].success = false;
                         if (listchild[qq1].collectionOptionList[0].answerValue != null) {
@@ -4399,14 +4407,14 @@ export default {
                                   list3[l3].collectionItems[l3q].answerValue = '';
                                 }
                               }
-                              // dhwb 初始化内容校验
-                              if (list3[l3].collectionItems[l3q].answerType == 'dhwb') {
-                                this.DHWBsizeComparison(list3[l3].collectionItems[l3q]);
-                              }
-                              // sz 初始化内容校验
-                              if (list3[l3].collectionItems[l3q].answerType == 'sz') {
-                                this.SZsizeComparison(list3[l3].collectionItems[l3q]);
-                              }
+                              // // dhwb 初始化内容校验
+                              // if (list3[l3].collectionItems[l3q].answerType == 'dhwb') {
+                              //   this.DHWBsizeComparison(list3[l3].collectionItems[l3q]);
+                              // }
+                              // // sz 初始化内容校验
+                              // if (list3[l3].collectionItems[l3q].answerType == 'sz') {
+                              //   this.SZsizeComparison(list3[l3].collectionItems[l3q]);
+                              // }
                             }
                           }
                           // console.log(list3[l3])
@@ -5145,7 +5153,27 @@ export default {
         }
       }
     },
+    filterCollectionInfos(collectionItemList, type) {
+      if (
+        (collectionItemList.answerType == 'dx' || collectionItemList.answerType == 'duox') &&
+        collectionItemList.collectionOptionList
+      ) {
+        for (let x = 0; x < collectionItemList.collectionOptionList.length; x++) {
+          this.filterCollectionInfos(collectionItemList.collectionOptionList[x]);
+        }
+      } else {
+        // dhwb 初始化内容校验
+        if (collectionItemList.answerType == 'dhwb') {
+          this.DHWBsizeComparison(collectionItemList, type);
+        }
+        // sz 初始化内容校验
+        if (collectionItemList.answerType == 'sz') {
+          this.SZsizeComparison(collectionItemList, type);
+        }
+      }
+    },
     onSubmit() {
+      this.validatorFlag = true;
       var checkUnManage = 'Y';
       var formData = {};
       if (this.checked) {
@@ -5184,6 +5212,7 @@ export default {
 
       if (this.$route.query.taskType == 1 || this.$route.query.taskType == 4) {
         for (var b = 0; b < this.collectionItemList.length; b++) {
+          this.filterCollectionInfos(this.collectionItemList[b], 'A');
           if (
             this.collectionItemList[b].answerType == 'sz' ||
             this.collectionItemList[b].answerType == 'sm' ||
@@ -5664,6 +5693,8 @@ export default {
           }
         }
       }
+      // 特殊题型判断是否通过
+      if (!this.validatorFlag) return;
       // 调色机扫码是否正确
       if (!this.filterFormData(formData)) {
         this.$dialog.alert({