fix: ticketFilter adapt VnInputDate
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2024-07-01 09:00:45 +02:00
parent c399d40daf
commit f4975d1f15
3 changed files with 21 additions and 23 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { computed, ref } from 'vue'; import { onMounted, watch, computed, ref } from 'vue';
import { date } from 'quasar'; import { date } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
@ -19,12 +19,18 @@ const $props = defineProps({
}, },
}); });
const emit = defineEmits(['update:modelValue']);
const { t } = useI18n(); const { t } = useI18n();
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired'); const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
const dateFormat = 'DD/MM/YYYY';
const isPopupOpen = ref(false); const isPopupOpen = ref(false);
const hover = ref(false); const hover = ref(false);
const mask = ref();
onMounted(() => {
// fix quasar bug
mask.value = '##/##/####';
});
const styleAttrs = computed(() => { const styleAttrs = computed(() => {
return $props.isOutlined return $props.isOutlined
@ -36,7 +42,6 @@ const styleAttrs = computed(() => {
: {}; : {};
}); });
const dateFormat = 'DD/MM/YYYY';
const formattedDate = computed({ const formattedDate = computed({
get() { get() {
if (!model.value) return model.value; if (!model.value) return model.value;
@ -50,7 +55,7 @@ const formattedDate = computed({
if (value.at(2) == '/') value = value.split('/').reverse().join('/'); if (value.at(2) == '/') value = value.split('/').reverse().join('/');
value = date.formatDate( value = date.formatDate(
new Date(value).toISOString(), new Date(value).toISOString(),
'YYYY-MM-DDTHH:mm:ss.SSSZ', 'YYYY-MM-DDTHH:mm:ss.SSSZ'
); );
} }
let ymd = value.split('-').map((e) => parseInt(e)); let ymd = value.split('-').map((e) => parseInt(e));
@ -63,7 +68,7 @@ const formattedDate = computed({
orgDate.getHours(), orgDate.getHours(),
orgDate.getMinutes(), orgDate.getMinutes(),
orgDate.getSeconds(), orgDate.getSeconds(),
orgDate.getMilliseconds(), orgDate.getMilliseconds()
); );
} }
} }
@ -72,7 +77,13 @@ const formattedDate = computed({
}); });
const popupDate = computed(() => const popupDate = computed(() =>
model.value ? date.formatDate(new Date(model.value), 'YYYY/MM/DD') : model.value, model.value ? date.formatDate(new Date(model.value), 'YYYY/MM/DD') : model.value
);
watch(
() => model.value,
(val) => (formattedDate.value = val),
{ immediate: true }
); );
</script> </script>
@ -81,7 +92,7 @@ const popupDate = computed(() =>
<QInput <QInput
v-model="formattedDate" v-model="formattedDate"
class="vn-input-date" class="vn-input-date"
mask="##/##/####" :mask="mask"
placeholder="dd/mm/aaaa" placeholder="dd/mm/aaaa"
v-bind="{ ...$attrs, ...styleAttrs }" v-bind="{ ...$attrs, ...styleAttrs }"
:class="{ required: $attrs.required }" :class="{ required: $attrs.required }"

View File

@ -17,15 +17,6 @@ const props = defineProps({
}, },
}); });
const from = Date.vnNew();
const to = Date.vnNew();
to.setDate(to.getDate() + 1);
const defaultParams = {
from: toDateString(from),
to: toDateString(to),
};
const workers = ref(); const workers = ref();
const provinces = ref(); const provinces = ref();
const states = ref(); const states = ref();
@ -44,11 +35,7 @@ const warehouses = ref();
@on-fetch="(data) => (workers = data)" @on-fetch="(data) => (workers = data)"
auto-load auto-load
/> />
<VnFilterPanel <VnFilterPanel :data-key="props.dataKey" :search-button="true">
:data-key="props.dataKey"
:params="defaultParams"
:search-button="true"
>
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong> <strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -26,8 +26,8 @@ const to = Date.vnNew();
to.setDate(to.getDate() + 1); to.setDate(to.getDate() + 1);
const userParams = { const userParams = {
from: toDateString(from), from: from.toISOString(),
to: toDateString(to), to: to.toISOString(),
}; };
function navigate(id) { function navigate(id) {