Last changes
This commit is contained in:
parent
9304b511bc
commit
cd8095d3b8
|
@ -127,7 +127,8 @@ export function useArrayData(key, userOptions) {
|
|||
store.filter = {};
|
||||
if (params) store.userParams = Object.assign({}, params);
|
||||
|
||||
await fetch({ append: false });
|
||||
const response = await fetch({ append: false });
|
||||
return response;
|
||||
}
|
||||
|
||||
async function addFilter({ filter, params }) {
|
||||
|
|
|
@ -73,7 +73,6 @@ const setData = (entity) => {
|
|||
<ZoneDescriptorMenuItems :zone="entity" />
|
||||
</template> -->
|
||||
<template #body="{ entity }">
|
||||
{{ console.log('entity', entity) }}
|
||||
<VnLv :label="t('summary.agency')" :value="entity.agencyMode.name" />
|
||||
<VnLv :label="t('summary.closeHour')" :value="toTimeFormat(entity.hour)" />
|
||||
<VnLv :label="t('summary.travelingDays')" :value="entity.travelingDays" />
|
||||
|
|
|
@ -15,8 +15,9 @@ const { viewSummary } = useSummaryDialog();
|
|||
|
||||
defineProps({
|
||||
rows: {
|
||||
type: Number,
|
||||
type: Array,
|
||||
required: true,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -20,10 +20,6 @@ const props = defineProps({
|
|||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
events: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
monthDate: {
|
||||
type: Object,
|
||||
default: null,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import ZoneDeliveryPanel from './ZoneDeliveryPanel.vue';
|
||||
|
@ -7,6 +7,7 @@ import ZoneDeliveryCalendar from './ZoneDeliveryCalendar.vue';
|
|||
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const { t } = useI18n();
|
||||
const stateStore = useStateStore();
|
||||
|
@ -22,6 +23,9 @@ const days = ref({});
|
|||
const exclusions = ref({});
|
||||
const geoExclusions = ref({});
|
||||
const events = ref([]);
|
||||
const { store } = useArrayData('ZoneDeliveryDays', {
|
||||
url: 'Zones/getEvents',
|
||||
});
|
||||
|
||||
const refreshEvents = () => {
|
||||
days.value = {};
|
||||
|
@ -133,6 +137,14 @@ const data = computed({
|
|||
},
|
||||
});
|
||||
|
||||
watch(
|
||||
() => store.data,
|
||||
(value) => {
|
||||
data.value = value;
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const getMonthNameAndYear = (date) => {
|
||||
const monthName = weekdayStore.getLocaleMonths[date.getMonth()].locale;
|
||||
const year = date.getFullYear();
|
||||
|
@ -184,7 +196,7 @@ onMounted(async () => {
|
|||
</template>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<ZoneDeliveryPanel @on-fetch-events="($event) => (data = $event)" />
|
||||
<ZoneDeliveryPanel />
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<QPage class="q-pa-md flex justify-center">
|
||||
|
|
|
@ -5,13 +5,13 @@ import { useI18n } from 'vue-i18n';
|
|||
import FetchData from 'components/FetchData.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { watch } from 'vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const emit = defineEmits(['onFetchEvents']);
|
||||
|
||||
const deliveryMethodFk = ref(null);
|
||||
const postcodesOptions = ref([]);
|
||||
|
@ -26,6 +26,10 @@ const agencyFilter = ref({
|
|||
limit: 30,
|
||||
});
|
||||
|
||||
const arrayData = useArrayData('ZoneDeliveryDays', {
|
||||
url: 'Zones/getEvents',
|
||||
});
|
||||
|
||||
const fetchDeliveryMethods = async (filter) => {
|
||||
try {
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
|
@ -62,22 +66,32 @@ const fetchAgencyModes = async (filter) => {
|
|||
}
|
||||
};
|
||||
|
||||
const fetchData = async () => {
|
||||
const fetchData = async (params) => {
|
||||
try {
|
||||
const params = { deliveryMethodFk: deliveryMethodFk.value, ...formData };
|
||||
const { data } = await axios.get('Zones/getEvents', { params });
|
||||
if (!data.events || !data.events.length) {
|
||||
const { data } = params
|
||||
? await arrayData.applyFilter({
|
||||
params,
|
||||
})
|
||||
: await arrayData.fetch({ append: false });
|
||||
if (!data.events || !data.events.length)
|
||||
notify(t('deliveryPanel.noEventsWarning'), 'warning');
|
||||
return;
|
||||
}
|
||||
emit('onFetchEvents', data);
|
||||
} catch (err) {
|
||||
console.error('Error fetching events: ', err);
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
const params = { deliveryMethodFk: deliveryMethodFk.value, ...formData };
|
||||
await fetchData(params);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
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>
|
||||
|
||||
|
@ -88,7 +102,7 @@ onMounted(async () => {
|
|||
@on-fetch="(data) => (postcodesOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
<QForm @submit="fetchData()" class="q-pa-md">
|
||||
<QForm @submit="onSubmit()" class="q-pa-md">
|
||||
<div class="column q-gutter-y-sm">
|
||||
<QRadio
|
||||
v-model="deliveryMethodFk"
|
||||
|
|
|
@ -51,6 +51,6 @@ zoneClosingTable:
|
|||
name: Name
|
||||
agency: Agency
|
||||
closing: Closing
|
||||
price: Precio
|
||||
price: Price
|
||||
preview: Preview
|
||||
zones: Zones
|
||||
|
|
|
@ -46,10 +46,11 @@ deliveryPanel:
|
|||
warehouse: Almacén
|
||||
query: Consultar
|
||||
noEventsWarning: No hay servicio para la zona especificada
|
||||
ZoneClosingTable:
|
||||
zoneClosingTable:
|
||||
id: Id
|
||||
name: Nombre
|
||||
agency: Agencia
|
||||
closing: Cierre
|
||||
preview: Vista previa
|
||||
price: Precio
|
||||
zones: Zonas
|
||||
|
|
Loading…
Reference in New Issue