diff --git a/src/components/Template/BaseInfoFormPackage.vue b/src/components/Template/BaseInfoFormPackage.vue index ad7c1f5..940ecdf 100644 --- a/src/components/Template/BaseInfoFormPackage.vue +++ b/src/components/Template/BaseInfoFormPackage.vue @@ -123,7 +123,9 @@ :item="sItem" :value="formFields[key]" /> -
+
diff --git a/src/components/Template/DecimalInput.vue b/src/components/Template/DecimalInput.vue index cc8e23a..90b5275 100644 --- a/src/components/Template/DecimalInput.vue +++ b/src/components/Template/DecimalInput.vue @@ -44,7 +44,16 @@ export default { if (newVal === '' || newVal == null) { this.internalValue = ''; } else { - this.internalValue = this.handleDecimalDigits(String(newVal)); + // 如果当前值是 "NA" 或 "20/30/40" 格式,保持不变 + if ((this.internalValue && this.internalValue.toUpperCase() === 'NA') || (this.internalValue && /^\d+(\/\d+)*$/.test(this.internalValue))) { + return; + } + // 检查是否为 "NA" 或其输入过程,或类似 "20/30/40" 的格式 + if (String(newVal).toUpperCase() === 'NA' || /^[Nn]?[Aa]?$/.test(String(newVal)) || /^\d+(\/\d*)*$/.test(String(newVal))) { + this.internalValue = String(newVal); + } else { + this.internalValue = this.handleDecimalDigits(String(newVal)); + } } } }, @@ -56,6 +65,27 @@ export default { return; } + // 检查是否为 "NA" 或其输入过程 + if (val.toUpperCase() === 'NA' || /^[Nn]?[Aa]?$/.test(val)) { + this.internalValue = val; + this.$emit('input', val); + return; + } + + // 检查是否为 "20/30/40" 或其输入过程 + if (/^\d+(\/\d*)*$/.test(val)) { + this.internalValue = val; + this.$emit('input', val); + return; + } + + // 如果当前值是 "NA" 或 "20/30/40" 格式,不允许输入其他字符 + if ((this.internalValue && this.internalValue.toUpperCase() === 'NA') || (this.internalValue && /^\d+(\/\d+)*$/.test(this.internalValue))) { + // 保持当前值不变 + this.$emit('input', this.internalValue); + return; + } + // 1. 只保留数字、小数点、开头的负号 let cleaned = val .replace(/[^\d.-]/g, '') @@ -120,6 +150,11 @@ export default { const actVal = val || this.internalValue; let finalValue = actVal.trim(); + // 检查是否为 "NA" 或类似 "20/30/40" 的格式 + if (finalValue.toUpperCase() === 'NA' || /^\d+(\/\d+)+$/.test(finalValue)) { + return finalValue; + } + if (finalValue === '' || finalValue === '-') { this.internalValue = ''; this.$emit('input', ''); @@ -150,6 +185,13 @@ export default { }, handleBlur() { + // 检查是否为 "NA" 或类似 "20/30/40" 的格式 + if ((this.internalValue && this.internalValue.toUpperCase() === 'NA') || (this.internalValue && /^\d+(\/\d+)*$/.test(this.internalValue))) { + this.$emit('input', this.internalValue); + this.$emit('blur', this.internalValue); + return; + } + let formatted = this.handleDecimalDigits(this.internalValue); this.internalValue = formatted; // emit 数字类型(也可 emit 字符串,根据需求) diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index 34f786b..06a47b7 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -1,7 +1,10 @@