forked from verdnatura/salix-front
refactor: refs #6652 improved defaulter section
This commit is contained in:
parent
a8fef3fa84
commit
2af4df8ded
|
@ -1,7 +1,7 @@
|
||||||
export default function dateRange(value) {
|
export default function dateRange(value) {
|
||||||
const minHour = new Date(value);
|
const minHour = new Date(value);
|
||||||
minHour.setHours(0, 0, 0, 0);
|
minHour.setHours(0, 0, 0, 0);
|
||||||
const maxHour = new Date(value);
|
const maxHour = new Date();
|
||||||
maxHour.setHours(23, 59, 59, 59);
|
maxHour.setHours(23, 59, 59, 59);
|
||||||
|
|
||||||
return [minHour, maxHour];
|
return [minHour, maxHour];
|
||||||
|
|
|
@ -14,9 +14,10 @@ import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.v
|
||||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue';
|
import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue';
|
||||||
|
import axios from 'axios';
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
const { t } = useI18n();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const dataRef = ref(null);
|
const dataRef = ref(null);
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ const selected = ref([]);
|
||||||
const tableColumnComponents = {
|
const tableColumnComponents = {
|
||||||
client: {
|
client: {
|
||||||
component: QBtn,
|
component: QBtn,
|
||||||
props: () => ({ flat: true, color: 'blue', noCaps: true }),
|
props: () => ({ flat: true, class: 'link', noCaps: true }),
|
||||||
event: () => {},
|
event: () => {},
|
||||||
},
|
},
|
||||||
isWorker: {
|
isWorker: {
|
||||||
|
@ -39,7 +40,12 @@ const tableColumnComponents = {
|
||||||
},
|
},
|
||||||
salesPerson: {
|
salesPerson: {
|
||||||
component: QBtn,
|
component: QBtn,
|
||||||
props: () => ({ flat: true, color: 'blue', noCaps: true }),
|
props: () => ({ flat: true, class: 'link', noCaps: true }),
|
||||||
|
event: () => {},
|
||||||
|
},
|
||||||
|
department: {
|
||||||
|
component: 'span',
|
||||||
|
props: () => {},
|
||||||
event: () => {},
|
event: () => {},
|
||||||
},
|
},
|
||||||
country: {
|
country: {
|
||||||
|
@ -59,7 +65,7 @@ const tableColumnComponents = {
|
||||||
},
|
},
|
||||||
author: {
|
author: {
|
||||||
component: QBtn,
|
component: QBtn,
|
||||||
props: () => ({ flat: true, color: 'blue', noCaps: true }),
|
props: () => ({ flat: true, class: 'link', noCaps: true }),
|
||||||
event: () => {},
|
event: () => {},
|
||||||
},
|
},
|
||||||
lastObservation: {
|
lastObservation: {
|
||||||
|
@ -82,6 +88,16 @@ const tableColumnComponents = {
|
||||||
props: () => {},
|
props: () => {},
|
||||||
event: () => {},
|
event: () => {},
|
||||||
},
|
},
|
||||||
|
finished: {
|
||||||
|
component: QCheckbox,
|
||||||
|
|
||||||
|
props: (prop) => ({
|
||||||
|
disable: true,
|
||||||
|
'model-value': prop.value,
|
||||||
|
class: 'disabled-checkbox',
|
||||||
|
}),
|
||||||
|
event: () => {},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
|
@ -105,6 +121,13 @@ const columns = computed(() => [
|
||||||
name: 'salesPerson',
|
name: 'salesPerson',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
field: 'departmentName',
|
||||||
|
label: t('Department'),
|
||||||
|
name: 'department',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
field: 'country',
|
field: 'country',
|
||||||
|
@ -166,6 +189,12 @@ const columns = computed(() => [
|
||||||
name: 'from',
|
name: 'from',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
field: 'finished',
|
||||||
|
label: t('Has recover'),
|
||||||
|
name: 'finished',
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const viewAddObservation = (rowsSelected) => {
|
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';
|
for (const element of data) element.isWorker = element.businessTypeFk === 'worker';
|
||||||
|
|
||||||
balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0);
|
balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0);
|
||||||
|
@ -191,6 +252,7 @@ function exprBuilder(param, value) {
|
||||||
case 'creditInsurance':
|
case 'creditInsurance':
|
||||||
case 'amount':
|
case 'amount':
|
||||||
case 'workerFk':
|
case 'workerFk':
|
||||||
|
case 'departmentFk':
|
||||||
case 'countryFk':
|
case 'countryFk':
|
||||||
case 'payMethod':
|
case 'payMethod':
|
||||||
case 'salesPersonFk':
|
case 'salesPersonFk':
|
||||||
|
@ -243,7 +305,6 @@ function exprBuilder(param, value) {
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</VnSubToolbar>
|
</VnSubToolbar>
|
||||||
|
|
||||||
<QPage class="column items-center q-pa-md">
|
<QPage class="column items-center q-pa-md">
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
ref="dataRef"
|
ref="dataRef"
|
||||||
|
@ -302,7 +363,7 @@ function exprBuilder(param, value) {
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<template v-if="props.col.name !== 'isWorker'">
|
<template v-if="typeof props.value !== 'boolean'">
|
||||||
<div
|
<div
|
||||||
v-if="
|
v-if="
|
||||||
props.col.name === 'lastObservation'
|
props.col.name === 'lastObservation'
|
||||||
|
@ -354,6 +415,7 @@ es:
|
||||||
Client: Cliente
|
Client: Cliente
|
||||||
Is worker: Es trabajador
|
Is worker: Es trabajador
|
||||||
Salesperson: Comercial
|
Salesperson: Comercial
|
||||||
|
Department: Departamento
|
||||||
Country: País
|
Country: País
|
||||||
P. Method: F. Pago
|
P. Method: F. Pago
|
||||||
Pay method: Forma de pago
|
Pay method: Forma de pago
|
||||||
|
|
|
@ -45,11 +45,10 @@ const authors = ref();
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #body="{ params }">
|
<template #body="{ params, searchFn }">
|
||||||
<QItem class="q-mb-sm q-mt-sm">
|
<QItem class="q-mb-sm">
|
||||||
<QItemSection v-if="clients">
|
<QItemSection v-if="clients">
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:input-debounce="0"
|
|
||||||
:label="t('Client')"
|
:label="t('Client')"
|
||||||
:options="clients"
|
:options="clients"
|
||||||
dense
|
dense
|
||||||
|
@ -62,6 +61,8 @@ const authors = ref();
|
||||||
rounded
|
rounded
|
||||||
use-input
|
use-input
|
||||||
v-model="params.clientFk"
|
v-model="params.clientFk"
|
||||||
|
@update:model-value="searchFn()"
|
||||||
|
auto-load
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection v-else>
|
<QItemSection v-else>
|
||||||
|
@ -85,6 +86,7 @@ const authors = ref();
|
||||||
rounded
|
rounded
|
||||||
use-input
|
use-input
|
||||||
v-model="params.salesPersonFk"
|
v-model="params.salesPersonFk"
|
||||||
|
@update:model-value="searchFn()"
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection v-else>
|
<QItemSection v-else>
|
||||||
|
@ -108,6 +110,7 @@ const authors = ref();
|
||||||
rounded
|
rounded
|
||||||
use-input
|
use-input
|
||||||
v-model="params.countryFk"
|
v-model="params.countryFk"
|
||||||
|
@update:model-value="searchFn()"
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection v-else>
|
<QItemSection v-else>
|
||||||
|
@ -153,6 +156,7 @@ const authors = ref();
|
||||||
rounded
|
rounded
|
||||||
use-input
|
use-input
|
||||||
v-model="params.workerFk"
|
v-model="params.workerFk"
|
||||||
|
@update:model-value="searchFn()"
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection v-else>
|
<QItemSection v-else>
|
||||||
|
|
Loading…
Reference in New Issue