diff --git a/src/components/common/VnDmsList.vue b/src/components/common/VnDmsList.vue index e3cb2874a..769ba9959 100644 --- a/src/components/common/VnDmsList.vue +++ b/src/components/common/VnDmsList.vue @@ -35,7 +35,7 @@ const $props = defineProps({ downloadModel: { type: String, required: false, - default: null, + default: undefined, }, defaultDmsCode: { type: String, diff --git a/src/filters/dateRange.js b/src/filters/dateRange.js index 4c0cfe654..7aa2869e5 100644 --- a/src/filters/dateRange.js +++ b/src/filters/dateRange.js @@ -1,7 +1,7 @@ export default function dateRange(value) { const minHour = new Date(value); minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); + const maxHour = new Date(); maxHour.setHours(23, 59, 59, 59); return [minHour, maxHour]; diff --git a/src/pages/Customer/Defaulter/CustomerDefaulter.vue b/src/pages/Customer/Defaulter/CustomerDefaulter.vue index c1e537c0a..5ed6af1a9 100644 --- a/src/pages/Customer/Defaulter/CustomerDefaulter.vue +++ b/src/pages/Customer/Defaulter/CustomerDefaulter.vue @@ -14,9 +14,10 @@ import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.v import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnInput from 'src/components/common/VnInput.vue'; import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue'; +import axios from 'axios'; const stateStore = useStateStore(); -const { t, locale } = useI18n(); +const { t } = useI18n(); const quasar = useQuasar(); const dataRef = ref(null); @@ -26,7 +27,7 @@ const selected = ref([]); const tableColumnComponents = { client: { component: QBtn, - props: () => ({ flat: true, color: 'blue', noCaps: true }), + props: () => ({ flat: true, class: 'link', noCaps: true }), event: () => {}, }, isWorker: { @@ -39,7 +40,12 @@ const tableColumnComponents = { }, salesPerson: { component: QBtn, - props: () => ({ flat: true, color: 'blue', noCaps: true }), + props: () => ({ flat: true, class: 'link', noCaps: true }), + event: () => {}, + }, + department: { + component: 'span', + props: () => {}, event: () => {}, }, country: { @@ -59,7 +65,7 @@ const tableColumnComponents = { }, author: { component: QBtn, - props: () => ({ flat: true, color: 'blue', noCaps: true }), + props: () => ({ flat: true, class: 'link', noCaps: true }), event: () => {}, }, lastObservation: { @@ -82,6 +88,16 @@ const tableColumnComponents = { props: () => {}, event: () => {}, }, + finished: { + component: QCheckbox, + + props: (prop) => ({ + disable: true, + 'model-value': prop.value, + class: 'disabled-checkbox', + }), + event: () => {}, + }, }; const columns = computed(() => [ @@ -105,6 +121,13 @@ const columns = computed(() => [ name: 'salesPerson', sortable: true, }, + { + align: 'left', + field: 'departmentName', + label: t('Department'), + name: 'department', + sortable: true, + }, { align: 'left', field: 'country', @@ -166,6 +189,12 @@ const columns = computed(() => [ name: 'from', sortable: true, }, + { + align: 'left', + field: 'finished', + label: t('Has recover'), + name: 'finished', + }, ]); const viewAddObservation = (rowsSelected) => { @@ -178,7 +207,39 @@ const viewAddObservation = (rowsSelected) => { }); }; -const onFetch = (data) => { +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); @@ -191,6 +252,7 @@ function exprBuilder(param, value) { case 'creditInsurance': case 'amount': case 'workerFk': + case 'departmentFk': case 'countryFk': case 'payMethod': case 'salesPersonFk': @@ -243,7 +305,6 @@ function exprBuilder(param, value) { - -