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 { useState } from 'src/composables/useState';
|
||||
import { toDateTimeFormat } from 'src/filters/date.js';
|
||||
import axios from 'axios';
|
||||
|
||||
const state = useState();
|
||||
const { t } = useI18n();
|
||||
|
@ -23,7 +24,7 @@ const { openConfirmationModal } = useVnConfirm();
|
|||
const { notify } = useNotify();
|
||||
const user = state.getUser();
|
||||
|
||||
const agencyModesOptions = ref([]);
|
||||
const itemPackingTypesOptions = ref([]);
|
||||
const selectedTickets = ref([]);
|
||||
|
||||
const exprBuilder = (param, value) => {
|
||||
|
@ -68,8 +69,7 @@ const applyColumnFilter = async (col) => {
|
|||
try {
|
||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
||||
params[paramKey] = col.columnFilter.filterValue;
|
||||
console.log('paramKey', paramKey, 'params', params);
|
||||
await arrayData.applyFilter({ params });
|
||||
await arrayData.addFilter({ params });
|
||||
} catch (err) {
|
||||
console.error('Error applying column filter', err);
|
||||
}
|
||||
|
@ -119,7 +119,19 @@ const ticketColumns = computed(() => [
|
|||
field: 'ipt',
|
||||
align: 'left',
|
||||
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),
|
||||
},
|
||||
{
|
||||
|
@ -135,7 +147,15 @@ const ticketColumns = computed(() => [
|
|||
field: 'liters',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('futureTickets.import'),
|
||||
|
@ -143,16 +163,6 @@ const ticketColumns = computed(() => [
|
|||
name: 'import',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
// columnFilter: {
|
||||
// component: VnInput,
|
||||
// type: 'text',
|
||||
// filterValue: null,
|
||||
// event: getInputEvents,
|
||||
// filterParamKey: 'nickName',
|
||||
// attrs: {
|
||||
// dense: true,
|
||||
// },
|
||||
// },
|
||||
},
|
||||
{
|
||||
label: t('futureTickets.availableLines'),
|
||||
|
@ -160,7 +170,15 @@ const ticketColumns = computed(() => [
|
|||
field: 'lines',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
format: (val) => dashIfEmpty(val),
|
||||
},
|
||||
{
|
||||
|
@ -168,7 +186,16 @@ const ticketColumns = computed(() => [
|
|||
name: 'futureId',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
columnFilter: null,
|
||||
columnFilter: {
|
||||
component: VnInput,
|
||||
type: 'text',
|
||||
filterValue: null,
|
||||
filterParamKey: 'futureId',
|
||||
event: getInputEvents,
|
||||
attrs: {
|
||||
dense: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t('futureTickets.futureShipped'),
|
||||
|
@ -185,7 +212,19 @@ const ticketColumns = computed(() => [
|
|||
field: 'futureIpt',
|
||||
align: 'left',
|
||||
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),
|
||||
},
|
||||
{
|
||||
|
@ -204,6 +243,24 @@ const isLessThan50 = (totalWithVat) =>
|
|||
const totalPriceColor = (totalWithVat) =>
|
||||
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 () => {
|
||||
await arrayData.fetch({ append: false });
|
||||
});
|
||||
|
@ -211,9 +268,14 @@ onMounted(async () => {
|
|||
|
||||
<template>
|
||||
<FetchData
|
||||
url="Tickets/getTicketsFuture"
|
||||
:filter="{ fields: ['id', 'name'], order: 'name' }"
|
||||
@on-fetch="(data) => (agencyModesOptions = data)"
|
||||
url="itemPackingTypes"
|
||||
:filter="{
|
||||
fields: ['code', 'description'],
|
||||
order: 'description ASC',
|
||||
where: { isActive: true },
|
||||
}"
|
||||
auto-load
|
||||
@on-fetch="(data) => (itemPackingTypesOptions = data)"
|
||||
/>
|
||||
<VnSearchbar
|
||||
data-key="WeeklyTickets"
|
||||
|
@ -222,7 +284,20 @@ onMounted(async () => {
|
|||
/>
|
||||
<VnSubToolbar>
|
||||
<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>
|
||||
</VnSubToolbar>
|
||||
<QPage class="column items-center q-pa-md">
|
||||
|
@ -437,7 +512,3 @@ onMounted(async () => {
|
|||
border-bottom: 4px solid white !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
</i18n>
|
||||
|
|
|
@ -20,3 +20,6 @@ futureTickets:
|
|||
risk: Risk
|
||||
origin: Origin
|
||||
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
|
||||
origin: Origen
|
||||
destination: Destino
|
||||
moveTicketTitle: Mover tickets
|
||||
moveTicketDialogSubtitle: '¿Desea mover {selectedTickets} tickets hacia el futuro?'
|
||||
moveTicketSuccess: Tickets movidos correctamente
|
||||
Search ticket: Buscar ticket
|
||||
You can search by ticket id or alias: Puedes buscar por id o alias del ticket
|
||||
|
|
Loading…
Reference in New Issue