forked from verdnatura/salix-front
fix: refs #7274 defaulterFilter
This commit is contained in:
parent
e4637b7d15
commit
9d9d3db43b
|
@ -5,7 +5,7 @@ import { useI18n } from 'vue-i18n';
|
|||
import { QBtn, QCheckbox, useQuasar } from 'quasar';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
|
||||
import { toCurrency, toDate } from 'filters/index';
|
||||
import { toCurrency, toDate, dateRange } from 'filters/index';
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import CustomerNotificationsFilter from './CustomerDefaulterFilter.vue';
|
||||
import CustomerBalanceDueTotal from './CustomerBalanceDueTotal.vue';
|
||||
|
@ -16,7 +16,7 @@ import VnInput from 'src/components/common/VnInput.vue';
|
|||
import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue';
|
||||
const stateStore = useStateStore();
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t, locale } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const dataRef = ref(null);
|
||||
|
||||
|
@ -183,6 +183,34 @@ const onFetch = (data) => {
|
|||
|
||||
balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0);
|
||||
};
|
||||
|
||||
function getRange(value) {
|
||||
let date;
|
||||
if (locale.value === 'es') {
|
||||
const [day, month, year] = value.split('/');
|
||||
date = new Date(year, month - 1, day);
|
||||
} else date = new Date(value);
|
||||
|
||||
return dateRange(date);
|
||||
}
|
||||
|
||||
function exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'clientFk':
|
||||
return { [`d.${param}`]: value?.id };
|
||||
case 'creditInsurance':
|
||||
case 'amount':
|
||||
case 'workerFk':
|
||||
case 'countryFk':
|
||||
case 'payMethod':
|
||||
case 'salesPersonFk':
|
||||
return { [`d.${param}`]: value };
|
||||
case 'date':
|
||||
return { 'd.created': { between: getRange(value) } };
|
||||
case 'defaulterSinced':
|
||||
return { 'd.defaulterSinced': { between: getRange(value) } };
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -232,6 +260,7 @@ const onFetch = (data) => {
|
|||
@on-fetch="onFetch"
|
||||
data-key="CustomerDefaulter"
|
||||
:filter="filter"
|
||||
:expr-builder="exprBuilder"
|
||||
auto-load
|
||||
url="Defaulters/filter"
|
||||
>
|
||||
|
|
|
@ -57,7 +57,7 @@ const authors = ref();
|
|||
hide-selected
|
||||
map-options
|
||||
option-label="name"
|
||||
option-value="clientTypeFk"
|
||||
option-value="id"
|
||||
outlined
|
||||
rounded
|
||||
use-input
|
||||
|
|
Loading…
Reference in New Issue