0
0
Fork 0

Solucion a comentarios 21

This commit is contained in:
carlosfonseca 2024-02-25 22:28:56 -05:00
parent 90ee50eab5
commit b12968f982
5 changed files with 71 additions and 32 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref } 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';
@ -47,9 +47,39 @@ const addressFilter = {
], ],
}; };
const setRows = (data) => { onBeforeMount(() => {
const { id } = route.params;
getAddressesData(id);
getClientData(id);
});
watch(
() => route.params.id,
(newValue) => {
getAddressesData(newValue);
getClientData(newValue);
}
);
const getAddressesData = async (id) => {
try {
const { data } = await axios.get(`Clients/${id}/addresses`, {
params: { filter: JSON.stringify(addressFilter) },
});
addresses.value = data; addresses.value = data;
sortAddresses(); sortAddresses();
} catch (error) {
return error;
}
};
const getClientData = async (id) => {
try {
const { data } = await axios.get(`Clients/${id}`);
client.value = data;
} catch (error) {
return error;
}
}; };
const setProvince = (provinceFk) => { const setProvince = (provinceFk) => {
@ -97,17 +127,6 @@ const toCustomerAddressEdit = (addressId) => {
</script> </script>
<template> <template>
<FetchData
@on-fetch="setRows"
auto-load
:filter="addressFilter"
:url="`Clients/${route.params.id}/addresses`"
/>
<FetchData
@on-fetch="(data) => (client = data)"
auto-load
:url="`Clients/${route.params.id}`"
/>
<FetchData <FetchData
@on-fetch="(data) => (provincesLocation = data)" @on-fetch="(data) => (provincesLocation = data)"
auto-load auto-load

View File

@ -72,11 +72,11 @@ const filterOptions = {
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">
<div class="col"> <div class="col">
<VnInput <VnInput
:label="t('customer.basicData.socialName')" :label="t('Comercial name')"
:rules="validate('client.socialName')" :rules="validate('client.socialName')"
autofocus autofocus
clearable clearable
v-model="data.socialName" v-model="data.name"
/> />
</div> </div>
<div class="col"> <div class="col">
@ -210,4 +210,5 @@ const filterOptions = {
<i18n> <i18n>
es: es:
In case of a company succession, specify the grantor company: En el caso de que haya habido una sucesión de empresa, indicar la empresa cedente In case of a company succession, specify the grantor company: En el caso de que haya habido una sucesión de empresa, indicar la empresa cedente
Comercial name: Nombre comercial
</i18n> </i18n>

View File

@ -24,8 +24,9 @@ const filter = {
limit: 30, limit: 30,
}; };
const getBankEntities = () => { const getBankEntities = (data, formData) => {
bankEntitiesRef.value.fetch(); bankEntitiesRef.value.fetch();
formData.bankEntityFk = Number(data.id);
}; };
</script> </script>
@ -89,7 +90,9 @@ const getBankEntities = () => {
v-model="data.bankEntityFk" v-model="data.bankEntityFk"
> >
<template #form> <template #form>
<CreateBankEntityForm @on-data-saved="getBankEntities()" /> <CreateBankEntityForm
@on-data-saved="getBankEntities($event, data)"
/>
</template> </template>
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">

View File

@ -1,8 +1,10 @@
<script setup> <script setup>
import { computed, ref } from 'vue'; import { computed, onBeforeMount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import axios from 'axios';
import { toCurrency, toDateHourMinSec } from 'src/filters'; import { toCurrency, toDateHourMinSec } from 'src/filters';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
@ -12,7 +14,6 @@ import CustomerCheckIconTooltip from '../components/CustomerCheckIconTooltip.vue
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const clientsTransactionsRef = ref(null);
const rows = ref([]); const rows = ref([]);
const filter = { const filter = {
@ -20,7 +21,7 @@ const filter = {
{ relation: 'mandateType', scope: { fields: ['id', 'name'] } }, { relation: 'mandateType', scope: { fields: ['id', 'name'] } },
{ relation: 'company', scope: { fields: ['id', 'code'] } }, { relation: 'company', scope: { fields: ['id', 'code'] } },
], ],
where: { clientFk: route.params.id }, where: { clientFk: null },
order: ['created DESC'], order: ['created DESC'],
limit: 20, limit: 20,
}; };
@ -90,20 +91,35 @@ const columns = computed(() => [
}, },
]); ]);
onBeforeMount(() => {
getData(route.params.id);
});
watch(
() => route.params.id,
(newValue) => {
getData(newValue);
}
);
const getData = async (id) => {
filter.where.clientFk = id;
try {
const { data } = await axios.get('clients/transactions', {
params: { filter: JSON.stringify(filter) },
});
rows.value = data;
} catch (error) {
return error;
}
};
const refreshData = () => { const refreshData = () => {
clientsTransactionsRef.value.fetch(); getData(route.params.id);
}; };
</script> </script>
<template> <template>
<FetchData
:filter="filter"
@on-fetch="(data) => (rows = data)"
auto-load
ref="clientsTransactionsRef"
url="clients/transactions"
/>
<div class="full-width flex justify-center"> <div class="full-width flex justify-center">
<QPage class="card-width q-pa-lg"> <QPage class="card-width q-pa-lg">
<QTable <QTable

View File

@ -101,7 +101,7 @@ const setData = (entity) => {
</template> </template>
<template #body="{ entity }"> <template #body="{ entity }">
<VnLv :label="t('worker.card.name')" :value="entity.user?.nickname" /> <VnLv :label="t('worker.card.name')" :value="entity.user?.nickname" />
<VnLv :label="t('worker.card.emailxxx')" :value="entity.user?.email" copy /> <VnLv :label="t('worker.card.email')" :value="entity.user?.email" copy />
<VnLv <VnLv
:label="t('worker.list.department')" :label="t('worker.list.department')"
:value="entity.department ? entity.department.department.name : null" :value="entity.department ? entity.department.department.name : null"