From 23670debd113401d2cecd5d5fc27a8073bbb0828 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 12 Mar 2025 15:34:30 +0100 Subject: [PATCH] feat: add VnInputDateTime component and enhance date handling functions --- src/boot/vnDate.js | 24 ++++++ src/components/common/VnInputDateTime.vue | 83 +++++++++++++++++++ .../Ticket/Negative/TicketLackFilter.vue | 33 ++------ src/pages/Ticket/Negative/TicketLackList.vue | 19 +++-- src/pages/Ticket/locale/en.yml | 1 + src/pages/Ticket/locale/es.yml | 6 +- 6 files changed, 130 insertions(+), 36 deletions(-) create mode 100644 src/components/common/VnInputDateTime.vue diff --git a/src/boot/vnDate.js b/src/boot/vnDate.js index 33d5ac27f..0c6417fe2 100644 --- a/src/boot/vnDate.js +++ b/src/boot/vnDate.js @@ -1,4 +1,6 @@ import { boot } from 'quasar/wrappers'; +import { date as quasarDate } from 'quasar'; +const { formatDate } = quasarDate; export default boot(() => { Date.vnUTC = () => { @@ -25,4 +27,26 @@ export default boot(() => { const date = new Date(Date.vnUTC()); return new Date(date.getFullYear(), date.getMonth() + 1, 0); }; + Date.getCurrentDateTimeFormatted = ( + endOfDay = true, + options = { iso: true, mask: 'DD-MM-YYYY HH:mm' }, + ) => { + const date = Date.vnUTC(); + if (endOfDay) { + date.setHours(23, 59, 0); + } + if (options.iso) { + return date.toISOString(); + } + return formatDate(date, options.mask); + }; + Date.convertToISODateTime = (dateTimeStr) => { + // Convertir de formato "DD-MM-YYYY HH:mm" a ISO + const [datePart, timePart] = dateTimeStr.split(' '); + const [day, month, year] = datePart.split('-'); + const [hours, minutes] = timePart.split(':'); + + const isoDate = new Date(year, month - 1, day, hours, minutes); + return isoDate.toISOString(); + }; }); diff --git a/src/components/common/VnInputDateTime.vue b/src/components/common/VnInputDateTime.vue new file mode 100644 index 000000000..dea70a160 --- /dev/null +++ b/src/components/common/VnInputDateTime.vue @@ -0,0 +1,83 @@ + + + + + es: + Open date: Abrir fecha + diff --git a/src/pages/Ticket/Negative/TicketLackFilter.vue b/src/pages/Ticket/Negative/TicketLackFilter.vue index 3762f453d..d064a94d5 100644 --- a/src/pages/Ticket/Negative/TicketLackFilter.vue +++ b/src/pages/Ticket/Negative/TicketLackFilter.vue @@ -6,6 +6,7 @@ import FetchData from 'components/FetchData.vue'; import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue'; import VnInput from 'src/components/common/VnInput.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; +import VnInputDateTime from 'src/components/common/VnInputDateTime.vue'; const { t } = useI18n(); const props = defineProps({ dataKey: { @@ -66,6 +67,7 @@ const setUserParams = (params) => { :data-key="props.dataKey" :search-button="true" @set-user-params="setUserParams" + :unremovable-params="['warehouseFk']" > - {{ filterRef }}