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

View File

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

View File

@ -60,7 +60,7 @@ const filterOptions = {
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 }">
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">

View File

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