This commit is contained in:
parent
1c86c874e0
commit
7962dbc26a
|
@ -3,11 +3,13 @@ import VnCard from 'components/common/VnCard.vue';
|
||||||
import RouteDescriptor from 'pages/Route/Card/RouteDescriptor.vue';
|
import RouteDescriptor from 'pages/Route/Card/RouteDescriptor.vue';
|
||||||
import RouteFilter from './RouteFilter.vue';
|
import RouteFilter from './RouteFilter.vue';
|
||||||
import RouteSearchbar from 'pages/Route/Card/RouteSearchbar.vue';
|
import RouteSearchbar from 'pages/Route/Card/RouteSearchbar.vue';
|
||||||
|
import filter from './RouteFilter.js';
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnCard
|
<VnCard
|
||||||
data-key="Route"
|
data-key="Route"
|
||||||
url="Routes"
|
url="Routes"
|
||||||
|
:filter="filter"
|
||||||
:descriptor="RouteDescriptor"
|
:descriptor="RouteDescriptor"
|
||||||
:filter-panel="RouteFilter"
|
:filter-panel="RouteFilter"
|
||||||
search-data-key="RouteList"
|
search-data-key="RouteList"
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||||
import VnLv from 'components/ui/VnLv.vue';
|
import VnLv from 'components/ui/VnLv.vue';
|
||||||
import useCardDescription from 'composables/useCardDescription';
|
|
||||||
import { dashIfEmpty, toDate } from 'src/filters';
|
import { dashIfEmpty, toDate } from 'src/filters';
|
||||||
import RouteDescriptorMenu from 'pages/Route/Card/RouteDescriptorMenu.vue';
|
import RouteDescriptorMenu from 'pages/Route/Card/RouteDescriptorMenu.vue';
|
||||||
|
|
||||||
|
@ -17,77 +15,30 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const entityId = computed(() => {
|
const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = {
|
|
||||||
fields: [
|
|
||||||
'id',
|
|
||||||
'workerFk',
|
|
||||||
'agencyModeFk',
|
|
||||||
'created',
|
|
||||||
'm3',
|
|
||||||
'warehouseFk',
|
|
||||||
'description',
|
|
||||||
'vehicleFk',
|
|
||||||
'kmStart',
|
|
||||||
'kmEnd',
|
|
||||||
'started',
|
|
||||||
'finished',
|
|
||||||
'cost',
|
|
||||||
'zoneFk',
|
|
||||||
'isOk',
|
|
||||||
],
|
|
||||||
include: [
|
|
||||||
{ relation: 'agencyMode', scope: { fields: ['id', 'name'] } },
|
|
||||||
{
|
|
||||||
relation: 'vehicle',
|
|
||||||
scope: { fields: ['id', 'm3'] },
|
|
||||||
},
|
|
||||||
{ relation: 'zone', scope: { fields: ['id', 'name'] } },
|
|
||||||
{
|
|
||||||
relation: 'worker',
|
|
||||||
scope: {
|
|
||||||
fields: ['id'],
|
|
||||||
include: {
|
|
||||||
relation: 'user',
|
|
||||||
scope: {
|
|
||||||
fields: ['id'],
|
|
||||||
include: { relation: 'emailUser', scope: { fields: ['email'] } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const data = ref(useCardDescription());
|
|
||||||
const setData = (entity) => (data.value = useCardDescription(entity.code, entity.id));
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CardDescriptor
|
<CardDescriptor
|
||||||
module="Route"
|
module="Route"
|
||||||
:url="`Routes/${entityId}`"
|
:url="`Routes/${entityId}`"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
:title="data.title"
|
:title="null"
|
||||||
:subtitle="data.subtitle"
|
data-key="Route"
|
||||||
data-key="routeData"
|
|
||||||
@on-fetch="setData"
|
|
||||||
>
|
>
|
||||||
<template #body="{ entity }">
|
<template #body="{ entity }">
|
||||||
<VnLv :label="t('Date')" :value="toDate(entity?.created)" />
|
<VnLv :label="$t('Date')" :value="toDate(entity?.created)" />
|
||||||
<VnLv :label="t('Agency')" :value="entity?.agencyMode?.name" />
|
<VnLv :label="$t('Agency')" :value="entity?.agencyMode?.name" />
|
||||||
<VnLv :label="t('Zone')" :value="entity?.zone?.name" />
|
<VnLv :label="$t('Zone')" :value="entity?.zone?.name" />
|
||||||
<VnLv
|
<VnLv
|
||||||
:label="t('Volume')"
|
:label="$t('Volume')"
|
||||||
:value="`${dashIfEmpty(entity?.m3)} / ${dashIfEmpty(
|
:value="`${dashIfEmpty(entity?.m3)} / ${dashIfEmpty(
|
||||||
entity?.vehicle?.m3
|
entity?.vehicle?.m3
|
||||||
)} m³`"
|
)} m³`"
|
||||||
/>
|
/>
|
||||||
<VnLv :label="t('Description')" :value="entity?.description" />
|
<VnLv :label="$t('Description')" :value="entity?.description" />
|
||||||
</template>
|
</template>
|
||||||
<template #menu="{ entity }">
|
<template #menu="{ entity }">
|
||||||
<RouteDescriptorMenu :route="entity" />
|
<RouteDescriptorMenu :route="entity" />
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
export default {
|
||||||
|
fields: [
|
||||||
|
'code',
|
||||||
|
'id',
|
||||||
|
'workerFk',
|
||||||
|
'agencyModeFk',
|
||||||
|
'created',
|
||||||
|
'm3',
|
||||||
|
'warehouseFk',
|
||||||
|
'description',
|
||||||
|
'vehicleFk',
|
||||||
|
'kmStart',
|
||||||
|
'kmEnd',
|
||||||
|
'started',
|
||||||
|
'finished',
|
||||||
|
'cost',
|
||||||
|
'zoneFk',
|
||||||
|
'isOk',
|
||||||
|
],
|
||||||
|
include: [
|
||||||
|
{ relation: 'agencyMode', scope: { fields: ['id', 'name'] } },
|
||||||
|
{
|
||||||
|
relation: 'vehicle',
|
||||||
|
scope: { fields: ['id', 'm3'] },
|
||||||
|
},
|
||||||
|
{ relation: 'zone', scope: { fields: ['id', 'name'] } },
|
||||||
|
{
|
||||||
|
relation: 'worker',
|
||||||
|
scope: {
|
||||||
|
fields: ['id'],
|
||||||
|
include: {
|
||||||
|
relation: 'user',
|
||||||
|
scope: {
|
||||||
|
fields: ['id'],
|
||||||
|
include: { relation: 'emailUser', scope: { fields: ['email'] } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
|
@ -11,6 +11,7 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnInput from 'components/common/VnInput.vue';
|
import VnInput from 'components/common/VnInput.vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||||
|
import filter from './RouteFilter.js';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -27,46 +28,6 @@ const defaultInitialData = {
|
||||||
};
|
};
|
||||||
const maxDistance = ref();
|
const maxDistance = ref();
|
||||||
|
|
||||||
const routeFilter = {
|
|
||||||
fields: [
|
|
||||||
'id',
|
|
||||||
'workerFk',
|
|
||||||
'agencyModeFk',
|
|
||||||
'created',
|
|
||||||
'm3',
|
|
||||||
'warehouseFk',
|
|
||||||
'description',
|
|
||||||
'vehicleFk',
|
|
||||||
'kmStart',
|
|
||||||
'kmEnd',
|
|
||||||
'started',
|
|
||||||
'finished',
|
|
||||||
'cost',
|
|
||||||
'zoneFk',
|
|
||||||
'isOk',
|
|
||||||
],
|
|
||||||
include: [
|
|
||||||
{ relation: 'agencyMode', scope: { fields: ['id', 'name'] } },
|
|
||||||
{
|
|
||||||
relation: 'vehicle',
|
|
||||||
scope: { fields: ['id', 'm3'] },
|
|
||||||
},
|
|
||||||
{ relation: 'zone', scope: { fields: ['id', 'name'] } },
|
|
||||||
{
|
|
||||||
relation: 'worker',
|
|
||||||
scope: {
|
|
||||||
fields: ['id'],
|
|
||||||
include: {
|
|
||||||
relation: 'user',
|
|
||||||
scope: {
|
|
||||||
fields: ['id'],
|
|
||||||
include: { relation: 'emailUser', scope: { fields: ['email'] } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const onSave = (data, response) => {
|
const onSave = (data, response) => {
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
axios.post(`Routes/${response?.id}/updateWorkCenter`);
|
axios.post(`Routes/${response?.id}/updateWorkCenter`);
|
||||||
|
@ -83,11 +44,10 @@ const onSave = (data, response) => {
|
||||||
sort-by="id ASC"
|
sort-by="id ASC"
|
||||||
/>
|
/>
|
||||||
<FormModel
|
<FormModel
|
||||||
:url="isNew ? null : `Routes/${route.params?.id}`"
|
|
||||||
:url-create="isNew ? 'Routes' : null"
|
:url-create="isNew ? 'Routes' : null"
|
||||||
:observe-form-changes="!isNew"
|
:observe-form-changes="!isNew"
|
||||||
:filter="routeFilter"
|
:filter="filter"
|
||||||
model="route"
|
model="Route"
|
||||||
:auto-load="!isNew"
|
:auto-load="!isNew"
|
||||||
:form-initial-data="isNew ? defaultInitialData : null"
|
:form-initial-data="isNew ? defaultInitialData : null"
|
||||||
@on-data-saved="onSave"
|
@on-data-saved="onSave"
|
||||||
|
|
Loading…
Reference in New Issue