#6317 create vnCurrency #181
|
@ -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']"
|
||||
jorgep marked this conversation as resolved
Outdated
alexm
commented
En angularjs fa aço: front/core/filters/currency.js ns si en vue hi ha algo paregut En angularjs fa aço: front/core/filters/currency.js ns si en vue hi ha algo paregut
jorgep
commented
Esto con el type number no es necesario. Esto con el type number no es necesario.
|
||||
lazy-rules
|
||||
>
|
||||
<template #prepend>
|
||||
<QIcon name="euro" size="sm" />
|
||||
</template>
|
||||
</VnInput>
|
||||
jorgep marked this conversation as resolved
Outdated
alexm
commented
Html(i quasar) te la posibilitat de gastar type="number" En un component q soles accepta numeros (tambe dixa '.' i ',') seria lo mes apropiat Html(i quasar) te la posibilitat de gastar type="number"
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
En un component q soles accepta numeros (tambe dixa '.' i ',') seria lo mes apropiat
jorgep
commented
Si gasto type="number" sale el banner predeterminado de html5 cuando escribes un número con coma, Una posible solución es añadir novalidate en el QForm. https://www.w3schools.com/tags/att_form_novalidate.asp Usando step="any" se admiten decimales con coma y punto. Si gasto type="number" sale el banner predeterminado de html5 cuando escribes un número con coma, Una posible solución es añadir novalidate en el QForm.
https://www.w3schools.com/tags/att_form_novalidate.asp
Usando step="any" se admiten decimales con coma y punto.
|
||||
</template>
|
||||
<style lang="scss" scoped></style>
|
||||
<i18n>
|
||||
es:
|
||||
amount: importe
|
||||
</i18n>
|
|
@ -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 />
|
||||
|
|
Loading…
Reference in New Issue
Todo esto creo que se puede sustituir por const amount = defineModel()
Por lo que he visto en internet, hace falta Vue 3.4 pero tenemos vue 3.3.4