0
0
Fork 0

fix: refs #6480 fix workerCard

This commit is contained in:
Jorge Penadés 2024-04-23 12:00:29 +02:00
parent 54f9cf36c2
commit f9a88ea8c2
4 changed files with 27 additions and 16 deletions

View File

@ -1,5 +1,5 @@
<script setup>
import { onBeforeMount } from 'vue';
import { onBeforeMount, computed } from 'vue';
import { useRoute, onBeforeRouteUpdate } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useArrayData } from 'src/composables/useArrayData';
@ -11,8 +11,9 @@ import LeftMenu from 'components/LeftMenu.vue';
const props = defineProps({
dataKey: { type: String, required: true },
baseUrl: { type: String, required: true },
filter: { type: Object, default: undefined },
baseUrl: { type: String, default: undefined },
customUrl: { type: String, default: undefined },
filter: { type: Object, default: () => {} },
descriptor: { type: Object, required: true },
searchbarDataKey: { type: String, default: undefined },
searchbarUrl: { type: String, default: undefined },
@ -23,20 +24,29 @@ const props = defineProps({
const { t } = useI18n();
const stateStore = useStateStore();
const route = useRoute();
const url = computed(() => {
if (props.baseUrl) return `${props.baseUrl}/${route.params.id}`;
return props.customUrl;
});
const arrayData = useArrayData(props.dataKey, {
url: `${props.baseUrl}/${route.params.id}`,
url: url.value,
filter: props.filter,
});
onBeforeMount(async () => await arrayData.fetch({ append: false }));
onBeforeRouteUpdate(async (to, from) => {
if (to.params.id !== from.params.id) {
arrayData.store.url = `${props.baseUrl}/${route.params.id}`;
await arrayData.fetch({ append: false });
}
onBeforeMount(async () => {
await arrayData.fetch({ append: false });
arrayData.store.filter.where = { id: route.params.id };
});
if (props.baseUrl) {
onBeforeRouteUpdate(async (to, from) => {
if (to.params.id !== from.params.id) {
arrayData.store.url = `${props.baseUrl}/${route.params.id}`;
await arrayData.fetch({ append: false });
}
});
}
</script>
<template>
<Teleport

View File

@ -4,7 +4,6 @@ import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import VnRow from 'components/ui/VnRow.vue';
import FetchData from 'src/components/FetchData.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FormModel from 'components/FormModel.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
@ -28,7 +27,6 @@ const filter = {
@on-fetch="(data) => (sectors = data)"
auto-load
/>
<VnSubToolbar />
<FormModel :url="`Parkings/${parkingId}`" model="parking" :filter="filter" auto-load>
<template #form="{ data }">
<VnRow>

View File

@ -91,8 +91,8 @@ async function changeState(value) {
>
<template #header="{ entity }">
<div>
Ticket #{{ entity.id }} - {{ entity.client.name }} ({{
entity.client.id
Ticket #{{ entity.id }} - {{ entity.client?.name }} ({{
entity.client?.id
}}) -
{{ entity.nickname }}
</div>

View File

@ -1,12 +1,15 @@
<script setup>
import VnCard from 'components/common/VnCard.vue';
import WorkerDescriptor from './WorkerDescriptor.vue';
const filter = { where: {} };
</script>
<template>
<VnCard
data-key="Worker"
base-url="Workers"
custom-url="Workers/Summary"
:descriptor="WorkerDescriptor"
:filter="filter"
searchbar-data-key="WorkerList"
searchbar-url="Workers/filter"
searchbar-label="Search worker"