updated DateRangePicker for Meter reports in Web UI

pull/129/head
13621160019@163.com 2022-02-27 16:32:19 +08:00
parent afc36b98ea
commit ee2968be65
12 changed files with 104 additions and 27 deletions

View File

@ -24,6 +24,7 @@ import { toast } from 'react-toastify';
import ButtonIcon from '../../common/ButtonIcon';
import { APIBaseURL } from '../../../config';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -134,6 +135,10 @@ const MeterBatch = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
}
};

View File

@ -30,6 +30,7 @@ import { APIBaseURL } from '../../../config';
import { periodTypeOptions } from '../common/PeriodTypeOptions';
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -260,11 +261,13 @@ const MeterCarbon = ({ setRedirect, setRedirectUrl, t }) => {
};
let onBasePeriodChange = (DateRange) => {
console.log(DateRange);
if(DateRange == null) {
setBasePeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setBasePeriodDateRange([DateRange[0], DateRange[1]]);
}
};
@ -273,6 +276,10 @@ const MeterCarbon = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'years').toDate(), moment(DateRange[1]).clone().subtract(1, 'years').toDate()]);

View File

@ -30,6 +30,7 @@ import { APIBaseURL } from '../../../config';
import { periodTypeOptions } from '../common/PeriodTypeOptions';
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -260,11 +261,13 @@ const MeterCost = ({ setRedirect, setRedirectUrl, t }) => {
};
let onBasePeriodChange = (DateRange) => {
console.log(DateRange);
if(DateRange == null) {
setBasePeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setBasePeriodDateRange([DateRange[0], DateRange[1]]);
}
};
@ -273,6 +276,10 @@ const MeterCost = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'years').toDate(), moment(DateRange[1]).clone().subtract(1, 'years').toDate()]);

View File

@ -30,6 +30,7 @@ import { APIBaseURL } from '../../../config';
import { periodTypeOptions } from '../common/PeriodTypeOptions';
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
import { DateRangePicker } from 'rsuite';
import { startOfDay, endOfDay, addDays, subDays } from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -263,11 +264,13 @@ const MeterEnergy = ({ setRedirect, setRedirectUrl, t }) => {
// Callback fired when value changed
let onBasePeriodChange = (DateRange) => {
console.log(DateRange);
if(DateRange == null) {
setBasePeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setBasePeriodDateRange([DateRange[0], DateRange[1]]);
}
};
@ -277,6 +280,10 @@ const MeterEnergy = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'years').toDate(), moment(DateRange[1]).clone().subtract(1, 'years').toDate()]);
@ -296,6 +303,7 @@ const MeterEnergy = ({ setRedirect, setRedirectUrl, t }) => {
setReportingPeriodDateRange([null, null]);
};
// Handler
const handleSubmit = e => {
e.preventDefault();

View File

@ -29,6 +29,7 @@ import ButtonIcon from '../../common/ButtonIcon';
import { APIBaseURL } from '../../../config';
import { periodTypeOptions } from '../common/PeriodTypeOptions';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -241,6 +242,10 @@ const MeterSubmetersBalance = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
}
};

View File

@ -32,6 +32,7 @@ import { toast } from 'react-toastify';
import ButtonIcon from '../../common/ButtonIcon';
import { APIBaseURL } from '../../../config';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const MeterTracking = ({ setRedirect, setRedirectUrl, t }) => {
@ -226,6 +227,10 @@ const MeterTracking = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
}
};

View File

@ -26,6 +26,7 @@ import { toast } from 'react-toastify';
import ButtonIcon from '../../common/ButtonIcon';
import { APIBaseURL } from '../../../config';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -231,6 +232,10 @@ const MeterTrend = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
}
};

View File

@ -30,6 +30,7 @@ import { APIBaseURL } from '../../../config';
import { periodTypeOptions } from '../common/PeriodTypeOptions';
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -242,11 +243,13 @@ const OfflineMeterCost = ({ setRedirect, setRedirectUrl, t }) => {
};
let onBasePeriodChange = (DateRange) => {
console.log(DateRange);
if(DateRange == null) {
setBasePeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setBasePeriodDateRange([DateRange[0], DateRange[1]]);
}
};
@ -255,6 +258,10 @@ const OfflineMeterCost = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'years').toDate(), moment(DateRange[1]).clone().subtract(1, 'years').toDate()]);

View File

@ -30,6 +30,7 @@ import { APIBaseURL } from '../../../config';
import { periodTypeOptions } from '../common/PeriodTypeOptions';
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -242,11 +243,13 @@ const OfflineMeterEnergy = ({ setRedirect, setRedirectUrl, t }) => {
};
let onBasePeriodChange = (DateRange) => {
console.log(DateRange);
if(DateRange == null) {
setBasePeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setBasePeriodDateRange([DateRange[0], DateRange[1]]);
}
};
@ -255,6 +258,10 @@ const OfflineMeterEnergy = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'years').toDate(), moment(DateRange[1]).clone().subtract(1, 'years').toDate()]);

View File

@ -30,6 +30,7 @@ import { APIBaseURL } from '../../../config';
import { periodTypeOptions } from '../common/PeriodTypeOptions';
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -240,11 +241,13 @@ const VirtualMeterCarbon = ({ setRedirect, setRedirectUrl, t }) => {
};
let onBasePeriodChange = (DateRange) => {
console.log(DateRange);
if(DateRange == null) {
setBasePeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setBasePeriodDateRange([DateRange[0], DateRange[1]]);
}
};
@ -253,6 +256,10 @@ const VirtualMeterCarbon = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'years').toDate(), moment(DateRange[1]).clone().subtract(1, 'years').toDate()]);

View File

@ -30,6 +30,7 @@ import { APIBaseURL } from '../../../config';
import { periodTypeOptions } from '../common/PeriodTypeOptions';
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -242,11 +243,13 @@ const VirtualMeterCost = ({ setRedirect, setRedirectUrl, t }) => {
};
let onBasePeriodChange = (DateRange) => {
console.log(DateRange);
if(DateRange == null) {
setBasePeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setBasePeriodDateRange([DateRange[0], DateRange[1]]);
}
};
@ -255,6 +258,10 @@ const VirtualMeterCost = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'years').toDate(), moment(DateRange[1]).clone().subtract(1, 'years').toDate()]);

View File

@ -30,6 +30,7 @@ import { APIBaseURL } from '../../../config';
import { periodTypeOptions } from '../common/PeriodTypeOptions';
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
import { DateRangePicker } from 'rsuite';
import { endOfDay} from 'date-fns';
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
@ -242,11 +243,13 @@ const VirtualMeterEnergy = ({ setRedirect, setRedirectUrl, t }) => {
};
let onBasePeriodChange = (DateRange) => {
console.log(DateRange);
if(DateRange == null) {
setBasePeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setBasePeriodDateRange([DateRange[0], DateRange[1]]);
}
};
@ -255,6 +258,10 @@ const VirtualMeterEnergy = ({ setRedirect, setRedirectUrl, t }) => {
if(DateRange == null) {
setReportingPeriodDateRange([null, null]);
} else {
if (moment(DateRange[1]).format('HH:mm:ss') == '00:00:00') {
// if the user did not change time value, set the default time to the end of day
DateRange[1] = endOfDay(DateRange[1]);
}
setReportingPeriodDateRange([DateRange[0], DateRange[1]]);
if (comparisonType === 'year-over-year') {
setBasePeriodDateRange([moment(DateRange[0]).clone().subtract(1, 'years').toDate(), moment(DateRange[1]).clone().subtract(1, 'years').toDate()]);