|
|
@ -44,16 +44,7 @@ export default { |
|
|
if (newVal === '' || newVal == null) { |
|
|
if (newVal === '' || newVal == null) { |
|
|
this.internalValue = ''; |
|
|
this.internalValue = ''; |
|
|
} else { |
|
|
} else { |
|
|
// 如果当前值是 "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)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.internalValue = this.handleDecimalDigits(String(newVal)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
@ -65,27 +56,6 @@ export default { |
|
|
return; |
|
|
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. 只保留数字、小数点、开头的负号 |
|
|
// 1. 只保留数字、小数点、开头的负号 |
|
|
let cleaned = val |
|
|
let cleaned = val |
|
|
.replace(/[^\d.-]/g, '') |
|
|
.replace(/[^\d.-]/g, '') |
|
|
@ -150,11 +120,6 @@ export default { |
|
|
const actVal = val || this.internalValue; |
|
|
const actVal = val || this.internalValue; |
|
|
let finalValue = actVal.trim(); |
|
|
let finalValue = actVal.trim(); |
|
|
|
|
|
|
|
|
// 检查是否为 "NA" 或类似 "20/30/40" 的格式 |
|
|
|
|
|
if (finalValue.toUpperCase() === 'NA' || /^\d+(\/\d+)+$/.test(finalValue)) { |
|
|
|
|
|
return finalValue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (finalValue === '' || finalValue === '-') { |
|
|
if (finalValue === '' || finalValue === '-') { |
|
|
this.internalValue = ''; |
|
|
this.internalValue = ''; |
|
|
this.$emit('input', ''); |
|
|
this.$emit('input', ''); |
|
|
@ -185,13 +150,6 @@ export default { |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
handleBlur() { |
|
|
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); |
|
|
let formatted = this.handleDecimalDigits(this.internalValue); |
|
|
this.internalValue = formatted; |
|
|
this.internalValue = formatted; |
|
|
// emit 数字类型(也可 emit 字符串,根据需求) |
|
|
// emit 数字类型(也可 emit 字符串,根据需求) |
|
|
|