forked from ddrilling/asb_cloud_front
Исправлена фильтрация суточных рапортов по дате
This commit is contained in:
parent
0ed91387b9
commit
f9ddf172f5
@ -1,10 +1,9 @@
|
|||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import { Button } from 'antd'
|
import { Button, DatePicker } from 'antd'
|
||||||
import { memo, useCallback, useContext, useEffect, useMemo, useState } from 'react'
|
|
||||||
import { FileExcelOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons'
|
import { FileExcelOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons'
|
||||||
|
import { memo, useCallback, useContext, useEffect, useMemo, useState } from 'react'
|
||||||
|
|
||||||
import LoaderPortal from '@components/LoaderPortal'
|
import LoaderPortal from '@components/LoaderPortal'
|
||||||
import DateRangeWrapper from '@components/Table/DateRangeWrapper'
|
|
||||||
import { Table, makeDateColumn, makeColumn } from '@components/Table'
|
import { Table, makeDateColumn, makeColumn } from '@components/Table'
|
||||||
import { download, invokeWebApiWrapperAsync } from '@components/factory'
|
import { download, invokeWebApiWrapperAsync } from '@components/factory'
|
||||||
import { DailyReportService } from '@api'
|
import { DailyReportService } from '@api'
|
||||||
@ -16,7 +15,7 @@ import { IdWellContext } from '@pages/Well'
|
|||||||
export const DailyReport = memo(() => {
|
export const DailyReport = memo(() => {
|
||||||
const [data, setData] = useState([])
|
const [data, setData] = useState([])
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const [searchDate, setSearchDate] = useState(null)
|
const [searchDate, setSearchDate] = useState([moment().subtract(1, 'week'), moment()])
|
||||||
const [selectedReport, setSelectedReport] = useState(null)
|
const [selectedReport, setSelectedReport] = useState(null)
|
||||||
const [isEditorVisible, setIsEditorVisible] = useState(false)
|
const [isEditorVisible, setIsEditorVisible] = useState(false)
|
||||||
|
|
||||||
@ -42,9 +41,8 @@ export const DailyReport = memo(() => {
|
|||||||
type={'link'}
|
type={'link'}
|
||||||
icon={<FileExcelOutlined />}
|
icon={<FileExcelOutlined />}
|
||||||
onClick={async () => await download(`/api/well/${idWell}/DailyReport/${report.reportDate}/excel`)}
|
onClick={async () => await download(`/api/well/${idWell}/DailyReport/${report.reportDate}/excel`)}
|
||||||
>
|
children={'Скачать XLSX'}
|
||||||
Скачать XLSX
|
/>
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
type={'link'}
|
type={'link'}
|
||||||
icon={<EditOutlined />}
|
icon={<EditOutlined />}
|
||||||
@ -52,16 +50,15 @@ export const DailyReport = memo(() => {
|
|||||||
setSelectedReport(report)
|
setSelectedReport(report)
|
||||||
setIsEditorVisible(true)
|
setIsEditorVisible(true)
|
||||||
}}
|
}}
|
||||||
>
|
children={'Редактировать'}
|
||||||
Редактировать
|
/>
|
||||||
</Button>
|
|
||||||
</>
|
</>
|
||||||
)}),
|
)}),
|
||||||
], [idWell])
|
], [idWell])
|
||||||
|
|
||||||
const filteredData = useMemo(() => {
|
const filteredData = useMemo(() => {
|
||||||
if (!searchDate) return data
|
if (!searchDate) return data
|
||||||
return data.filter((row) => moment(row.date).isBetween(...searchDate))
|
return data.filter((row) => moment.utc(row.reportDate).local().isBetween(...searchDate))
|
||||||
}, [data, searchDate])
|
}, [data, searchDate])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -71,7 +68,13 @@ export const DailyReport = memo(() => {
|
|||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<div>Диапозон дат отчёта</div>
|
<div>Диапозон дат отчёта</div>
|
||||||
<DateRangeWrapper onCalendarChange={setSearchDate} />
|
<DatePicker.RangePicker
|
||||||
|
allowClear={false}
|
||||||
|
format={'DD.MM.YYYY'}
|
||||||
|
defaultValue={searchDate}
|
||||||
|
onCalendarChange={setSearchDate}
|
||||||
|
disabledDate={(date) => date.isAfter(moment())}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', alignItems: 'end' }}>
|
<div style={{ display: 'flex', alignItems: 'end' }}>
|
||||||
|
Loading…
Reference in New Issue
Block a user