forked from verdnatura/salix-front
perf: approach
This commit is contained in:
parent
961c8140af
commit
0d718448e2
|
@ -22,7 +22,7 @@ const { t } = useI18n();
|
||||||
const { validate } = useValidator();
|
const { validate } = useValidator();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const myForm = ref(null);
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
url: {
|
url: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -106,11 +106,14 @@ const defaultButtons = computed(() => ({
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'save',
|
icon: 'save',
|
||||||
label: 'globals.save',
|
label: 'globals.save',
|
||||||
|
click: () => myForm.value.submit(),
|
||||||
|
type: 'submit',
|
||||||
},
|
},
|
||||||
reset: {
|
reset: {
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'restart_alt',
|
icon: 'restart_alt',
|
||||||
label: 'globals.reset',
|
label: 'globals.reset',
|
||||||
|
click: () => reset(),
|
||||||
},
|
},
|
||||||
...$props.defaultButtons,
|
...$props.defaultButtons,
|
||||||
}));
|
}));
|
||||||
|
@ -262,6 +265,7 @@ defineExpose({
|
||||||
<template>
|
<template>
|
||||||
<div class="column items-center full-width">
|
<div class="column items-center full-width">
|
||||||
<QForm
|
<QForm
|
||||||
|
ref="myForm"
|
||||||
v-if="formData"
|
v-if="formData"
|
||||||
@submit="save"
|
@submit="save"
|
||||||
@reset="reset"
|
@reset="reset"
|
||||||
|
@ -290,7 +294,7 @@ defineExpose({
|
||||||
:color="defaultButtons.reset.color"
|
:color="defaultButtons.reset.color"
|
||||||
:icon="defaultButtons.reset.icon"
|
:icon="defaultButtons.reset.icon"
|
||||||
flat
|
flat
|
||||||
@click="reset"
|
@click="defaultButtons.reset.click"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t(defaultButtons.reset.label)"
|
:title="t(defaultButtons.reset.label)"
|
||||||
/>
|
/>
|
||||||
|
@ -330,7 +334,7 @@ defineExpose({
|
||||||
:label="tMobile('globals.save')"
|
:label="tMobile('globals.save')"
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="save"
|
icon="save"
|
||||||
@click="save"
|
@click="defaultButtons.save.click"
|
||||||
:disable="!hasChanges"
|
:disable="!hasChanges"
|
||||||
:title="t(defaultButtons.save.label)"
|
:title="t(defaultButtons.save.label)"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -68,6 +68,7 @@ defineExpose({
|
||||||
<QBtn
|
<QBtn
|
||||||
:label="t('globals.save')"
|
:label="t('globals.save')"
|
||||||
:title="t('globals.save')"
|
:title="t('globals.save')"
|
||||||
|
@submit="() => formModelRef.save()"
|
||||||
type="submit"
|
type="submit"
|
||||||
color="primary"
|
color="primary"
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
|
|
|
@ -25,7 +25,6 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
|
||||||
const vnInputRef = ref(null);
|
const vnInputRef = ref(null);
|
||||||
const value = computed({
|
const value = computed({
|
||||||
get() {
|
get() {
|
||||||
|
@ -63,11 +62,7 @@ const inputRules = [
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div @mouseover="hover = true" @mouseleave="hover = false">
|
||||||
@mouseover="hover = true"
|
|
||||||
@mouseleave="hover = false"
|
|
||||||
:rules="$attrs.required ? [requiredFieldRule] : null"
|
|
||||||
>
|
|
||||||
<QInput
|
<QInput
|
||||||
ref="vnInputRef"
|
ref="vnInputRef"
|
||||||
v-model="value"
|
v-model="value"
|
||||||
|
@ -76,7 +71,6 @@ const inputRules = [
|
||||||
:class="{ required: $attrs.required }"
|
:class="{ required: $attrs.required }"
|
||||||
@keyup.enter="emit('keyup.enter')"
|
@keyup.enter="emit('keyup.enter')"
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
:rules="inputRules"
|
|
||||||
:lazy-rules="true"
|
:lazy-rules="true"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
>
|
>
|
||||||
|
|
|
@ -143,7 +143,6 @@ async function filterHandler(val, update) {
|
||||||
watch(options, (newValue) => {
|
watch(options, (newValue) => {
|
||||||
setOptions(newValue);
|
setOptions(newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(modelValue, (newValue) => {
|
watch(modelValue, (newValue) => {
|
||||||
if (!myOptions.value.some((option) => option[optionValue.value] == newValue))
|
if (!myOptions.value.some((option) => option[optionValue.value] == newValue))
|
||||||
fetchFilter(newValue);
|
fetchFilter(newValue);
|
||||||
|
@ -175,7 +174,6 @@ watch(modelValue, (newValue) => {
|
||||||
ref="vnSelectRef"
|
ref="vnSelectRef"
|
||||||
lazy-rules
|
lazy-rules
|
||||||
:class="{ required: $attrs.required }"
|
:class="{ required: $attrs.required }"
|
||||||
:rules="$attrs.required ? [requiredFieldRule] : null"
|
|
||||||
virtual-scroll-slice-size="options.length"
|
virtual-scroll-slice-size="options.length"
|
||||||
>
|
>
|
||||||
<template v-if="isClearable" #append>
|
<template v-if="isClearable" #append>
|
||||||
|
|
|
@ -40,7 +40,7 @@ export function useValidator() {
|
||||||
if (!isValid) return message;
|
if (!isValid) return message;
|
||||||
},
|
},
|
||||||
presence: (value) => {
|
presence: (value) => {
|
||||||
let message = `Value can't be empty`;
|
let message = t(`globals.valueCantBeEmpty`);
|
||||||
if (validation.message)
|
if (validation.message)
|
||||||
message = t(validation.message) || validation.message;
|
message = t(validation.message) || validation.message;
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ globals:
|
||||||
notificationSent: Notification sent
|
notificationSent: Notification sent
|
||||||
warehouse: Warehouse
|
warehouse: Warehouse
|
||||||
company: Company
|
company: Company
|
||||||
fieldRequired: Field required
|
fieldRequired: Field requdired
|
||||||
allowedFilesText: 'Allowed file types: { allowedContentTypes }'
|
allowedFilesText: 'Allowed file types: { allowedContentTypes }'
|
||||||
smsSent: SMS sent
|
smsSent: SMS sent
|
||||||
confirmDeletion: Confirm deletion
|
confirmDeletion: Confirm deletion
|
||||||
|
|
|
@ -75,6 +75,9 @@ globals:
|
||||||
warehouse: Almacén
|
warehouse: Almacén
|
||||||
company: Empresa
|
company: Empresa
|
||||||
fieldRequired: Campo requerido
|
fieldRequired: Campo requerido
|
||||||
|
valueCantBeEmpty: El valor no puede estar vacío
|
||||||
|
Value can't be blank: El valor no puede estar en blanco
|
||||||
|
Value can't be null: El valor no puede ser nulo
|
||||||
allowedFilesText: 'Tipos de archivo permitidos: { allowedContentTypes }'
|
allowedFilesText: 'Tipos de archivo permitidos: { allowedContentTypes }'
|
||||||
smsSent: SMS enviado
|
smsSent: SMS enviado
|
||||||
confirmDeletion: Confirmar eliminación
|
confirmDeletion: Confirmar eliminación
|
||||||
|
|
Loading…
Reference in New Issue