This commit is contained in:
2026-06-30 22:19:27 +03:30
parent 15c43a8ee9
commit bbec5b802d
11 changed files with 178 additions and 40 deletions
+20 -11
View File
@@ -36,6 +36,7 @@
import {usePrefix} from "@/utils/usePrefix";
import {computed} from "vue";
import {usePrice} from "@/utils/usePrice";
import {persianToEnglishDigits, shouldNormalizeInputDigits} from '@/utils/persianDigits';
//Props
interface Prop {
@@ -59,9 +60,7 @@ const addonTextColor = computed(() => props.addonTextColor)
//emits
const localValue = computed({
set(value) {
props.type === 'price'
? emits('update:value', value?.toString().replaceAll(',', ''))
: emits('update:value', value)
emits('update:value', normalizeValue(value))
},
get() {
return props.type === 'price'
@@ -75,16 +74,26 @@ const props = withDefaults(defineProps<Prop>(), {
})
const emits = defineEmits(['update:value', 'onchange'])
const handlerChange = (e: any) => {
props.type === 'price'
? emits('update:value', e.target.value?.toString().replaceAll(',', ''))
: emits('update:value', e.target.value)
props.type === 'price'
? emits('onchange', e.target.value?.toString().replaceAll(',', ''))
: emits('onchange', e.target.value)
function normalizeValue(value: unknown) {
if (value == null || value === '') {
return value
}
let normalized = String(value)
if (shouldNormalizeInputDigits(props)) {
normalized = persianToEnglishDigits(normalized)
}
if (props.type === 'price') {
normalized = normalized.replaceAll(',', '')
}
return normalized
}
//css style
const handlerChange = (e: any) => {
const normalized = normalizeValue(e.target.value)
emits('update:value', normalized)
emits('onchange', normalized)
}
const {prefixCls} = usePrefix('input')
</script>