From 2fa8c3f88a837d94e8f2fe987fb150a4a82543b0 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sat, 23 Nov 2024 15:59:29 +0100 Subject: [PATCH 1/2] feat: refs #8163 limit with maxLength --- src/components/common/VnInput.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/common/VnInput.vue b/src/components/common/VnInput.vue index 1aa36bf4f7..7099295f86 100644 --- a/src/components/common/VnInput.vue +++ b/src/components/common/VnInput.vue @@ -88,6 +88,7 @@ const mixinRules = [ const handleKeydown = (e) => { if (e.key === 'Backspace') return; + if ($props.insertable && e.key.match(/[0-9]/)) { handleInsertMode(e); } @@ -97,20 +98,19 @@ const handleInsertMode = (e) => { e.preventDefault(); const input = e.target; const cursorPos = input.selectionStart; - + const { maxlength } = vnInputRef.value; let currentValue = value.value; if (!currentValue) currentValue = e.key; - const newValue = Number(e.key); - if (newValue && !isNaN(newValue)) { + const newValue = e.key; + if (newValue && !isNaN(newValue) && cursorPos < maxlength) { value.value = currentValue.substring(0, cursorPos) + newValue + currentValue.substring(cursorPos + 1); - - nextTick(() => { - input.setSelectionRange(cursorPos + 1, cursorPos + 1); - }); } + nextTick(() => { + input.setSelectionRange(cursorPos + 1, cursorPos + 1); + }); }; From 7f87df122539921a4b108a4db5d88d7135c0d779 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sat, 23 Nov 2024 16:49:32 +0100 Subject: [PATCH 2/2] feat: refs #8163 use VnAccountNumber in VnAccountNumber --- src/components/common/VnAccountNumber.vue | 54 ++++++++++++++++--- .../Supplier/Card/SupplierFiscalData.vue | 3 +- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/components/common/VnAccountNumber.vue b/src/components/common/VnAccountNumber.vue index f7273a72d8..c4fa786746 100644 --- a/src/components/common/VnAccountNumber.vue +++ b/src/components/common/VnAccountNumber.vue @@ -1,20 +1,24 @@ diff --git a/src/pages/Supplier/Card/SupplierFiscalData.vue b/src/pages/Supplier/Card/SupplierFiscalData.vue index bd35c69c06..1a79be8bc2 100644 --- a/src/pages/Supplier/Card/SupplierFiscalData.vue +++ b/src/pages/Supplier/Card/SupplierFiscalData.vue @@ -9,6 +9,7 @@ import VnRow from 'components/ui/VnRow.vue'; import VnInput from 'src/components/common/VnInput.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import VnLocation from 'src/components/common/VnLocation.vue'; +import VnAccountNumber from 'src/components/common/VnAccountNumber.vue'; const route = useRoute(); const { t } = useI18n(); @@ -100,7 +101,7 @@ function handleLocation(data, location) { /> -