fix: init fix
This commit is contained in:
parent
ad64c4ea0c
commit
229130409a
|
@ -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,28 @@ 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);
|
||||
_date.setHours(0, 0, 0, 0);
|
||||
params.from = new Date(
|
||||
new Date(dated).setDate(_date.getDate() - previousDays)
|
||||
).toISOString();
|
||||
_date.setHours(23, 59, 59, 59);
|
||||
params.to = new Date(
|
||||
new Date(dated).setDate(_date.getDate() + scopeDays)
|
||||
).toISOString();
|
||||
return params;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -144,7 +160,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 +216,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