feat: #6943 OrderList

This commit is contained in:
Javier Segarra 2024-11-13 10:36:27 +01:00
parent 236df82c90
commit 0632b939a1
1 changed files with 18 additions and 14 deletions

View File

@ -141,11 +141,16 @@ const columns = computed(() => [
],
},
]);
const formInitialData = {
active: true,
addressId: null,
clientFk: null,
};
onMounted(() => {
if (!route.query.createForm) return;
const clientId = route.query.createForm;
const id = JSON.parse(clientId);
fetchClientAddress(id.clientFk, id);
fetchClientAddress(id.clientFk, formInitialData);
});
async function fetchClientAddress(id, formData) {
const { data } = await axios.get(`Clients/${id}`, {
@ -154,6 +159,7 @@ async function fetchClientAddress(id, formData) {
addressesList.value = data.addresses;
formData.addressId = data.defaultAddressFk;
fetchAgencies(formData);
return formData.addressId;
}
async function fetchAgencies({ landed, addressId }) {
@ -174,13 +180,6 @@ const getDateColor = (date) => {
if (comparation == 0) return 'bg-warning';
if (comparation < 0) return 'bg-success';
};
onMounted(() => {
if (!route.query.createForm) return;
const clientId = route.query.createForm;
const id = JSON.parse(clientId);
fetchClientAddress(id.clientFk, id);
});
</script>
<template>
<OrderSearchbar />
@ -189,6 +188,7 @@ onMounted(() => {
<OrderFilter data-key="OrderList" />
</template>
</RightMenu>
<VnTable
ref="tableRef"
data-key="OrderList"
@ -200,11 +200,7 @@ onMounted(() => {
onDataSaved: (url) => {
tableRef.redirect(url);
},
formInitialData: {
active: true,
addressId: null,
clientFk: null,
},
formInitialData,
}"
:user-params="{ showEmpty: false }"
:right-search="false"
@ -231,12 +227,20 @@ onMounted(() => {
</span>
</template>
<template #more-create-dialog="{ data }">
{{ formInitialData }}
{{ data }}
<VnSelect
url="Clients"
:include="{ relation: 'addresses' }"
v-model="data.clientFk"
:label="t('module.customer')"
@update:model-value="(id) => fetchClientAddress(id, data)"
@update:model-value="
(id) => {
const addressId = fetchClientAddress(id, data);
console.error('addressId', addressId);
data.addressId = addressId;
}
"
/>
<VnSelect
v-model="data.addressId"