From 4d8a62c07261dfcf8c947de4735b36360883f945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Tue, 21 Sep 2021 10:35:34 +0500 Subject: [PATCH] fix report filter --- src/pages/Report/index.jsx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/pages/Report/index.jsx b/src/pages/Report/index.jsx index 577ebde..038aa9f 100644 --- a/src/pages/Report/index.jsx +++ b/src/pages/Report/index.jsx @@ -84,8 +84,8 @@ export default function Report({ idWell }) { ] const handleReportCreation = async (values) => { - let begin = aviableDateRange[0].toISOString() - let end = aviableDateRange[1].toISOString() + let begin = filterDateRange[0].toISOString() + let end = filterDateRange[1].toISOString() try { const idUser = localStorage["userId"] @@ -126,8 +126,8 @@ export default function Report({ idWell }) { } catch (error) { notify( `Не удалось создать отчет по скважине (${idWell}) c - ${aviableDateRange[0].format("DD.MM.YYYY hh:mm:ss")} по - ${aviableDateRange[1].format("DD.MM.YYYY hh:mm:ss")}`, + ${filterDateRange[0].format("DD.MM.YYYY hh:mm:ss")} по + ${filterDateRange[1].format("DD.MM.YYYY hh:mm:ss")}`, "error" ) console.log(error) @@ -159,12 +159,22 @@ export default function Report({ idWell }) { moment(aviableDatesRange.from), moment(aviableDatesRange.to) ] + + let from = moment(aviableDatesRange.to) + from = from.subtract(1, "days") + if (from < datesRange[0]) + from = datesRange[0] + + const filterDateDefaults = [from, moment(aviableDatesRange.to)] + setFilterDateRange(filterDateDefaults) setAviableDateRange(datesRange) } useEffect(() => invokeWebApiWrapperAsync(async() => { const aviableDatesRange = await ReportService.getReportsDateRange(idWell) - updateAviableDatesRange(aviableDatesRange) + updateAviableDatesRange(aviableDatesRange) + const suitableReports = await ReportService.getSuitableReportsNames(idWell, 4294967295, 3, '0001-01-01T00:00:00.000Z', '9999-01-01T00:00:00.000Z') + updateSuitableReports(suitableReports) }), [idWell]) useEffect(() => invokeWebApiWrapperAsync(async() => { @@ -174,8 +184,6 @@ export default function Report({ idWell }) { const end = filterDateRange[1].toISOString() const pagesCount = await ReportService.getReportSize(idWell, step, format, begin, end) setPagesCount(pagesCount) - const suitableReports = await ReportService.getSuitableReportsNames(idWell, step, format, begin, end) - updateSuitableReports(suitableReports) }, setShowLoader, `Не удалось получить предварительные параметры отчета c @@ -204,6 +212,7 @@ export default function Report({ idWell }) { onCalendarChange={(dates) => { setFilterDateRange(dates) }} + value = {filterDateRange} showTime />