forked from ddrilling/asb_cloud_front
Merge branch 'dev' into feature/add-zoom-for-d3chart
This commit is contained in:
commit
f481a212c5
@ -42,7 +42,7 @@ export const App = memo(() => (
|
|||||||
|
|
||||||
{/* User pages */}
|
{/* User pages */}
|
||||||
<Route element={<UserOutlet />}>
|
<Route element={<UserOutlet />}>
|
||||||
<Route path={'/file_download/:idWell/:idFile/*'} element={<FileDownload />} />
|
<Route path={'/file_download/:idFile/*'} element={<FileDownload />} />
|
||||||
|
|
||||||
<Route element={<LayoutPortal />}>
|
<Route element={<LayoutPortal />}>
|
||||||
{/* Admin pages */}
|
{/* Admin pages */}
|
||||||
|
@ -1,40 +1,30 @@
|
|||||||
import { Link, useNavigate, useParams } from 'react-router-dom'
|
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'
|
||||||
import { memo, useCallback, useEffect, useState } from 'react'
|
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import { InfoCircleFilled, CloseCircleOutlined } from '@ant-design/icons'
|
import { InfoCircleFilled, CloseCircleOutlined } from '@ant-design/icons'
|
||||||
import { Button, Result, Typography } from 'antd'
|
import { Button, Result, Typography } from 'antd'
|
||||||
|
|
||||||
import { downloadFile, invokeWebApiWrapperAsync } from '@components/factory'
|
import { downloadFile, invokeWebApiWrapperAsync } from '@components/factory'
|
||||||
import { withPermissions } from '@utils'
|
import { withPermissions } from '@utils'
|
||||||
import { FileService, WellService } from '@api'
|
import { FileService } from '@api'
|
||||||
|
|
||||||
const { Paragraph, Text } = Typography
|
const { Paragraph, Text } = Typography
|
||||||
|
|
||||||
export const getLinkToFile = (fileInfo) => `/file_download/${fileInfo.idWell}/${fileInfo.id}`
|
export const getLinkToFile = (fileInfo) => `/file_download/${fileInfo.id}`
|
||||||
|
|
||||||
const FileDownload = memo(function FileDownload() {
|
const FileDownload = memo(function FileDownload() {
|
||||||
const { idWell, idFile } = useParams()
|
const { idFile } = useParams()
|
||||||
const [well, setWell] = useState({})
|
|
||||||
const [file, setFile] = useState({})
|
const [file, setFile] = useState({})
|
||||||
const [isError, setIsError] = useState(false)
|
const [isError, setIsError] = useState(false)
|
||||||
|
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const location = useLocation()
|
||||||
useEffect(() => {
|
const isFirstOpenApp = useMemo(() => location.key === 'default', [location])
|
||||||
invokeWebApiWrapperAsync(
|
|
||||||
async () => setWell(await WellService.get(idWell)),
|
|
||||||
null,
|
|
||||||
'Не удалось получить информацию о скважине',
|
|
||||||
{ actionName: 'Получение данных о скважине' }
|
|
||||||
)
|
|
||||||
}, [idWell])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invokeWebApiWrapperAsync(
|
invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const files = await FileService.getFilesInfo(idWell)
|
const file = await FileService.getFileInfo(idFile)
|
||||||
// TODO Получается только одна категория файлов.
|
setFile(file)
|
||||||
// Поменять при появлении метода получения инфы о конкретном файле
|
|
||||||
setFile(files.items.find((file) => file.id === idFile) ?? { id: idFile, idWell, name: `File_${idWell}_${idFile}` })
|
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
() => {
|
() => {
|
||||||
@ -43,10 +33,10 @@ const FileDownload = memo(function FileDownload() {
|
|||||||
},
|
},
|
||||||
{ actionName: 'Получение информации о файле' }
|
{ actionName: 'Получение информации о файле' }
|
||||||
)
|
)
|
||||||
}, [idWell, idFile])
|
}, [idFile])
|
||||||
|
|
||||||
const download = useCallback(async () => {
|
const download = useCallback(async () => {
|
||||||
if (!await downloadFile(file))
|
if (!file || !await downloadFile(file))
|
||||||
setIsError(true)
|
setIsError(true)
|
||||||
}, [file])
|
}, [file])
|
||||||
|
|
||||||
@ -58,13 +48,16 @@ const FileDownload = memo(function FileDownload() {
|
|||||||
<>
|
<>
|
||||||
Вы перешли к странице загрузки файла!
|
Вы перешли к странице загрузки файла!
|
||||||
<br />
|
<br />
|
||||||
Файл "{file.name ?? ('№' + idFile)}", скважина "{well.caption ?? ('№' + idWell)}".
|
Файл "{file?.name ?? ('№' + idFile)}".
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
// subTitle={}
|
// subTitle={}
|
||||||
extra={(
|
extra={(
|
||||||
<>
|
<>
|
||||||
<Button type={'ghost'} onClick={() => navigate('/')}>Вернуться на главную</Button>
|
{isFirstOpenApp
|
||||||
|
? <Button type={'ghost'} onClick={() => navigate('/')}>Вернуться на главную</Button>
|
||||||
|
: <Button type={'ghost'} onClick={() => navigate(-1)}>Вернуться на страницу документов</Button>
|
||||||
|
}
|
||||||
<Button type={'primary'} onClick={download}>Загрузить</Button>
|
<Button type={'primary'} onClick={download}>Загрузить</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -72,8 +72,7 @@ const DailyReport = memo(() => {
|
|||||||
|
|
||||||
const filteredData = useMemo(() => {
|
const filteredData = useMemo(() => {
|
||||||
if (!searchDate) return data
|
if (!searchDate) return data
|
||||||
const endDate = moment(searchDate[1]).add(1, 'd')
|
return data.filter((row) => moment(row.reportDate).isBetween(searchDate[0], searchDate[1], 'day', '[]'))
|
||||||
return data.filter((row) => moment(row.reportDate).isBetween(searchDate[0], endDate, 'ms', '[)'))
|
|
||||||
}, [data, searchDate])
|
}, [data, searchDate])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user