forked from ddrilling/asb_cloud_front
Добавлена обработка ошибок при скачивании суточного рапорта и изменён формат даты
This commit is contained in:
parent
b02b828cb6
commit
34c9b81e77
@ -6,7 +6,7 @@ import moment from 'moment'
|
|||||||
import { useWell } from '@asb/context'
|
import { useWell } from '@asb/context'
|
||||||
import LoaderPortal from '@components/LoaderPortal'
|
import LoaderPortal from '@components/LoaderPortal'
|
||||||
import { DateRangeWrapper, Table, makeDateColumn, makeColumn } from '@components/Table'
|
import { DateRangeWrapper, Table, makeDateColumn, makeColumn } from '@components/Table'
|
||||||
import { download, invokeWebApiWrapperAsync } from '@components/factory'
|
import { download, invokeWebApiWrapperAsync, notify } from '@components/factory'
|
||||||
import { arrayOrDefault, wrapPrivateComponent } from '@utils'
|
import { arrayOrDefault, wrapPrivateComponent } from '@utils'
|
||||||
import { DailyReportService } from '@api'
|
import { DailyReportService } from '@api'
|
||||||
|
|
||||||
@ -37,6 +37,16 @@ const DailyReport = memo(() => {
|
|||||||
|
|
||||||
const checkIsDateBusy = useCallback((current) => current.isAfter(moment(), 'day') || data.some((row) => moment(row.reportDate).isSame(current, 'day')), [data])
|
const checkIsDateBusy = useCallback((current) => current.isAfter(moment(), 'day') || data.some((row) => moment(row.reportDate).isSame(current, 'day')), [data])
|
||||||
|
|
||||||
|
const makeOnDownloadClick = useCallback((report) => async () => {
|
||||||
|
const date = moment(report.reportDate)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await download(`/api/well/${well.id}/DailyReport/${date.format('YYYY-MM-DD')}/excel`)
|
||||||
|
} catch {
|
||||||
|
notify(`Не удалось скачать суточный рапорт от ${date.format('DD.MM.YYYY')}`, 'error', well)
|
||||||
|
}
|
||||||
|
}, [well])
|
||||||
|
|
||||||
const columns = useMemo(() => [
|
const columns = useMemo(() => [
|
||||||
makeDateColumn('Дата', 'reportDate', undefined, 'DD.MM.YYYY', { width: 300 }),
|
makeDateColumn('Дата', 'reportDate', undefined, 'DD.MM.YYYY', { width: 300 }),
|
||||||
makeColumn('', '', { width: 200, render: (_, report) => (
|
makeColumn('', '', { width: 200, render: (_, report) => (
|
||||||
@ -44,7 +54,7 @@ const DailyReport = memo(() => {
|
|||||||
<Button
|
<Button
|
||||||
type={'link'}
|
type={'link'}
|
||||||
icon={<FileExcelOutlined />}
|
icon={<FileExcelOutlined />}
|
||||||
onClick={async () => await download(`/api/well/${well.id}/DailyReport/${report.reportDate}/excel`)}
|
onClick={makeOnDownloadClick(report)}
|
||||||
children={'Скачать XLSX'}
|
children={'Скачать XLSX'}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
@ -58,7 +68,7 @@ const DailyReport = memo(() => {
|
|||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}),
|
)}),
|
||||||
], [well])
|
], [makeOnDownloadClick])
|
||||||
|
|
||||||
const filteredData = useMemo(() => {
|
const filteredData = useMemo(() => {
|
||||||
if (!searchDate) return data
|
if (!searchDate) return data
|
||||||
|
Loading…
Reference in New Issue
Block a user