refactor: refs #7553 rollback ticket advance due to slot problems
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-09-09 08:14:53 +02:00
parent 94ae74ca7f
commit 0b961050a0
2 changed files with 290 additions and 139 deletions

View File

@ -408,7 +408,8 @@ defineExpose({
@click="stateStore.toggleRightDrawer()" @click="stateStore.toggleRightDrawer()"
/> />
</template> </template>
<!--TODO: este slot se carga los botones de mostrar tabla/card y columnas visibles--> <!--TODO: este slot se carga los botones de mostrar tabla/card y columnas visibles
por lo que no es viable para el uso que se le quiere dar-->
<!-- <template #top> <!-- <template #top>
<div class="full-width-slot"> <div class="full-width-slot">
<slot name="before-header" /> <slot name="before-header" />

View File

@ -3,8 +3,8 @@ import { onMounted, ref, computed, reactive } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
// import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
// import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue'; import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
@ -19,14 +19,13 @@ import useNotify from 'src/composables/useNotify.js';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { toDateFormat } from 'src/filters/date.js'; import { toDateFormat } from 'src/filters/date.js';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue';
const state = useState(); const state = useState();
const { t } = useI18n(); const { t } = useI18n();
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const { notify } = useNotify(); const { notify } = useNotify();
const user = state.getUser(); const user = state.getUser();
const tableRef = ref();
const itemPackingTypesOptions = ref([]); const itemPackingTypesOptions = ref([]);
const zonesOptions = ref([]); const zonesOptions = ref([]);
const selectedTickets = ref([]); const selectedTickets = ref([]);
@ -45,14 +44,15 @@ const exprBuilder = (param, value) => {
case 'notMovableLines': case 'notMovableLines':
case 'futureZoneFk': case 'futureZoneFk':
return { [param]: value }; return { [param]: value };
case 'ipt': case 'iptColFilter':
return { [param]: { like: `%${value}%` } }; return { ipt: { like: `%${value}%` } };
case 'futureIpt': case 'futureIptColFilter':
return { [param]: { like: `%${value}%` } }; return { futureIpt: { like: `%${value}%` } };
} }
}; };
const userParams = reactive({}); const userParams = reactive({});
const arrayData = useArrayData('AdvanceTickets', { const arrayData = useArrayData('AdvanceTickets', {
url: 'Tickets/getTicketsAdvance', url: 'Tickets/getTicketsAdvance',
userParams: userParams, userParams: userParams,
@ -82,123 +82,220 @@ const getInputEvents = (col) => {
}; };
}; };
const columns = computed(() => [ const ticketColumns = computed(() => [
{ {
label: '', label: '',
name: 'icons', name: 'icons',
hidden: true,
},
{
align: 'center',
label: t('advanceTickets.ticketId'),
name: 'id',
},
{
align: 'left', align: 'left',
columnFilter: null,
},
{
label: t('advanceTickets.ticketId'),
name: 'ticketId',
align: 'center',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
filterParamKey: 'id',
event: getInputEvents,
attrs: {
dense: true,
},
},
},
{
label: t('advanceTickets.ipt'), label: t('advanceTickets.ipt'),
name: 'ipt', name: 'ipt',
field: 'ipt',
align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: 'select', component: VnSelect,
filterParamKey: 'iptColFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
url: 'itemPackingTypes', options: itemPackingTypesOptions.value,
fields: ['code', 'description'], 'option-value': 'code',
where: { isActive: true }, 'option-label': 'description',
optionValue: 'code', dense: true,
optionLabel: 'description',
}, },
}, },
format: (row, dashIfEmpty) => dashIfEmpty(row.ipt), format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.state'), label: t('advanceTickets.state'),
name: 'state', name: 'state',
hidden: true, align: 'left',
sortable: true,
columnFilter: null,
}, },
{ {
align: 'left',
label: t('advanceTickets.liters'), label: t('advanceTickets.liters'),
name: 'liters', name: 'liters',
field: 'liters',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
}, },
{ {
align: 'left',
label: t('advanceTickets.lines'), label: t('advanceTickets.lines'),
name: 'lines', name: 'lines',
format: (row, dashIfEmpty) => dashIfEmpty(row.lines), field: 'lines',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.import'), label: t('advanceTickets.import'),
name: 'totalWithVat', field: 'import',
hidden: true, name: 'import',
format: (row) => toCurrency(row.totalWithVat), align: 'left',
sortable: true,
}, },
{ {
align: 'left',
label: t('advanceTickets.futureId'), label: t('advanceTickets.futureId'),
name: 'futureId', name: 'futureId',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
filterParamKey: 'futureId',
event: getInputEvents,
attrs: {
dense: true,
},
},
}, },
{ {
align: 'left',
label: t('advanceTickets.futureIpt'), label: t('advanceTickets.futureIpt'),
name: 'futureIpt', name: 'futureIpt',
field: 'futureIpt',
align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: 'select', component: VnSelect,
filterParamKey: 'futureIptColFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
url: 'itemPackingTypes', options: itemPackingTypesOptions.value,
fields: ['code', 'description'], 'option-value': 'code',
where: { isActive: true }, 'option-label': 'description',
optionValue: 'code', dense: true,
optionLabel: 'description',
}, },
}, },
format: (row, dashIfEmpty) => dashIfEmpty(row.futureIpt), format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureState'), label: t('advanceTickets.futureState'),
name: 'futureState', name: 'futureState',
hidden: true, align: 'left',
sortable: true,
columnFilter: null,
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureLiters'), label: t('advanceTickets.futureLiters'),
name: 'futureLiters', name: 'futureLiters',
}, field: 'futureLiters',
{
align: 'left', align: 'left',
label: t('advanceTickets.futureZone'), sortable: true,
name: 'futureZoneFk',
columnClass: 'expand',
columnFilter: { columnFilter: {
component: 'select', component: VnInput,
inWhere: true, type: 'text',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
url: 'Zones', dense: true,
fields: ['id', 'name'],
}, },
}, },
columnField: { format: (val) => dashIfEmpty(val),
component: null,
},
format: (row, dashIfEmpty) => dashIfEmpty(row.futureZoneName),
}, },
{ {
label: t('advanceTickets.futureZone'),
name: 'futureZoneName',
field: 'futureZoneName',
align: 'left', align: 'left',
sortable: true,
columnFilter: {
component: VnSelect,
type: 'select',
filterValue: null,
filterParamKey: 'futureZoneFk',
event: getInputEvents,
attrs: {
options: zonesOptions.value,
'option-value': 'id',
'option-label': 'name',
dense: true,
},
},
format: (val) => dashIfEmpty(val),
},
{
label: t('advanceTickets.notMovableLines'), label: t('advanceTickets.notMovableLines'),
name: 'notMovableLines', name: 'notMovableLines',
field: 'notMovableLines',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureLines'), label: t('advanceTickets.futureLines'),
name: 'futureLines', name: 'futureLines',
field: 'futureLines',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureImport'), label: t('advanceTickets.futureImport'),
name: 'futureTotalWithVat', name: 'futureImport',
hidden: true, align: 'left',
format: (row) => toCurrency(row.futureTotalWithVat), sortable: true,
columnFilter: null,
}, },
]); ]);
@ -351,7 +448,7 @@ const handleCloseProgressDialog = () => {
const handleCancelProgress = () => (cancelProgress.value = true); const handleCancelProgress = () => (cancelProgress.value = true);
onMounted(async () => { onMounted(async () => {
let today = Date.vnNew().toISOString(); let today = Date.vnNew();
const tomorrow = new Date(today); const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);
userParams.dateFuture = tomorrow; userParams.dateFuture = tomorrow;
@ -360,13 +457,6 @@ onMounted(async () => {
const filter = { limit: 0 }; const filter = { limit: 0 };
await arrayData.addFilter({ filter, userParams }); await arrayData.addFilter({ filter, userParams });
}); });
const getColor = (row) => {
return row?.classColor ? `bg-${row.classColor}` : 'bg-orange';
};
const getFutureColor = (row) => {
return row?.futureClassColor ? `bg-${row.futureClassColor}` : 'bg-orange';
};
</script> </script>
<template> <template>
@ -390,9 +480,9 @@ const getFutureColor = (row) => {
@on-fetch="(data) => (zonesOptions = data)" @on-fetch="(data) => (zonesOptions = data)"
/> />
<VnSearchbar <VnSearchbar
data-key="AdvanceTickets" data-key="WeeklyTickets"
:label="t('advanceTickets.search')" :label="t('weeklyTickets.search')"
:info="t('advanceTickets.searchInfo')" :info="t('weeklyTickets.searchInfo')"
/> />
<VnSubToolbar> <VnSubToolbar>
<template #st-data> <template #st-data>
@ -441,32 +531,73 @@ const getFutureColor = (row) => {
</template> </template>
</RightMenu> </RightMenu>
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<VnTable <QTable
ref="tableRef" :rows="tickets"
data-key="AdvanceTickets" :columns="ticketColumns"
url="TicketWeeklies/filter" row-key="index"
:columns="columns" selection="multiple"
auto-load
:right-search="false"
:disable-option="{ card: true }"
v-model:selected="selectedTickets" v-model:selected="selectedTickets"
:table="{ :pagination="{ rowsPerPage: 0 }"
'row-key': 'id', :no-data-label="t('globals.noResults')"
selection: 'multiple', style="max-width: 99%"
}"
> >
<!--TODO: arreglar estilos--> <template #header="props">
<template #before-header> <QTr :props="props">
<span class="horizontal-separator" translate> <QTh
{{ t('advanceTickets.destination') }} class="horizontal-separator text-uppercase color-vn-label"
{{ toDateFormat(userParams.dateToAdvance) }} colspan="7"
</span> translate
<span class="horizontal-separator" translate> >
{{ t('advanceTickets.origin') }} {{ t('advanceTickets.destination') }}
{{ toDateFormat(userParams.dateFuture) }} {{ toDateFormat(userParams.dateToAdvance) }}
</span> </QTh>
<QTh
class="horizontal-separator text-uppercase color-vn-label"
colspan="9"
translate
>
{{ t('advanceTickets.origin') }}
{{ toDateFormat(userParams.dateFuture) }}
</QTh>
</QTr>
<QTr>
<QTh>
<QCheckbox v-model="props.selected" />
</QTh>
<QTh
v-for="(col, index) in ticketColumns"
:key="index"
:class="{ 'vertical-separator': col.name === 'futureId' }"
>
{{ col.label }}
</QTh>
</QTr>
</template> </template>
<template #column-icons="{ row }"> <template #top-row="{ cols }">
<QTr>
<QTd />
<QTd
v-for="(col, index) in cols"
:key="index"
style="max-width: 100px"
>
<component
:is="col.columnFilter.component"
v-if="col.columnFilter"
v-model="col.columnFilter.filterValue"
v-bind="col.columnFilter.attrs"
v-on="col.columnFilter.event(col)"
dense
/>
</QTd>
</QTr>
</template>
<template #header-cell-availableLines="{ col }">
<QTh class="vertical-separator">
{{ col.label }}
</QTh>
</template>
<template #body-cell-icons="{ row }">
<QTd class="q-gutter-x-xs"> <QTd class="q-gutter-x-xs">
<QIcon <QIcon
v-if="row.futureAgency !== row.agency && row.agency" v-if="row.futureAgency !== row.agency && row.agency"
@ -493,52 +624,73 @@ const getFutureColor = (row) => {
</QIcon> </QIcon>
</QTd> </QTd>
</template> </template>
<template #column-id="{ row }"> <template #body-cell-ticketId="{ row }">
<span class="link" @click.stop> <QTd>
{{ row.id }} <QBtn flat class="link">
<TicketDescriptorProxy :id="row.id" /> {{ row.id }}
</span> <TicketDescriptorProxy :id="row.id" />
</QBtn>
</QTd>
</template> </template>
<template #column-state="{ row }"> <template #body-cell-state="{ row }">
<QChip :class="getColor(row)" dense square> <QTd>
{{ row.state }} <QBadge
</QChip> text-color="black"
:color="row.classColor"
class="q-ma-none"
dense
>
{{ row.state }}
</QBadge>
</QTd>
</template> </template>
<template #column-totalWithVat="{ row }"> <template #body-cell-import="{ row }">
<QBadge <QTd>
:text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'" <QBadge
:color="totalPriceColor(row.totalWithVat)" :text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'"
class="q-ma-none" :color="totalPriceColor(row.totalWithVat)"
dense class="q-ma-none"
> dense
{{ toCurrency(row.totalWithVat || 0) }} >
</QBadge> {{ toCurrency(row.totalWithVat || 0) }}
</QBadge>
</QTd>
</template> </template>
<template #column-futureId="{ row }"> <template #body-cell-futureId="{ row }">
<!--TODO: arreglar estilos para que se muestre como antes, slot?--> <QTd class="vertical-separator">
<div class="vertical-separator"> <QBtn flat class="link" dense>
<span class="link" @click.stop>
{{ row.futureId }} {{ row.futureId }}
<TicketDescriptorProxy :id="row.futureId" /> <TicketDescriptorProxy :id="row.futureId" />
</span> </QBtn>
</div> </QTd>
</template> </template>
<template #column-futureState="{ row }"> <template #body-cell-futureState="{ row }">
<QChip :class="getFutureColor(row)" dense square> <QTd>
{{ row.futureState }} <QBadge
</QChip> text-color="black"
:color="row.futureClassColor"
class="q-ma-none"
dense
>
{{ row.futureState }}
</QBadge>
</QTd>
</template> </template>
<template #column-futureTotalWithVat="{ row }"> <template #body-cell-futureImport="{ row }">
<QBadge <QTd>
:text-color="isLessThan50(row.futureTotalWithVat) ? 'black' : 'white'" <QBadge
:color="totalPriceColor(row.futureTotalWithVat)" :text-color="
class="q-ma-none" isLessThan50(row.futureTotalWithVat) ? 'black' : 'white'
dense "
> :color="totalPriceColor(row.futureTotalWithVat)"
{{ toCurrency(row.futureTotalWithVat || 0) }} class="q-ma-none"
</QBadge> dense
>
{{ toCurrency(row.futureTotalWithVat || 0) }}
</QBadge>
</QTd>
</template> </template>
</VnTable> </QTable>
<VnProgress <VnProgress
:progress="progressPercentage" :progress="progressPercentage"
:cancelled="cancelProgress" :cancelled="cancelProgress"
@ -562,8 +714,6 @@ const getFutureColor = (row) => {
} }
.horizontal-separator { .horizontal-separator {
width: 100%; border-bottom: 4px solid white !important;
margin-top: 1%;
border-bottom: 5px solid white !important;
} }
</style> </style>