diff --git a/src/pages/Customer/Defaulter/CustomerDefaulter.vue b/src/pages/Customer/Defaulter/CustomerDefaulter.vue index af7ce0a26..06732b944 100644 --- a/src/pages/Customer/Defaulter/CustomerDefaulter.vue +++ b/src/pages/Customer/Defaulter/CustomerDefaulter.vue @@ -22,7 +22,7 @@ const balanceDueTotal = ref(0); const selected = ref([]); const tableColumnComponents = { - client: { + clientFk: { component: QBtn, props: () => ({ flat: true, class: 'link', noCaps: true }), event: () => {}, @@ -40,7 +40,7 @@ const tableColumnComponents = { props: () => ({ flat: true, class: 'link', noCaps: true }), event: () => {}, }, - department: { + departmentName: { component: 'span', props: () => {}, event: () => {}, @@ -102,12 +102,12 @@ const columns = computed(() => [ align: 'left', field: 'clientName', label: t('Client'), - name: 'client', + name: 'clientFk', sortable: true, }, { align: 'left', - field: 'isWorker', + field: ({ isWorker }) => Boolean(isWorker), label: t('Is worker'), name: 'isWorker', }, @@ -122,7 +122,7 @@ const columns = computed(() => [ align: 'left', field: 'departmentName', label: t('Department'), - name: 'department', + name: 'departmentName', sortable: true, }, { @@ -204,48 +204,24 @@ const viewAddObservation = (rowsSelected) => { }); }; -const departments = ref(new Map()); - const onFetch = async (data) => { - const salesPersonFks = data.map((item) => item.salesPersonFk); - const departmentNames = salesPersonFks.map(async (salesPersonFk) => { - try { - const { data: workerDepartment } = await axios.get( - `WorkerDepartments/${salesPersonFk}` - ); - const { data: department } = await axios.get( - `Departments/${workerDepartment.departmentFk}` - ); - departments.value.set(salesPersonFk, department.name); - } catch (error) { - console.error('Err: ', error); - } - }); const recoveryData = await axios.get('Recoveries'); - const recoveries = recoveryData.data.map(({ clientFk, finished }) => ({ clientFk, finished, })); - await Promise.all(departmentNames); - data.forEach((item) => { - item.departmentName = departments.value.get(item.salesPersonFk); - item.isWorker = item.businessTypeFk === 'worker'; const recovery = recoveries.find(({ clientFk }) => clientFk === item.clientFk); item.finished = recovery?.finished === null; }); - - for (const element of data) element.isWorker = element.businessTypeFk === 'worker'; - balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0); }; function exprBuilder(param, value) { switch (param) { case 'clientFk': - return { [`d.${param}`]: value?.id }; + return { [`d.${param}`]: value }; case 'creditInsurance': case 'amount': case 'workerFk': diff --git a/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue b/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue index 9220bd7c0..6b4d8baaa 100644 --- a/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue +++ b/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue @@ -1,7 +1,6 @@