Sfoglia il codice sorgente

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

zhujindu 2 mesi fa
parent
commit
f42b342d30
1 ha cambiato i file con 102 aggiunte e 20 eliminazioni
  1. 102 20
      src/views/deviceWithin/addStoreVisit.vue

+ 102 - 20
src/views/deviceWithin/addStoreVisit.vue

@@ -262,6 +262,9 @@
               v-model="item.answerValue"
               :placeholder="item.collectionOptionList[0].collectionOption"
               @blur="SZsizeComparison(item, 'A')"></van-field>
+            <p v-if="item.ruleMessage" class="ruleMessage">
+              {{ item.ruleMessage }}
+            </p>
             <delete-upload-img
               :photoIdentifyType="photoIdentifyType"
               :imgs="item.fileInfoList"></delete-upload-img>
@@ -451,6 +454,9 @@
               :formatter="dhwbFormatter"
               @blur="DHWBsizeComparison(item, 'A')"
               :placeholder="item.collectionOptionList[0].collectionOption"></van-field>
+            <p v-if="item.ruleMessage" class="ruleMessage">
+              {{ item.ruleMessage }}
+            </p>
             <p
               style="
                 color: #444;
@@ -764,6 +770,9 @@
                         :placeholder="
                           childitem.collectionOptionList[0].collectionOption
                         "></van-field>
+                      <p v-if="childitem.collectionOptionList[0].ruleMessage" class="ruleMessage">
+                        {{ childitem.collectionOptionList[0].ruleMessage }}
+                      </p>
                       <p
                         style="
                           color: #444;
@@ -811,6 +820,9 @@
                         v-model="childitem.collectionOptionList[0].answerValue"
                         :placeholder="childitem.collectionOptionList[0].collectionOption"
                         @blur="SZsizeComparison(childitem)"></van-field>
+                      <p v-if="childitem.collectionOptionList[0].ruleMessage" class="ruleMessage">
+                        {{ childitem.collectionOptionList[0].ruleMessage }}
+                      </p>
                       <delete-upload-img
                         :photoIdentifyType="photoIdentifyType"
                         :imgs="childitem.fileInfoList"></delete-upload-img>
@@ -1178,6 +1190,11 @@
                                   :placeholder="
                                     childitem1.collectionOptionList[0].collectionOption
                                   "></van-field>
+                                <p
+                                  v-if="childitem1.collectionOptionList[0].ruleMessage"
+                                  class="ruleMessage">
+                                  {{ childitem1.collectionOptionList[0].ruleMessage }}
+                                </p>
                                 <p
                                   style="
                                     color: #444;
@@ -1601,6 +1618,11 @@
                                             :placeholder="
                                               child33item1.collectionOptionList[0].collectionOption
                                             "></van-field>
+                                          <p
+                                            v-if="child33item1.collectionOptionList[0].ruleMessage"
+                                            class="ruleMessage">
+                                            {{ child33item1.collectionOptionList[0].ruleMessage }}
+                                          </p>
                                           <p
                                             style="
                                               color: #444;
@@ -1902,6 +1924,11 @@
                                               child33item1.collectionOptionList[0].collectionOption
                                             "
                                             @blur="SZsizeComparison(child33item1)"></van-field>
+                                          <p
+                                            v-if="child33item1.collectionOptionList[0].ruleMessage"
+                                            class="ruleMessage">
+                                            {{ child33item1.collectionOptionList[0].ruleMessage }}
+                                          </p>
                                           <delete-upload-img
                                             :photoIdentifyType="photoIdentifyType"
                                             :imgs="child33item1.fileInfoList"></delete-upload-img>
@@ -2356,6 +2383,17 @@
                                                         child44item1.collectionOptionList[0]
                                                           .collectionOption
                                                       "></van-field>
+                                                    <p
+                                                      v-if="
+                                                        child44item1.collectionOptionList[0]
+                                                          .ruleMessage
+                                                      "
+                                                      class="ruleMessage">
+                                                      {{
+                                                        child44item1.collectionOptionList[0]
+                                                          .ruleMessage
+                                                      }}
+                                                    </p>
                                                     <p
                                                       style="
                                                         color: #444;
@@ -2692,6 +2730,17 @@
                                                       @blur="
                                                         SZsizeComparison(child44item1)
                                                       "></van-field>
+                                                    <p
+                                                      v-if="
+                                                        child44item1.collectionOptionList[0]
+                                                          .ruleMessage
+                                                      "
+                                                      class="ruleMessage">
+                                                      {{
+                                                        child44item1.collectionOptionList[0]
+                                                          .ruleMessage
+                                                      }}
+                                                    </p>
                                                     <delete-upload-img
                                                       :photoIdentifyType="photoIdentifyType"
                                                       :imgs="
@@ -3085,6 +3134,11 @@
                                   v-model="childitem1.collectionOptionList[0].answerValue"
                                   :placeholder="childitem1.collectionOptionList[0].collectionOption"
                                   @blur="SZsizeComparison(childitem1)"></van-field>
+                                <p
+                                  v-if="childitem1.collectionOptionList[0].ruleMessage"
+                                  class="ruleMessage">
+                                  {{ childitem1.collectionOptionList[0].ruleMessage }}
+                                </p>
                                 <delete-upload-img
                                   :photoIdentifyType="photoIdentifyType"
                                   :imgs="childitem1.fileInfoList"></delete-upload-img>
@@ -3931,20 +3985,19 @@ export default {
         answerValue = item.collectionOptionList[0].answerValue;
         itemData = item.collectionOptionList[0];
       }
-      let value = answerValue.replace(
-        /[^-\d.]|(?<!\d)\.|\.(?!\d)|^[.]$|^[+-]$|^[+-]\.$|(?<=\.\d*)\.|(?<=\d\.\d*)\.(?=\d)/g,
-        ''
-      );
+      let value = answerValue
+        ? answerValue.replace(
+            /[^-\d.]|(?<!\d)\.|\.(?!\d)|^[.]$|^[+-]$|^[+-]\.$|(?<=\.\d*)\.|(?<=\d\.\d*)\.(?=\d)/g,
+            ''
+          )
+        : '';
       this.$set(itemData, 'answerValue', value);
       if (value) {
         // 最大值
         let maxValue = item.collectionOptionList[0].maxValue;
         if (maxValue && maxValue != '') {
           if (value > Number(maxValue)) {
-            // this.collectionItemList[index].answerValue = value.slice(0, -1);
-            // this.$toast(
-            //   this.collectionItemList[index].collectionName + '最大输入值为:' + maxValue
-            // );
+            this.$set(itemData, 'ruleMessage', '最大输入值为:' + maxValue);
             this.$set(itemData, 'answerValue', '');
             this.$toast('输入内容不合法');
           }
@@ -3953,14 +4006,13 @@ export default {
         let minValue = item.collectionOptionList[0].minValue;
         if (minValue && minValue != '') {
           if (value < Number(minValue)) {
-            // this.collectionItemList[index].answerValue = minValue;
-            // this.$toast(
-            //   this.collectionItemList[index].collectionName + '最小输入值为:' + minValue
-            // );
+            this.$set(itemData, 'ruleMessage', '最小输入值为:' + minValue);
             this.$set(itemData, 'answerValue', '');
             this.$toast('输入内容不合法');
           }
         }
+      } else {
+        this.$set(itemData, 'ruleMessage', '请输入数字');
       }
     },
     // dhwb 单行文本校验
@@ -3981,24 +4033,20 @@ export default {
         let maxValue = item.collectionOptionList[0].maxValue;
         if (maxValue && maxValue != '') {
           if (value.length > Number(maxValue)) {
-            // this.collectionItemList[index].answerValue = value.slice(0, -1);
-            // this.$toast(
-            //   this.collectionItemList[index].collectionName + '最大输入值为:' + maxValue
-            // );
             this.$set(itemData, 'answerValue', '');
+            this.$set(itemData, 'ruleMessage', '最大输入值为:' + maxValue);
             this.$toast('输入内容不合法');
+            return;
           }
         }
         //最小值
         let minValue = item.collectionOptionList[0].minValue;
         if (minValue && minValue != '') {
           if (value.length < Number(minValue)) {
-            // this.collectionItemList[index].answerValue = minValue;
-            // this.$toast(
-            //   this.collectionItemList[index].collectionName + '最小输入值为:' + minValue
-            // );
             this.$set(itemData, 'answerValue', '');
+            this.$set(itemData, 'ruleMessage', '最小输入值为:' + minValue);
             this.$toast('输入内容不合法');
+            return;
           }
         }
         // 至少一个汉字
@@ -4006,9 +4054,14 @@ export default {
         if (leastOneChinese == '1') {
           if (!/[\u4e00-\u9fa5]/.test(value)) {
             this.$set(itemData, 'answerValue', '');
+            this.$set(itemData, 'ruleMessage', '至少有一个汉字');
             this.$toast('输入内容不合法,至少有一个汉字');
+            return;
           }
         }
+        this.$set(itemData, 'ruleMessage', '');
+      } else {
+        this.$set(itemData, 'ruleMessage', '请输入至少有一个汉字');
       }
     },
     // 且只可输入:汉字、数字、字母、标点符号, 特殊字符:空格、换行、表情等不可输入
@@ -4148,6 +4201,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');
+            }
             if (
               collectionItemLists[q].answerType == 'duox' ||
               collectionItemLists[q].answerType == 'dx'
@@ -4184,6 +4245,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]);
+                      }
                       if (listchild[qq1].answerType == 'sm') {
                         listchild[qq1].success = false;
                         if (listchild[qq1].collectionOptionList[0].answerValue != null) {
@@ -4324,6 +4393,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]);
+                              }
                             }
                           }
                           // console.log(list3[l3])
@@ -5905,5 +5982,10 @@ export default {
       height: 35px;
     }
   }
+  .ruleMessage {
+    color: red;
+    font-size: 12px;
+    margin: 3px 0;
+  }
 }
 </style>