Browse Source

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

sunny 1 month ago
parent
commit
772eb82813
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/views/deviceWithin/addStoreVisit.vue

+ 5 - 2
src/views/deviceWithin/addStoreVisit.vue

@@ -4389,9 +4389,12 @@ export default {
       }
       let value = answerValue 
           ? answerValue.replace(/[^\d.-]/g, '') // 移除所有非法字符
-                 .replace(/^\./, '') // 移除开头的小数点
+                .replace(/^\./, '') // 移除开头的小数点
                 .replace(/\.$/, '') // 移除结尾的小数点(如果需要)
-                .replace(/(?<=.)-/g, '') // 移除除了开头位置外的所有负号
+                // .replace(/(?<=.)-/g, '') // 移除除了开头位置外的所有负号
+                .replace(/^-/, 'NEGATIVE_MARKER')  // 先标记开头的负号
+                .replace(/-/g, '')                 // 移除所有负号
+                .replace(/NEGATIVE_MARKER/, '-')   // 恢复开头的负号
                 .replace(/\.+/g, '.') // 多个小数点合并为一个
                 .replace(/(\..*)\./g, '$1') // 只保留第一个小数点
           : '';