Last changes

This commit is contained in:
William Buezas 2024-05-15 09:39:15 -03:00
parent 9304b511bc
commit cd8095d3b8
8 changed files with 44 additions and 20 deletions

View File

@ -127,7 +127,8 @@ export function useArrayData(key, userOptions) {
store.filter = {}; store.filter = {};
if (params) store.userParams = Object.assign({}, params); if (params) store.userParams = Object.assign({}, params);
await fetch({ append: false }); const response = await fetch({ append: false });
return response;
} }
async function addFilter({ filter, params }) { async function addFilter({ filter, params }) {

View File

@ -73,7 +73,6 @@ const setData = (entity) => {
<ZoneDescriptorMenuItems :zone="entity" /> <ZoneDescriptorMenuItems :zone="entity" />
</template> --> </template> -->
<template #body="{ entity }"> <template #body="{ entity }">
{{ console.log('entity', entity) }}
<VnLv :label="t('summary.agency')" :value="entity.agencyMode.name" /> <VnLv :label="t('summary.agency')" :value="entity.agencyMode.name" />
<VnLv :label="t('summary.closeHour')" :value="toTimeFormat(entity.hour)" /> <VnLv :label="t('summary.closeHour')" :value="toTimeFormat(entity.hour)" />
<VnLv :label="t('summary.travelingDays')" :value="entity.travelingDays" /> <VnLv :label="t('summary.travelingDays')" :value="entity.travelingDays" />

View File

@ -15,8 +15,9 @@ const { viewSummary } = useSummaryDialog();
defineProps({ defineProps({
rows: { rows: {
type: Number, type: Array,
required: true, required: true,
default: () => [],
}, },
}); });

View File

@ -20,10 +20,6 @@ const props = defineProps({
type: Number, type: Number,
required: true, required: true,
}, },
events: {
type: Object,
default: null,
},
monthDate: { monthDate: {
type: Object, type: Object,
default: null, default: null,

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { computed, onMounted, ref } from 'vue'; import { computed, onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import ZoneDeliveryPanel from './ZoneDeliveryPanel.vue'; import ZoneDeliveryPanel from './ZoneDeliveryPanel.vue';
@ -7,6 +7,7 @@ import ZoneDeliveryCalendar from './ZoneDeliveryCalendar.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useWeekdayStore } from 'src/stores/useWeekdayStore'; import { useWeekdayStore } from 'src/stores/useWeekdayStore';
import { useArrayData } from 'src/composables/useArrayData';
const { t } = useI18n(); const { t } = useI18n();
const stateStore = useStateStore(); const stateStore = useStateStore();
@ -22,6 +23,9 @@ const days = ref({});
const exclusions = ref({}); const exclusions = ref({});
const geoExclusions = ref({}); const geoExclusions = ref({});
const events = ref([]); const events = ref([]);
const { store } = useArrayData('ZoneDeliveryDays', {
url: 'Zones/getEvents',
});
const refreshEvents = () => { const refreshEvents = () => {
days.value = {}; days.value = {};
@ -133,6 +137,14 @@ const data = computed({
}, },
}); });
watch(
() => store.data,
(value) => {
data.value = value;
},
{ immediate: true }
);
const getMonthNameAndYear = (date) => { const getMonthNameAndYear = (date) => {
const monthName = weekdayStore.getLocaleMonths[date.getMonth()].locale; const monthName = weekdayStore.getLocaleMonths[date.getMonth()].locale;
const year = date.getFullYear(); const year = date.getFullYear();
@ -184,7 +196,7 @@ onMounted(async () => {
</template> </template>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above> <QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8"> <QScrollArea class="fit text-grey-8">
<ZoneDeliveryPanel @on-fetch-events="($event) => (data = $event)" /> <ZoneDeliveryPanel />
</QScrollArea> </QScrollArea>
</QDrawer> </QDrawer>
<QPage class="q-pa-md flex justify-center"> <QPage class="q-pa-md flex justify-center">

View File

@ -5,13 +5,13 @@ import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import { useArrayData } from 'src/composables/useArrayData';
import axios from 'axios'; import axios from 'axios';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { watch } from 'vue'; import { watch } from 'vue';
const { t } = useI18n(); const { t } = useI18n();
const { notify } = useNotify(); const { notify } = useNotify();
const emit = defineEmits(['onFetchEvents']);
const deliveryMethodFk = ref(null); const deliveryMethodFk = ref(null);
const postcodesOptions = ref([]); const postcodesOptions = ref([]);
@ -26,6 +26,10 @@ const agencyFilter = ref({
limit: 30, limit: 30,
}); });
const arrayData = useArrayData('ZoneDeliveryDays', {
url: 'Zones/getEvents',
});
const fetchDeliveryMethods = async (filter) => { const fetchDeliveryMethods = async (filter) => {
try { try {
const params = { filter: JSON.stringify(filter) }; const params = { filter: JSON.stringify(filter) };
@ -62,22 +66,32 @@ const fetchAgencyModes = async (filter) => {
} }
}; };
const fetchData = async () => { const fetchData = async (params) => {
try { try {
const params = { deliveryMethodFk: deliveryMethodFk.value, ...formData }; const { data } = params
const { data } = await axios.get('Zones/getEvents', { params }); ? await arrayData.applyFilter({
if (!data.events || !data.events.length) { params,
})
: await arrayData.fetch({ append: false });
if (!data.events || !data.events.length)
notify(t('deliveryPanel.noEventsWarning'), 'warning'); notify(t('deliveryPanel.noEventsWarning'), 'warning');
return;
}
emit('onFetchEvents', data);
} catch (err) { } catch (err) {
console.error('Error fetching events: ', err); console.error('Error fetching events: ', err);
} }
}; };
const onSubmit = async () => {
const params = { deliveryMethodFk: deliveryMethodFk.value, ...formData };
await fetchData(params);
};
onMounted(async () => { onMounted(async () => {
deliveryMethodFk.value = 'delivery'; deliveryMethodFk.value = 'delivery';
await fetchData();
if (arrayData?.store?.userParams && arrayData?.store?.userParams) {
formData.geoFk = arrayData.store?.userParams?.geoFk;
formData.agencyModeFk = arrayData.store?.userParams?.agencyModeFk;
}
}); });
</script> </script>
@ -88,7 +102,7 @@ onMounted(async () => {
@on-fetch="(data) => (postcodesOptions = data)" @on-fetch="(data) => (postcodesOptions = data)"
auto-load auto-load
/> />
<QForm @submit="fetchData()" class="q-pa-md"> <QForm @submit="onSubmit()" class="q-pa-md">
<div class="column q-gutter-y-sm"> <div class="column q-gutter-y-sm">
<QRadio <QRadio
v-model="deliveryMethodFk" v-model="deliveryMethodFk"

View File

@ -51,6 +51,6 @@ zoneClosingTable:
name: Name name: Name
agency: Agency agency: Agency
closing: Closing closing: Closing
price: Precio price: Price
preview: Preview preview: Preview
zones: Zones zones: Zones

View File

@ -46,10 +46,11 @@ deliveryPanel:
warehouse: Almacén warehouse: Almacén
query: Consultar query: Consultar
noEventsWarning: No hay servicio para la zona especificada noEventsWarning: No hay servicio para la zona especificada
ZoneClosingTable: zoneClosingTable:
id: Id id: Id
name: Nombre name: Nombre
agency: Agencia agency: Agencia
closing: Cierre closing: Cierre
preview: Vista previa
price: Precio price: Precio
zones: Zonas zones: Zonas