From 31f18507045e186fa65c8ae98c32fb4ee17b1a0a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 16 Apr 2025 14:12:23 +0200 Subject: [PATCH 01/22] feat: add multiple attribute --- src/components/common/VnInputDate.vue | 54 ++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/components/common/VnInputDate.vue b/src/components/common/VnInputDate.vue index 343130f1d..f361fb536 100644 --- a/src/components/common/VnInputDate.vue +++ b/src/components/common/VnInputDate.vue @@ -6,7 +6,6 @@ import { useRequired } from 'src/composables/useRequired'; const $attrs = useAttrs(); const { isRequired, requiredFieldRule } = useRequired($attrs); -const model = defineModel({ type: [String, Date] }); const $props = defineProps({ isOutlined: { @@ -17,6 +16,15 @@ const $props = defineProps({ type: Boolean, default: true, }, + multiple: { + type: Boolean, + default: false, + }, +}); + +const model = defineModel({ + type: [String, Date, Array], + default: null, }); const vnInputDateRef = ref(null); @@ -31,10 +39,17 @@ const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])]; const formattedDate = computed({ get() { if (!model.value) return model.value; + if ($props.multiple) { + return model.value + .map((d) => date.formatDate(new Date(d), dateFormat)) + .join(', '); + } return date.formatDate(new Date(model.value), dateFormat); }, set(value) { if (value == model.value) return; + if ($props.multiple) return; // No permitir edición manual en modo múltiple + let newDate; if (value) { // parse input @@ -47,7 +62,7 @@ const formattedDate = computed({ } const [year, month, day] = value.split('-').map((e) => parseInt(e)); newDate = new Date(year, month - 1, day); - if (model.value) { + if (model.value && !$props.multiple) { const orgDate = model.value instanceof Date ? model.value : new Date(model.value); @@ -63,12 +78,19 @@ const formattedDate = computed({ }, }); -const popupDate = computed(() => - model.value ? date.formatDate(new Date(model.value), 'YYYY/MM/DD') : model.value, -); +const popupDate = computed(() => { + if (!model.value) return model.value; + if ($props.multiple) { + return model.value.map((d) => date.formatDate(new Date(d), 'YYYY/MM/DD')); + } + return date.formatDate(new Date(model.value), 'YYYY/MM/DD'); +}); onMounted(() => { // fix quasar bug mask.value = '##/##/####'; + if ($props.multiple && !model.value) { + model.value = []; + } }); watch( () => model.value, @@ -86,8 +108,12 @@ const styleAttrs = computed(() => { : {}; }); -const manageDate = (date) => { - formattedDate.value = date; +const manageDate = (dates) => { + if ($props.multiple) { + model.value = dates.map((d) => new Date(d).toISOString()); + } else { + formattedDate.value = dates; + } isPopupOpen.value = false; }; @@ -98,7 +124,7 @@ const manageDate = (date) => { ref="vnInputDateRef" v-model="formattedDate" class="vn-input-date" - :mask="mask" + :mask="$props.multiple ? undefined : mask" placeholder="dd/mm/aaaa" v-bind="{ ...$attrs, ...styleAttrs }" :class="{ required: isRequired }" @@ -136,10 +162,18 @@ const manageDate = (date) => { :no-focus="true" :no-parent-event="true" > - + - + From 6c0fcc38b0cd8d329301f6eab8d486adb7876f48 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 16 Apr 2025 14:13:08 +0200 Subject: [PATCH 02/22] feat: apply multiple --- .../Ticket/Negative/TicketLackFilter.vue | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/pages/Ticket/Negative/TicketLackFilter.vue b/src/pages/Ticket/Negative/TicketLackFilter.vue index 78c030476..055b86ffd 100644 --- a/src/pages/Ticket/Negative/TicketLackFilter.vue +++ b/src/pages/Ticket/Negative/TicketLackFilter.vue @@ -7,6 +7,9 @@ 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'; +import VnDate from 'src/components/common/VnDate.vue'; +import VnInputDate from 'src/components/common/VnInputDate.vue'; + const { t } = useI18n(); const props = defineProps({ dataKey: { @@ -67,7 +70,6 @@ const setUserParams = (params) => { :data-key="props.dataKey" :search-button="true" @set-user-params="setUserParams" - :unremovable-params="['warehouseFk']" > +