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 axios from 'axios';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { toDate } from 'src/filters/index';
|
||||
import { dateRange, toDate } from 'src/filters/index';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
|
@ -104,18 +104,12 @@ function getParams() {
|
|||
};
|
||||
}
|
||||
const userParams = computed(() => {
|
||||
const minDate = Date.vnNew();
|
||||
minDate.setHours(0, 0, 0, 0);
|
||||
minDate.setMonth(minDate.getMonth() - 2);
|
||||
|
||||
const maxDate = Date.vnNew();
|
||||
maxDate.setHours(23, 59, 59, 59);
|
||||
|
||||
return {
|
||||
campaign: campaignList.value[0]?.id,
|
||||
from: minDate,
|
||||
to: maxDate,
|
||||
const campaign = campaignList.value[0]?.id;
|
||||
const userParams = {
|
||||
campaign,
|
||||
...updateDateParams(campaign, { from: Date.vnNew(), to: Date.vnNew() }),
|
||||
};
|
||||
return userParams;
|
||||
});
|
||||
const openReportPdf = () => {
|
||||
openReport(`Clients/${route.params.id}/campaign-metrics-pdf`, getParams());
|
||||
|
@ -134,6 +128,23 @@ const sendCampaignMetricsEmail = ({ address }) => {
|
|||
...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>
|
||||
|
||||
<template>
|
||||
|
@ -144,7 +155,6 @@ const sendCampaignMetricsEmail = ({ address }) => {
|
|||
:order="['itemTypeFk', 'itemName', 'itemSize', 'description']"
|
||||
:columns="columns"
|
||||
search-url="consumption"
|
||||
:filter="filter"
|
||||
:user-params="userParams"
|
||||
:default-remove="false"
|
||||
:default-reset="false"
|
||||
|
@ -201,6 +211,7 @@ const sendCampaignMetricsEmail = ({ address }) => {
|
|||
class="q-px-sm q-pt-none fit"
|
||||
dense
|
||||
option-label="code"
|
||||
@update:model-value="(data) => updateDateParams(data, params)"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
|
|
Loading…
Reference in New Issue