diff --git a/src/pages/Order/OrderList.vue b/src/pages/Order/OrderList.vue index 1622f5ffe..9870be9b3 100644 --- a/src/pages/Order/OrderList.vue +++ b/src/pages/Order/OrderList.vue @@ -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; }