#6317 create vnCurrency #181

Merged
jorgep merged 16 commits from 6317-createVnCurrency into dev 2024-03-01 07:39:06 +00:00
2 changed files with 36 additions and 21 deletions
Showing only changes of commit e49a9f4165 - Show all commits

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'))"
Review

Todo esto creo que se puede sustituir por const amount = defineModel()

Todo esto creo que se puede sustituir por const amount = defineModel()
Review

Por lo que he visto en internet, hace falta Vue 3.4 pero tenemos vue 3.3.4

Por lo que he visto en internet, hace falta Vue 3.4 pero tenemos vue 3.3.4
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
Outdated
Review

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

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
Outdated
Review

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

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

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>

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 />