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

feature_20251201_门店拜访手机号验证bug修改

zhujindu 3 дней назад
Родитель
Сommit
4995079642
1 измененных файлов с 29 добавлено и 20 удалено
  1. 29 20
      src/views/deviceWithin/addStoreVisit.vue

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

@@ -4387,17 +4387,18 @@ export default {
         answerValue = item.collectionOptionList[0].answerValue;
         itemData = item.collectionOptionList[0];
       }
-      let value = answerValue 
-          ? answerValue.replace(/[^\d.-]/g, '') // 移除所有非法字符
-                .replace(/^\./, '') // 移除开头的小数点
-                .replace(/\.$/, '') // 移除结尾的小数点(如果需要)
-                // .replace(/(?<=.)-/g, '') // 移除除了开头位置外的所有负号
-                .replace(/^-/, 'NEGATIVE_MARKER')  // 先标记开头的负号
-                .replace(/-/g, '')                 // 移除所有负号
-                .replace(/NEGATIVE_MARKER/, '-')   // 恢复开头的负号
-                .replace(/\.+/g, '.') // 多个小数点合并为一个
-                .replace(/(\..*)\./g, '$1') // 只保留第一个小数点
-          : '';
+      let value = answerValue
+        ? answerValue
+            .replace(/[^\d.-]/g, '') // 移除所有非法字符
+            .replace(/^\./, '') // 移除开头的小数点
+            .replace(/\.$/, '') // 移除结尾的小数点(如果需要)
+            // .replace(/(?<=.)-/g, '') // 移除除了开头位置外的所有负号
+            .replace(/^-/, 'NEGATIVE_MARKER') // 先标记开头的负号
+            .replace(/-/g, '') // 移除所有负号
+            .replace(/NEGATIVE_MARKER/, '-') // 恢复开头的负号
+            .replace(/\.+/g, '.') // 多个小数点合并为一个
+            .replace(/(\..*)\./g, '$1') // 只保留第一个小数点
+        : '';
       // let value = answerValue
       //   ? answerValue.replace(
       //       /[^-\d.]|(?<!\d)\.|\.(?!\d)|^[.]$|^[+-]$|^[+-]\.$|(?<=\.\d*)\.|(?<=\d\.\d*)\.(?=\d)/g,
@@ -4407,7 +4408,10 @@ export default {
       this.$set(itemData, 'answerValue', value);
       if (value) {
         // 最大值
-        let maxValue = item.collectionOptionList[0].maxValue == null ? item.collectionOptionList[0].maxValue : item.collectionOptionList[0].maxValue.toString();
+        let maxValue =
+          item.collectionOptionList[0].maxValue == null
+            ? item.collectionOptionList[0].maxValue
+            : item.collectionOptionList[0].maxValue.toString();
         if (maxValue && maxValue != '') {
           if (value > Number(maxValue)) {
             this.$set(itemData, 'ruleMessage', '最大值为:' + maxValue);
@@ -4418,7 +4422,10 @@ export default {
           }
         }
         //最小值
-        let minValue = item.collectionOptionList[0].minValue == null ? item.collectionOptionList[0].minValue : item.collectionOptionList[0].minValue.toString();
+        let minValue =
+          item.collectionOptionList[0].minValue == null
+            ? item.collectionOptionList[0].minValue
+            : item.collectionOptionList[0].minValue.toString();
         if (minValue && minValue != '') {
           if (value < Number(minValue)) {
             this.$set(itemData, 'ruleMessage', '最小值为:' + minValue);
@@ -4630,7 +4637,10 @@ export default {
           // this.showCode = false;
         }
         // 生动化陈列是否可以编辑
-        if (this.$route.query.types == 'edit' && (this.photoIdentifyType == '6' || this.photoIdentifyType == '7')) {
+        if (
+          this.$route.query.types == 'edit' &&
+          (this.photoIdentifyType == '6' || this.photoIdentifyType == '7')
+        ) {
           this.isEditSDHCL = false;
         } else {
           this.isEditSDHCL = true;
@@ -5670,7 +5680,7 @@ export default {
     traverseCollectionItems(items) {
       // 处理一层子项(如果有)
       if (items.collectionOptionList && items.collectionOptionList.length > 0) {
-        if(items.answerValue == items.collectionOptionList[0].collectionOptionId ){
+        if (items.answerValue == items.collectionOptionList[0].collectionOptionId) {
           items.collectionOptionList.forEach((item) => {
             // 处理二层子项(如果有)
             if (item.collectionItems && item.collectionItems.length > 0) {
@@ -5681,7 +5691,6 @@ export default {
             }
           });
         }
-        
       }
     },
     onSubmit() {
@@ -6331,16 +6340,16 @@ export default {
     telConfirm(val) {
       let item = '';
       let answerValue = '';
-      if (
+      if (val.answerValue != null) {
+        answerValue = val.answerValue;
+        item = val;
+      } else if (
         val.collectionOptionList &&
         val.collectionOptionList.length &&
         val.collectionOptionList[0].answerValue
       ) {
         answerValue = val.collectionOptionList[0].answerValue;
         item = val.collectionOptionList[0];
-      } else {
-        answerValue = val.answerValue;
-        item = val;
       }
       if (!/^1[123456789]\d{9}$/.test(answerValue) || answerValue == '') {
         this.$toast(val.collectionName + '格式错误');