0
0
Fork 0

Update Form Model component

This commit is contained in:
Kevin Martinez 2023-11-30 08:47:40 -03:00
parent cf53245bcf
commit babaf47653
4 changed files with 14 additions and 2 deletions

View File

@ -35,6 +35,10 @@ const $props = defineProps({
type: Boolean, type: Boolean,
default: true, default: true,
}, },
autoLoad: {
type: Boolean,
default: false,
},
}); });
const emit = defineEmits(['onFetch']); const emit = defineEmits(['onFetch']);
@ -43,7 +47,11 @@ defineExpose({
save, save,
}); });
onMounted(async () => await fetch()); onMounted(async () => {
if ($props.autoLoad) {
await fetch();
}
});
onUnmounted(() => { onUnmounted(() => {
state.unset($props.model); state.unset($props.model);
@ -96,6 +104,7 @@ function reset() {
emit('onFetch', state.get($props.model)); emit('onFetch', state.get($props.model));
hasChanges.value = false; hasChanges.value = false;
} }
// eslint-disable-next-line vue/no-dupe-keys // eslint-disable-next-line vue/no-dupe-keys
function filter(value, update, filterOptions) { function filter(value, update, filterOptions) {
update( update(
@ -176,6 +185,7 @@ watch(formUrl, async () => {
max-width: 800px; max-width: 800px;
width: 100%; width: 100%;
} }
.q-card { .q-card {
padding: 32px; padding: 32px;
} }

View File

@ -96,6 +96,7 @@ const statesFilter = {
:url-update="`Claims/updateClaim/${route.params.id}`" :url-update="`Claims/updateClaim/${route.params.id}`"
:filter="claimFilter" :filter="claimFilter"
model="claim" model="claim"
auto-load
> >
<template #form="{ data, validate, filter }"> <template #form="{ data, validate, filter }">
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">

View File

@ -60,7 +60,7 @@ const filterOptions = {
auto-load auto-load
/> />
<FormModel :url="`Clients/${route.params.id}`" model="customer"> <FormModel :url="`Clients/${route.params.id}`" model="customer" auto-load>
<template #form="{ data, validate, filter }"> <template #form="{ data, validate, filter }">
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">

View File

@ -29,6 +29,7 @@ const shelvingFilter = {
:url-update="`Shelvings/${shelvingId}`" :url-update="`Shelvings/${shelvingId}`"
:filter="shelvingFilter" :filter="shelvingFilter"
model="shelving" model="shelving"
auto-load
> >
<template #form="{ data, validate, filter }"> <template #form="{ data, validate, filter }">
<ShelvingForm :data="data" :validate="validate" :filter="filter" /> <ShelvingForm :data="data" :validate="validate" :filter="filter" />