forked from verdnatura/salix-front
perf: use FetchData instead VnPAginate
This commit is contained in:
parent
4fa5d47481
commit
8d59cfa9c3
|
@ -2,7 +2,7 @@
|
||||||
import { onBeforeMount, ref, watch } from 'vue';
|
import { onBeforeMount, ref, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ const addressFilter = {
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
const { id } = route.params;
|
const { id } = route.params;
|
||||||
// getAddressesData(id);
|
|
||||||
getClientData(id);
|
getClientData(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,14 +60,9 @@ watch(
|
||||||
() => route.params.id,
|
() => route.params.id,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
if (!newValue) return;
|
if (!newValue) return;
|
||||||
// getAddressesData(newValue);
|
|
||||||
getClientData(newValue);
|
getClientData(newValue);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
async function onFetch(data) {
|
|
||||||
addresses.value = data;
|
|
||||||
sortAddresses();
|
|
||||||
}
|
|
||||||
|
|
||||||
const getClientData = async (id) => {
|
const getClientData = async (id) => {
|
||||||
try {
|
try {
|
||||||
|
@ -94,9 +88,9 @@ const setDefault = (address) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const sortAddresses = () => {
|
const sortAddresses = (data) => {
|
||||||
if (!client.value || !addresses.value) return;
|
if (!client.value || !data) return;
|
||||||
addresses.value = addresses.value.sort((a, b) => {
|
addresses.value = data.sort((a, b) => {
|
||||||
return isDefaultAddress(b) - isDefaultAddress(a);
|
return isDefaultAddress(b) - isDefaultAddress(a);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -117,17 +111,17 @@ const toCustomerAddressEdit = (addressId) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="full-width flex justify-center">
|
<FetchData
|
||||||
<QCard class="card-width q-pa-lg">
|
@on-fetch="sortAddresses"
|
||||||
<VnPaginate
|
|
||||||
@on-fetch="onFetch"
|
|
||||||
auto-load
|
auto-load
|
||||||
data-key="CustomerAddresses"
|
data-key="CustomerAddresses"
|
||||||
order="id DESC"
|
order="id DESC"
|
||||||
ref="vnPaginateRef"
|
ref="vnPaginateRef"
|
||||||
:filter="addressFilter"
|
:filter="addressFilter"
|
||||||
:url="`Clients/${route.params.id}/addresses`"
|
:url="`Clients/${route.params.id}/addresses`"
|
||||||
></VnPaginate>
|
/>
|
||||||
|
<div class="full-width flex justify-center">
|
||||||
|
<QCard class="card-width q-pa-lg">
|
||||||
<QCardSection>
|
<QCardSection>
|
||||||
<div
|
<div
|
||||||
v-for="(item, index) in addresses"
|
v-for="(item, index) in addresses"
|
||||||
|
|
Loading…
Reference in New Issue