0
0
Fork 0

fix: refs #8114 orderList

This commit is contained in:
Carlos Satorres 2024-11-27 06:18:41 +01:00
parent 8688f2a3aa
commit 59648d14f0
2 changed files with 11 additions and 18 deletions

View File

@ -59,17 +59,17 @@ const initialFormState = reactive({
clientFk: $props.clientFk, clientFk: $props.clientFk,
}); });
const onClientChange = async (clientId = $props.clientFk) => { // const onClientChange = async (clientId = $props.clientFk) => {
const { data } = await axios.get(`Clients/${clientId}`); // const { data } = await axios.get(`Clients/${clientId}`);
await fetchAddressList(data.defaultAddressFk); // await fetchAddressList(data.defaultAddressFk);
}; // };
async function onDataSaved(_, id) { async function onDataSaved(_, id) {
await router.push({ path: `/order/${id}/catalog` }); await router.push({ path: `/order/${id}/catalog` });
} }
onMounted(async () => { // onMounted(async () => {
await onClientChange(); // await onClientChange();
}); // });
</script> </script>
<template> <template>
@ -90,10 +90,9 @@ onMounted(async () => {
option-value="id" option-value="id"
option-label="name" option-label="name"
:filter="{ :filter="{
fields: ['id', 'name', 'defaultAddressFk'], fields: ['id', 'name'],
}" }"
hide-selected hide-selected
@update:model-value="onClientChange"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
@ -110,7 +109,7 @@ onMounted(async () => {
:label="t('order.form.addressFk')" :label="t('order.form.addressFk')"
v-model="data.addressId" v-model="data.addressId"
url="addresses" url="addresses"
:fields="['id', 'nickname', 'defaultAddressFk', 'street', 'city']" :fields="['id', 'nickname', 'street', 'city']"
sort-by="id" sort-by="id"
option-value="id" option-value="id"
option-label="street" option-label="street"

View File

@ -141,12 +141,6 @@ const columns = computed(() => [
], ],
}, },
]); ]);
onMounted(() => {
if (!route.query.createForm) return;
const clientId = route.query.createForm;
const id = JSON.parse(clientId);
fetchClientAddress(id.clientFk);
});
async function fetchClientAddress(id, formData = {}) { async function fetchClientAddress(id, formData = {}) {
const { data } = await axios.get(`Clients/${id}`, { const { data } = await axios.get(`Clients/${id}`, {
params: { filter: { include: { relation: 'addresses' } } }, params: { filter: { include: { relation: 'addresses' } } },
@ -191,7 +185,7 @@ const getDateColor = (date) => {
urlCreate: 'Orders/new', urlCreate: 'Orders/new',
title: t('module.cerateOrder'), title: t('module.cerateOrder'),
onDataSaved: (url) => { onDataSaved: (url) => {
tableRef.redirect(`${url}/catalog`); tableRef.redirect(`${url}/catalog`);
}, },
formInitialData: { formInitialData: {
active: true, active: true,
@ -250,7 +244,7 @@ const getDateColor = (date) => {
:label="t('module.address')" :label="t('module.address')"
option-value="id" option-value="id"
option-label="nickname" option-label="nickname"
@update:model-value="() => fetchAgencies(data)" @update:model-value="() => fetchClientAddress(data)"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">