HOTFIX: #6943 CustomerList form salesPersons options #790

Closed
jsegarra wants to merge 84 commits from hotfix_newCustomer_SalesPerson into master
1 changed files with 18 additions and 14 deletions
Showing only changes of commit 0632b939a1 - Show all commits

View File

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