forked from verdnatura/salix-front
Ticket future
This commit is contained in:
parent
06e8e819f4
commit
c798874a9e
|
@ -16,6 +16,7 @@ import { getDateQBadgeColor } from 'src/composables/getDateQBadgeColor.js';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { toDateTimeFormat } from 'src/filters/date.js';
|
import { toDateTimeFormat } from 'src/filters/date.js';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -23,7 +24,7 @@ const { openConfirmationModal } = useVnConfirm();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
|
|
||||||
const agencyModesOptions = ref([]);
|
const itemPackingTypesOptions = ref([]);
|
||||||
const selectedTickets = ref([]);
|
const selectedTickets = ref([]);
|
||||||
|
|
||||||
const exprBuilder = (param, value) => {
|
const exprBuilder = (param, value) => {
|
||||||
|
@ -68,8 +69,7 @@ const applyColumnFilter = async (col) => {
|
||||||
try {
|
try {
|
||||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||||
params[paramKey] = col.columnFilter.filterValue;
|
params[paramKey] = col.columnFilter.filterValue;
|
||||||
console.log('paramKey', paramKey, 'params', params);
|
await arrayData.addFilter({ params });
|
||||||
await arrayData.applyFilter({ params });
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error applying column filter', err);
|
console.error('Error applying column filter', err);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,19 @@ const ticketColumns = computed(() => [
|
||||||
field: 'ipt',
|
field: 'ipt',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
columnFilter: null,
|
columnFilter: {
|
||||||
|
component: VnSelect,
|
||||||
|
filterParamKey: 'ipt',
|
||||||
|
type: 'select',
|
||||||
|
filterValue: null,
|
||||||
|
event: getInputEvents,
|
||||||
|
attrs: {
|
||||||
|
options: itemPackingTypesOptions.value,
|
||||||
|
'option-value': 'code',
|
||||||
|
'option-label': 'description',
|
||||||
|
dense: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
format: (val) => dashIfEmpty(val),
|
format: (val) => dashIfEmpty(val),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -135,7 +147,15 @@ const ticketColumns = computed(() => [
|
||||||
field: 'liters',
|
field: 'liters',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
columnFilter: null,
|
columnFilter: {
|
||||||
|
component: VnInput,
|
||||||
|
type: 'text',
|
||||||
|
filterValue: null,
|
||||||
|
event: getInputEvents,
|
||||||
|
attrs: {
|
||||||
|
dense: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('futureTickets.import'),
|
label: t('futureTickets.import'),
|
||||||
|
@ -143,16 +163,6 @@ const ticketColumns = computed(() => [
|
||||||
name: 'import',
|
name: 'import',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
// columnFilter: {
|
|
||||||
// component: VnInput,
|
|
||||||
// type: 'text',
|
|
||||||
// filterValue: null,
|
|
||||||
// event: getInputEvents,
|
|
||||||
// filterParamKey: 'nickName',
|
|
||||||
// attrs: {
|
|
||||||
// dense: true,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('futureTickets.availableLines'),
|
label: t('futureTickets.availableLines'),
|
||||||
|
@ -160,7 +170,15 @@ const ticketColumns = computed(() => [
|
||||||
field: 'lines',
|
field: 'lines',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
columnFilter: null,
|
columnFilter: {
|
||||||
|
component: VnInput,
|
||||||
|
type: 'text',
|
||||||
|
filterValue: null,
|
||||||
|
event: getInputEvents,
|
||||||
|
attrs: {
|
||||||
|
dense: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
format: (val) => dashIfEmpty(val),
|
format: (val) => dashIfEmpty(val),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -168,7 +186,16 @@ const ticketColumns = computed(() => [
|
||||||
name: 'futureId',
|
name: 'futureId',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
columnFilter: null,
|
columnFilter: {
|
||||||
|
component: VnInput,
|
||||||
|
type: 'text',
|
||||||
|
filterValue: null,
|
||||||
|
filterParamKey: 'futureId',
|
||||||
|
event: getInputEvents,
|
||||||
|
attrs: {
|
||||||
|
dense: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('futureTickets.futureShipped'),
|
label: t('futureTickets.futureShipped'),
|
||||||
|
@ -185,7 +212,19 @@ const ticketColumns = computed(() => [
|
||||||
field: 'futureIpt',
|
field: 'futureIpt',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
columnFilter: null,
|
columnFilter: {
|
||||||
|
component: VnSelect,
|
||||||
|
filterParamKey: 'futureIpt',
|
||||||
|
type: 'select',
|
||||||
|
filterValue: null,
|
||||||
|
event: getInputEvents,
|
||||||
|
attrs: {
|
||||||
|
options: itemPackingTypesOptions.value,
|
||||||
|
'option-value': 'code',
|
||||||
|
'option-label': 'description',
|
||||||
|
dense: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
format: (val) => dashIfEmpty(val),
|
format: (val) => dashIfEmpty(val),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -204,6 +243,24 @@ const isLessThan50 = (totalWithVat) =>
|
||||||
const totalPriceColor = (totalWithVat) =>
|
const totalPriceColor = (totalWithVat) =>
|
||||||
isLessThan50(totalWithVat) ? 'warning' : 'transparent';
|
isLessThan50(totalWithVat) ? 'warning' : 'transparent';
|
||||||
|
|
||||||
|
const moveTicketsFuture = async () => {
|
||||||
|
try {
|
||||||
|
const ticketsToMove = selectedTickets.value.map((ticket) => ({
|
||||||
|
originId: ticket.id,
|
||||||
|
destinationId: ticket.futureId,
|
||||||
|
originShipped: ticket.shipped,
|
||||||
|
destinationShipped: ticket.futureShipped,
|
||||||
|
workerFk: ticket.workerFk,
|
||||||
|
}));
|
||||||
|
|
||||||
|
let params = { tickets: ticketsToMove };
|
||||||
|
await axios.post('Tickets/merge', params);
|
||||||
|
notify(t('futureTickets.moveTicketSuccess'), 'positive');
|
||||||
|
arrayData.fetch({ append: false });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error moving tickets to future', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await arrayData.fetch({ append: false });
|
await arrayData.fetch({ append: false });
|
||||||
});
|
});
|
||||||
|
@ -211,9 +268,14 @@ onMounted(async () => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Tickets/getTicketsFuture"
|
url="itemPackingTypes"
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name' }"
|
:filter="{
|
||||||
@on-fetch="(data) => (agencyModesOptions = data)"
|
fields: ['code', 'description'],
|
||||||
|
order: 'description ASC',
|
||||||
|
where: { isActive: true },
|
||||||
|
}"
|
||||||
|
auto-load
|
||||||
|
@on-fetch="(data) => (itemPackingTypesOptions = data)"
|
||||||
/>
|
/>
|
||||||
<VnSearchbar
|
<VnSearchbar
|
||||||
data-key="WeeklyTickets"
|
data-key="WeeklyTickets"
|
||||||
|
@ -222,7 +284,20 @@ onMounted(async () => {
|
||||||
/>
|
/>
|
||||||
<VnSubToolbar>
|
<VnSubToolbar>
|
||||||
<template #st-data>
|
<template #st-data>
|
||||||
<QBtn icon="keyboard_double_arrow_right" color="primary" />
|
<QBtn
|
||||||
|
icon="keyboard_double_arrow_right"
|
||||||
|
color="primary"
|
||||||
|
:disable="!selectedTickets.length"
|
||||||
|
@click.stop="
|
||||||
|
openConfirmationModal(
|
||||||
|
t('futureTickets.moveTicketTitle'),
|
||||||
|
t(`futureTickets.moveTicketDialogSubtitle`, {
|
||||||
|
selectedTickets: selectedTickets.length,
|
||||||
|
}),
|
||||||
|
moveTicketsFuture
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnSubToolbar>
|
</VnSubToolbar>
|
||||||
<QPage class="column items-center q-pa-md">
|
<QPage class="column items-center q-pa-md">
|
||||||
|
@ -437,7 +512,3 @@ onMounted(async () => {
|
||||||
border-bottom: 4px solid white !important;
|
border-bottom: 4px solid white !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
</i18n>
|
|
||||||
|
|
|
@ -20,3 +20,6 @@ futureTickets:
|
||||||
risk: Risk
|
risk: Risk
|
||||||
origin: Origin
|
origin: Origin
|
||||||
destination: Destination
|
destination: Destination
|
||||||
|
moveTicketTitle: Move tickets
|
||||||
|
moveTicketDialogSubtitle: 'Do you want to move {selectedTickets} tickets to the future?'
|
||||||
|
moveTicketSuccess: Tickets moved successfully!
|
||||||
|
|
|
@ -20,5 +20,8 @@ futureTickets:
|
||||||
rounding: Redondeo
|
rounding: Redondeo
|
||||||
origin: Origen
|
origin: Origen
|
||||||
destination: Destino
|
destination: Destino
|
||||||
|
moveTicketTitle: Mover tickets
|
||||||
|
moveTicketDialogSubtitle: '¿Desea mover {selectedTickets} tickets hacia el futuro?'
|
||||||
|
moveTicketSuccess: Tickets movidos correctamente
|
||||||
Search ticket: Buscar ticket
|
Search ticket: Buscar ticket
|
||||||
You can search by ticket id or alias: Puedes buscar por id o alias del ticket
|
You can search by ticket id or alias: Puedes buscar por id o alias del ticket
|
||||||
|
|
Loading…
Reference in New Issue