From c798874a9ebaced2c2a2f7486dc07aa193ca4d68 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Mon, 17 Jun 2024 17:27:06 -0300 Subject: [PATCH] Ticket future --- src/pages/Ticket/TicketFuture.vue | 123 +++++++++++++++++++++++------- src/pages/Ticket/locale/en.yml | 3 + src/pages/Ticket/locale/es.yml | 3 + 3 files changed, 103 insertions(+), 26 deletions(-) diff --git a/src/pages/Ticket/TicketFuture.vue b/src/pages/Ticket/TicketFuture.vue index ca3753424..6c635b98a 100644 --- a/src/pages/Ticket/TicketFuture.vue +++ b/src/pages/Ticket/TicketFuture.vue @@ -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 () => {