0
0
Fork 0

feat: refs #6317 create vnCurrency

This commit is contained in:
Jorge Penadés 2024-02-05 15:39:53 +01:00
parent a5064e2e2f
commit e49a9f4165
2 changed files with 36 additions and 21 deletions

View File

@ -0,0 +1,34 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import VnInput from 'src/components/common/VnInput.vue';
import { useFirstUpper } from 'src/composables/useFirstUpper';
const { t } = useI18n();
const amount = ref();
const isValidNumber = (value) => /^(\d|\d+(\.)?\d+)$/.test(value);
</script>
<template>
<VnInput
:label="useFirstUpper(t('amount'))"
v-model="amount"
is-outlined
@update:model-value="
(value) => {
if (value.includes(',')) amount.value = amount.replace(',', '.');
}
"
:rules="[(val) => isValidNumber(val) || !val || 'Please type a number']"
lazy-rules
>
<template #prepend>
<QIcon name="euro" size="sm" />
</template>
</VnInput>
</template>
<style lang="scss" scoped></style>
<i18n>
es:
amount: importe
</i18n>

View File

@ -1,9 +1,9 @@
<script setup>
import { useI18n } from 'vue-i18n';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnInputDate from 'components/common/VnInputDate.vue';
import VnCurrency from 'src/components/common/VnCurrency.vue';
const { t } = useI18n();
const props = defineProps({
@ -51,28 +51,9 @@ function isValidNumber(value) {
</QItem>
<QItem>
<QItemSection>
<VnInput
:label="t('Amount')"
v-model="params.amount"
is-outlined
@update:model-value="
(value) => {
if (value.includes(','))
params.amount = params.amount.replace(',', '.');
}
"
:rules="[
(val) => isValidNumber(val) || !val || 'Please type a number',
]"
lazy-rules
>
<template #prepend>
<QIcon name="euro" size="sm" />
</template>
</VnInput>
<VnCurrency v-model="params.amount" />
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnInputDate v-model="params.from" :label="t('From')" is-outlined />