7525-devToTest #419
|
@ -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];
|
||||
|
|
|
@ -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) {
|
|||
</div>
|
||||
</template>
|
||||
</VnSubToolbar>
|
||||
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<VnPaginate
|
||||
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
|
||||
v-if="
|
||||
props.col.name === 'lastObservation'
|
||||
|
@ -354,6 +415,7 @@ es:
|
|||
Client: Cliente
|
||||
Is worker: Es trabajador
|
||||
Salesperson: Comercial
|
||||
Department: Departamento
|
||||
Country: País
|
||||
P. Method: F. Pago
|
||||
Pay method: Forma de pago
|
||||
|
|
|
@ -45,11 +45,10 @@ const authors = ref();
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<template #body="{ params }">
|
||||
<QItem class="q-mb-sm q-mt-sm">
|
||||
<template #body="{ params, searchFn }">
|
||||
<QItem class="q-mb-sm">
|
||||
<QItemSection v-if="clients">
|
||||
<VnSelect
|
||||
:input-debounce="0"
|
||||
:label="t('Client')"
|
||||
:options="clients"
|
||||
dense
|
||||
|
@ -62,6 +61,8 @@ const authors = ref();
|
|||
rounded
|
||||
use-input
|
||||
v-model="params.clientFk"
|
||||
@update:model-value="searchFn()"
|
||||
auto-load
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection v-else>
|
||||
|
@ -85,6 +86,7 @@ const authors = ref();
|
|||
rounded
|
||||
use-input
|
||||
v-model="params.salesPersonFk"
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection v-else>
|
||||
|
@ -108,6 +110,7 @@ const authors = ref();
|
|||
rounded
|
||||
use-input
|
||||
v-model="params.countryFk"
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection v-else>
|
||||
|
@ -153,6 +156,7 @@ const authors = ref();
|
|||
rounded
|
||||
use-input
|
||||
v-model="params.workerFk"
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection v-else>
|
||||
|
|
Loading…
Reference in New Issue