Merge pull request 'hotfix: CustomerConsumption campaignFilter' (!1156) from hotfix_customerConsumption_campaignFilter into master
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
Reviewed-on: #1156 Reviewed-by: Pablo Natek <pablone@verdnatura.es>
This commit is contained in:
commit
d7bcc5b358
|
@ -2,7 +2,7 @@
|
||||||
import { ref, computed, onBeforeMount } from 'vue';
|
import { ref, computed, onBeforeMount } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { toDate } from 'src/filters/index';
|
import { dateRange, toDate } from 'src/filters/index';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
|
@ -104,18 +104,12 @@ function getParams() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const userParams = computed(() => {
|
const userParams = computed(() => {
|
||||||
const minDate = Date.vnNew();
|
const campaign = campaignList.value[0]?.id;
|
||||||
minDate.setHours(0, 0, 0, 0);
|
const userParams = {
|
||||||
minDate.setMonth(minDate.getMonth() - 2);
|
campaign,
|
||||||
|
...updateDateParams(campaign, { from: Date.vnNew(), to: Date.vnNew() }),
|
||||||
const maxDate = Date.vnNew();
|
|
||||||
maxDate.setHours(23, 59, 59, 59);
|
|
||||||
|
|
||||||
return {
|
|
||||||
campaign: campaignList.value[0]?.id,
|
|
||||||
from: minDate,
|
|
||||||
to: maxDate,
|
|
||||||
};
|
};
|
||||||
|
return userParams;
|
||||||
});
|
});
|
||||||
const openReportPdf = () => {
|
const openReportPdf = () => {
|
||||||
openReport(`Clients/${route.params.id}/campaign-metrics-pdf`, getParams());
|
openReport(`Clients/${route.params.id}/campaign-metrics-pdf`, getParams());
|
||||||
|
@ -134,6 +128,23 @@ const sendCampaignMetricsEmail = ({ address }) => {
|
||||||
...getParams(),
|
...getParams(),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateDateParams = (value, params) => {
|
||||||
|
if (!value) {
|
||||||
|
params.from = null;
|
||||||
|
params.to = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const campaign = campaignList.value.find((c) => c.id === value);
|
||||||
|
if (!campaign) return;
|
||||||
|
|
||||||
|
const { dated, previousDays, scopeDays } = campaign;
|
||||||
|
const _date = new Date(dated);
|
||||||
|
const [from, to] = dateRange(_date);
|
||||||
|
params.from = new Date(from.setDate(from.getDate() - previousDays)).toISOString();
|
||||||
|
params.to = new Date(to.setDate(to.getDate() + scopeDays)).toISOString();
|
||||||
|
return params;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -144,7 +155,6 @@ const sendCampaignMetricsEmail = ({ address }) => {
|
||||||
:order="['itemTypeFk', 'itemName', 'itemSize', 'description']"
|
:order="['itemTypeFk', 'itemName', 'itemSize', 'description']"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
search-url="consumption"
|
search-url="consumption"
|
||||||
:filter="filter"
|
|
||||||
:user-params="userParams"
|
:user-params="userParams"
|
||||||
:default-remove="false"
|
:default-remove="false"
|
||||||
:default-reset="false"
|
:default-reset="false"
|
||||||
|
@ -201,6 +211,7 @@ const sendCampaignMetricsEmail = ({ address }) => {
|
||||||
class="q-px-sm q-pt-none fit"
|
class="q-px-sm q-pt-none fit"
|
||||||
dense
|
dense
|
||||||
option-label="code"
|
option-label="code"
|
||||||
|
@update:model-value="(data) => updateDateParams(data, params)"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem v-bind="scope.itemProps">
|
||||||
|
|
Loading…
Reference in New Issue