0
0
Fork 0

fix: refs #8114 fix agencyList

This commit is contained in:
Carlos Satorres 2024-12-02 13:25:07 +01:00
parent aaeabefdfe
commit 48482efe3b
1 changed files with 12 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<script setup>
import axios from 'axios';
import { useI18n } from 'vue-i18n';
import { computed, ref } from 'vue';
import { computed, ref, onMounted } from 'vue';
import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
import OrderSummary from 'pages/Order/Card/OrderSummary.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
@ -14,11 +14,13 @@ import OrderFilter from './Card/OrderFilter.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue';
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
import { toDateTimeFormat } from 'src/filters/date';
import { useRoute } from 'vue-router';
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
const tableRef = ref();
const agencyList = ref([]);
const route = useRoute();
const addressOptions = ref([]);
const columns = computed(() => [
{
@ -145,11 +147,12 @@ async function fetchClientAddress(id, formData = {}) {
`Clients/${id}/addresses?filter[order]=isActive DESC`
);
addressOptions.value = data;
console.log('formData', formData);
formData.addressId = data.defaultAddressFk;
fetchAgencies(formData);
}
async function fetchAgencies({ landed, addressId }) {
console.log('addressId', addressId);
if (!landed || !addressId) return (agencyList.value = []);
const { data } = await axios.get('Agencies/landsThatDay', {
@ -167,6 +170,12 @@ 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);
});
</script>
<template>
<OrderSearchbar />
@ -243,6 +252,7 @@ const getDateColor = (date) => {
:label="t('module.address')"
option-value="id"
option-label="nickname"
@update:model-value="() => fetchAgencies(data)"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">