From 6197d283e4fa2d104644848e3fa98ae7d60cf496 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Wed, 21 Aug 2024 10:51:38 -0300 Subject: [PATCH] Create ticket future filter --- src/components/ui/VnFilterPanel.vue | 2 +- src/pages/Ticket/TicketFuture.vue | 19 +- src/pages/Ticket/TicketFutureFilter.vue | 244 ++++++++++++++++++++++++ src/pages/Ticket/locale/en.yml | 5 + src/pages/Ticket/locale/es.yml | 5 + 5 files changed, 269 insertions(+), 6 deletions(-) create mode 100644 src/pages/Ticket/TicketFutureFilter.vue diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 9059605ca..3598f96a5 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -202,7 +202,7 @@ function formatValue(value) { function sanitizer(params) { for (const [key, value] of Object.entries(params)) { - if (typeof value == 'object') { + if (value && typeof value === 'object') { const param = Object.values(value)[0]; if (typeof param == 'string') params[key] = param.replaceAll('%', ''); } diff --git a/src/pages/Ticket/TicketFuture.vue b/src/pages/Ticket/TicketFuture.vue index 2fec6dc18..4ec430e2e 100644 --- a/src/pages/Ticket/TicketFuture.vue +++ b/src/pages/Ticket/TicketFuture.vue @@ -8,6 +8,8 @@ import VnSelect from 'src/components/common/VnSelect.vue'; import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; +import RightMenu from 'src/components/common/RightMenu.vue'; +import TicketFutureFilter from './TicketFutureFilter.vue'; import { dashIfEmpty, toCurrency } from 'src/filters'; import { useVnConfirm } from 'composables/useVnConfirm'; @@ -37,9 +39,9 @@ const exprBuilder = (param, value) => { return { liters: value }; case 'lines': return { lines: value }; - case 'ipt': + case 'iptColFilter': return { ipt: { like: `%${value}%` } }; - case 'futureIpt': + case 'futureIptColFilter': return { futureIpt: { like: `%${value}%` } }; case 'totalWithVat': return { totalWithVat: value }; @@ -83,6 +85,8 @@ const getInputEvents = (col) => { }; }; +const tickets = computed(() => store.data); + const ticketColumns = computed(() => [ { label: t('futureTickets.problems'), @@ -121,7 +125,7 @@ const ticketColumns = computed(() => [ sortable: true, columnFilter: { component: VnSelect, - filterParamKey: 'ipt', + filterParamKey: 'iptColFilter', type: 'select', filterValue: null, event: getInputEvents, @@ -214,7 +218,7 @@ const ticketColumns = computed(() => [ sortable: true, columnFilter: { component: VnSelect, - filterParamKey: 'futureIpt', + filterParamKey: 'futureIptColFilter', type: 'select', filterValue: null, event: getInputEvents, @@ -305,9 +309,14 @@ onMounted(async () => { + + + +import { ref } from 'vue'; +import { useI18n } from 'vue-i18n'; + +import FetchData from 'components/FetchData.vue'; +import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue'; +import VnSelect from 'components/common/VnSelect.vue'; +import VnInputDate from 'src/components/common/VnInputDate.vue'; +import VnInput from 'src/components/common/VnInput.vue'; + +import axios from 'axios'; +import { onMounted } from 'vue'; + +const { t } = useI18n(); +const props = defineProps({ + dataKey: { + type: String, + required: true, + }, +}); + +const warehousesOptions = ref([]); +const itemPackingTypes = ref([]); +const stateOptions = ref([]); + +const getItemPackingTypes = async () => { + try { + const filter = { + where: { isActive: true }, + }; + const { data } = await axios.get('ItemPackingTypes', { + params: { filter: JSON.stringify(filter) }, + }); + itemPackingTypes.value = data.map((ipt) => ({ + description: t(ipt.description), + code: ipt.code, + })); + } catch (error) { + console.error(error); + } +}; + +const getGroupedStates = async () => { + try { + const { data } = await axios.get('AlertLevels'); + stateOptions.value = data.map((state) => ({ + id: state.id, + name: t(`futureTickets.${state.code}`), + code: state.code, + })); + } catch (error) { + console.error(error); + } +}; + +onMounted(async () => { + getItemPackingTypes(); + getGroupedStates(); +}); + + + + + +en: + iptInfo: IPT + params: + originDated: Origin date + futureDated: Destination date + futureIpt: Destination IPT + ipt: Origin IPT + warehouseFk: Warehouse + litersMax: Max liters + linesMax: Max lines + state: Origin grouped state + futureState: Destination grouped state + problems: With problems +es: + Horizontal: Horizontal + Vertical: Vertical + iptInfo: Encajado + params: + originDated: Fecha origen + futureDated: Fecha destino + futureIpt: IPT destino + ipt: IPT Origen + warehouseFk: Almacén + litersMax: Litros máx. + linesMax: Líneas máx. + state: Estado agrupado origen + futureState: Estado agrupado destino + problems: Con problemas + diff --git a/src/pages/Ticket/locale/en.yml b/src/pages/Ticket/locale/en.yml index 10a8e1fa4..305228669 100644 --- a/src/pages/Ticket/locale/en.yml +++ b/src/pages/Ticket/locale/en.yml @@ -93,6 +93,11 @@ futureTickets: moveTicketSuccess: Tickets moved successfully! searchInfo: Search future tickets by date futureTicket: Future tickets + FREE: Free + ON_PREVIOUS: ON_PREVIOUS + ON_PREPARATION: On preparation + PACKED: Packed + DELIVERED: Delivered expedition: id: Expedition item: Item diff --git a/src/pages/Ticket/locale/es.yml b/src/pages/Ticket/locale/es.yml index a80692bfe..20b4edf16 100644 --- a/src/pages/Ticket/locale/es.yml +++ b/src/pages/Ticket/locale/es.yml @@ -140,6 +140,11 @@ futureTickets: moveTicketSuccess: Tickets movidos correctamente searchInfo: Buscar tickets por fecha futureTicket: Tickets a futuro + FREE: Libre + ON_PREVIOUS: ON_PREVIOUS + ON_PREPARATION: En preparación + PACKED: Encajado + DELIVERED: Servido ticketSale: id: Id visible: Visible