forked from verdnatura/salix-front
feat(orderList): correct create order
This commit is contained in:
parent
ee71ae9d24
commit
dc7c686508
|
@ -15,9 +15,9 @@ import OrderFilter from './Card/OrderFilter.vue';
|
|||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const tableRef = ref();
|
||||
const clientList = ref([]);
|
||||
const agencyList = ref([]);
|
||||
const selectedAddress = ref();
|
||||
const addressesList = ref([]);
|
||||
const clientId = ref();
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
|
@ -102,20 +102,19 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
name: 'agencyModeFk',
|
||||
label: t('module.agency'),
|
||||
component: 'select',
|
||||
cardVisible: true,
|
||||
attrs: {
|
||||
url: 'agencyModes',
|
||||
fields: ['id', 'name'],
|
||||
find: {
|
||||
value: 'agencyModeFk',
|
||||
label: 'agencyName',
|
||||
format: (row) => row?.agencyName,
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'agencyModes',
|
||||
fields: ['id', 'name'],
|
||||
find: {
|
||||
value: 'agencyModeFk',
|
||||
label: 'agencyName',
|
||||
},
|
||||
},
|
||||
},
|
||||
columnField: {
|
||||
component: null,
|
||||
},
|
||||
format: (row) => row?.agencyName,
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -138,10 +137,22 @@ const columns = computed(() => [
|
|||
},
|
||||
]);
|
||||
|
||||
async function fetchClientAddress(id, data) {
|
||||
const clientData = await axios.get(`Clients/${id}`);
|
||||
selectedAddress.value = clientData.data.defaultAddressFk;
|
||||
data.addressId = selectedAddress.value;
|
||||
async function fetchClientAddress(id, formData) {
|
||||
const { data } = await axios.get(`Clients/${id}`, {
|
||||
params: { filter: { include: { relation: 'addresses' } } },
|
||||
});
|
||||
addressesList.value = data.addresses;
|
||||
formData.addressId = data.defaultAddressFk;
|
||||
fetchAgencies(formData);
|
||||
}
|
||||
|
||||
async function fetchAgencies({ landed, addressId }) {
|
||||
if (!landed || !addressId) return (agencyList.value = []);
|
||||
|
||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||
params: { addressFk: addressId, landed },
|
||||
});
|
||||
agencyList.value = data;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
|
@ -175,29 +186,41 @@ async function fetchClientAddress(id, data) {
|
|||
<template #more-create-dialog="{ data }">
|
||||
<VnSelect
|
||||
url="Clients"
|
||||
v-model="data.id"
|
||||
:include="{ relation: 'addresses' }"
|
||||
v-model="clientId"
|
||||
:label="t('module.customer')"
|
||||
:options="clientList"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
@update:model-value="(id) => fetchClientAddress(id, data)"
|
||||
/>
|
||||
<VnSelect
|
||||
url="Clients"
|
||||
v-model="selectedAddress"
|
||||
v-model="data.addressId"
|
||||
:options="addressesList"
|
||||
:label="t('module.address')"
|
||||
:options="selectedAddress"
|
||||
option-value="defaultAddressFk"
|
||||
option-label="street"
|
||||
option-value="id"
|
||||
option-label="nickname"
|
||||
@update:model-value="() => fetchAgencies(data)"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>
|
||||
{{ scope.opt?.nickname }}: {{ scope.opt?.street }},
|
||||
{{ scope.opt?.city }}</QItemLabel
|
||||
>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
<VnInputDate
|
||||
v-model="data.landed"
|
||||
:label="t('module.landed')"
|
||||
@update:model-value="() => fetchAgencies(data)"
|
||||
/>
|
||||
<VnInputDate v-model="data.landed" :label="t('module.landed')" />
|
||||
<VnSelect
|
||||
url="Agencies"
|
||||
v-model="data.agencyModeId"
|
||||
:label="t('module.agency')"
|
||||
:options="agencyList"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
option-value="agencyModeFk"
|
||||
option-label="agencyMode"
|
||||
/>
|
||||
</template>
|
||||
</VnTable>
|
||||
|
|
Loading…
Reference in New Issue