fix report filter

This commit is contained in:
Фролов 2021-09-21 10:35:34 +05:00
parent 8d46df8294
commit 4d8a62c072

View File

@ -84,8 +84,8 @@ export default function Report({ idWell }) {
] ]
const handleReportCreation = async (values) => { const handleReportCreation = async (values) => {
let begin = aviableDateRange[0].toISOString() let begin = filterDateRange[0].toISOString()
let end = aviableDateRange[1].toISOString() let end = filterDateRange[1].toISOString()
try { try {
const idUser = localStorage["userId"] const idUser = localStorage["userId"]
@ -126,8 +126,8 @@ export default function Report({ idWell }) {
} catch (error) { } catch (error) {
notify( notify(
`Не удалось создать отчет по скважине (${idWell}) c `Не удалось создать отчет по скважине (${idWell}) c
${aviableDateRange[0].format("DD.MM.YYYY hh:mm:ss")} по ${filterDateRange[0].format("DD.MM.YYYY hh:mm:ss")} по
${aviableDateRange[1].format("DD.MM.YYYY hh:mm:ss")}`, ${filterDateRange[1].format("DD.MM.YYYY hh:mm:ss")}`,
"error" "error"
) )
console.log(error) console.log(error)
@ -159,12 +159,22 @@ export default function Report({ idWell }) {
moment(aviableDatesRange.from), moment(aviableDatesRange.from),
moment(aviableDatesRange.to) 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) setAviableDateRange(datesRange)
} }
useEffect(() => invokeWebApiWrapperAsync(async() => { useEffect(() => invokeWebApiWrapperAsync(async() => {
const aviableDatesRange = await ReportService.getReportsDateRange(idWell) 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]) }), [idWell])
useEffect(() => invokeWebApiWrapperAsync(async() => { useEffect(() => invokeWebApiWrapperAsync(async() => {
@ -174,8 +184,6 @@ export default function Report({ idWell }) {
const end = filterDateRange[1].toISOString() const end = filterDateRange[1].toISOString()
const pagesCount = await ReportService.getReportSize(idWell, step, format, begin, end) const pagesCount = await ReportService.getReportSize(idWell, step, format, begin, end)
setPagesCount(pagesCount) setPagesCount(pagesCount)
const suitableReports = await ReportService.getSuitableReportsNames(idWell, step, format, begin, end)
updateSuitableReports(suitableReports)
}, },
setShowLoader, setShowLoader,
`Не удалось получить предварительные параметры отчета c `Не удалось получить предварительные параметры отчета c
@ -204,6 +212,7 @@ export default function Report({ idWell }) {
onCalendarChange={(dates) => { onCalendarChange={(dates) => {
setFilterDateRange(dates) setFilterDateRange(dates)
}} }}
value = {filterDateRange}
showTime showTime
/> />
</Form.Item> </Form.Item>