diff --git a/src/pages/Customer/Defaulter/CustomerDefaulter.vue b/src/pages/Customer/Defaulter/CustomerDefaulter.vue index d54d5df35..bf7480985 100644 --- a/src/pages/Customer/Defaulter/CustomerDefaulter.vue +++ b/src/pages/Customer/Defaulter/CustomerDefaulter.vue @@ -2,7 +2,7 @@ import { ref, computed, onBeforeMount } from 'vue'; import { useI18n } from 'vue-i18n'; -import { QBtn, QCheckbox } from 'quasar'; +import { QBtn, QCheckbox, useQuasar } from 'quasar'; import { toCurrency, toDate } from 'filters/index'; import { useArrayData } from 'composables/useArrayData'; @@ -12,34 +12,19 @@ import CustomerNotificationsFilter from './CustomerDefaulterFilter.vue'; import CustomerBalanceDueTotal from './CustomerBalanceDueTotal.vue'; import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; +import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue'; const { t } = useI18n(); const stateStore = useStateStore(); +const quasar = useQuasar(); const arrayData = ref(null); const balanceDueTotal = ref(0); - -onBeforeMount(async () => { - arrayData.value = useArrayData('CustomerDefaulter', { - url: 'Defaulters/filter', - limit: 0, - }); - await arrayData.value.fetch({ append: false }); - balanceDueTotal.value = arrayData.value.store.data.reduce( - (accumulator, currentValue) => { - return accumulator + (currentValue['amount'] || 0); - }, - 0 - ); - console.log(balanceDueTotal.value); - stateStore.rightDrawer = true; -}); - -const rows = computed(() => arrayData.value.store.data); - +const customerId = ref(0); const selected = ref([]); const workerId = ref(0); -const customerId = ref(0); + +const rows = computed(() => arrayData.value.store.data); const tableColumnComponents = { client: { @@ -49,11 +34,10 @@ const tableColumnComponents = { }, isWorker: { component: QCheckbox, - props: ({ value }) => ({ + props: ({ row }) => ({ disable: true, - 'model-value': Boolean(value), + 'model-value': Boolean(row.selected), }), - event: () => {}, }, salesperson: { component: QBtn, @@ -171,6 +155,25 @@ const columns = computed(() => [ }, ]); +onBeforeMount(() => { + getArrayData(); +}); + +const getArrayData = async () => { + arrayData.value = useArrayData('CustomerDefaulter', { + url: 'Defaulters/filter', + limit: 0, + }); + await arrayData.value.fetch({ append: false }); + balanceDueTotal.value = arrayData.value.store.data.reduce( + (accumulator, currentValue) => { + return accumulator + (currentValue['amount'] || 0); + }, + 0 + ); + stateStore.rightDrawer = true; +}; + const selectCustomerId = (id) => { workerId.value = 0; customerId.value = id; @@ -180,6 +183,20 @@ const selectWorkerId = (id) => { customerId.value = 0; workerId.value = id; }; + +const viewAddObservation = (rowsSelected) => { + quasar.dialog({ + component: CustomerDefaulterAddObservation, + componentProps: { + clients: rowsSelected, + promise: refreshData, + }, + }); +}; + +const refreshData = () => { + getArrayData(); +};