diff --git a/src/pages/DrillingProgram/CategoryRender.jsx b/src/pages/DrillingProgram/CategoryRender.jsx index 92e5ea9..d997135 100644 --- a/src/pages/DrillingProgram/CategoryRender.jsx +++ b/src/pages/DrillingProgram/CategoryRender.jsx @@ -10,6 +10,7 @@ import Poprompt from '@components/Poprompt' import { UserView } from '@components/views' import UploadForm from '@components/UploadForm' import DownloadLink from '@components/DownloadLink' +import LoaderPortal from '@components/LoaderPortal' import { formatBytes, invokeWebApiWrapperAsync, notify } from '@components/factory' import { DrillingProgramService } from '@api' import { formatDate } from '@utils' @@ -17,7 +18,6 @@ import { formatDate } from '@utils' import MarksCard from './MarksCard' import '@styles/drilling_program.less' -import LoaderPortal from '@asb/components/LoaderPortal' const CommentPrompt = memo((props) => (

{title}

- {permissionToEdit && ( + {onEdit && (
- setIsUploading(true)} - onUploadComplete={() => onUpdate?.(idFileCategory)} - onUploadError={(e) => notify(e?.message ?? 'Ошибка загрузки файла', 'error')} - /> + {permissionToUpload && ( + setIsUploading(true)} + onUploadComplete={() => onUpdate?.(idFileCategory)} + onUploadError={(e) => notify(e?.message ?? 'Ошибка загрузки файла', 'error')} + /> + )}
-
- {permissionToApprove && file && ( - - )} - mark.idMarkType === 1)} /> -
-
- {permissionToApprove && file && ( - - )} - mark.idMarkType === 0)} /> -
+ {file && ( + <> +
+ {permissionToApprove && ( + + )} + mark.idMarkType === 1)} /> +
+
+ {permissionToApprove && ( + + )} + mark.idMarkType === 0)} /> +
+ + )}
diff --git a/src/pages/DrillingProgram/index.jsx b/src/pages/DrillingProgram/index.jsx index 8f3fa66..91d0385 100644 --- a/src/pages/DrillingProgram/index.jsx +++ b/src/pages/DrillingProgram/index.jsx @@ -1,8 +1,13 @@ import { Button, Layout } from 'antd' -import { CloseOutlined, FileWordOutlined, LoadingOutlined } from '@ant-design/icons' +import { + CloseOutlined, + FileWordOutlined, + LoadingOutlined, + ReloadOutlined, + WarningOutlined +} from '@ant-design/icons' import { memo, useCallback, useEffect, useState } from 'react' -import { Flex } from '@components/Grid' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' import { arrayOrDefault, formatDate } from '@utils' @@ -15,11 +20,20 @@ import CategoryHistory from './CategoryHistory' import '@styles/drilling_program.less' +const idStateNotInitialized = 0 +const idStateApproving = 1 +const idStateCreating = 2 +const idStateReady = 3 +const idStateError = 4 +const idStateUnknown = -1 + const stateString = { - 0: 'Не настроена', - 1: 'Согласовывается', - 2: 'Формируется', - [-1]: 'Неизвестно', + [idStateNotInitialized]: { icon: CloseOutlined, text: 'Не настроена' }, + [idStateApproving]: { icon: LoadingOutlined, text: 'Согласовывается' }, + [idStateCreating]: { icon: LoadingOutlined, text: 'Формируется' }, + [idStateReady]: { icon: null, text: 'Сформирована' }, + [idStateError]: { icon: WarningOutlined, text: 'Ошибка формирования' }, + [idStateUnknown]: { icon: WarningOutlined, text: 'Неизвестно' }, } export const DrillingProgram = memo(({ idWell }) => { @@ -30,6 +44,20 @@ export const DrillingProgram = memo(({ idWell }) => { const [categories, setCategories] = useState([]) const [data, setData] = useState({}) + const { + idState, + permissionToEdit, + parts, + program, + error, + } = data + + const stateId = idState ?? idStateUnknown + const state = stateString[stateId] + const StateIcon = state.icon + + console.log(parts) + const updateData = useCallback(async () => await invokeWebApiWrapperAsync( async () => { const data = await DrillingProgramService.getState(idWell) @@ -37,7 +65,7 @@ export const DrillingProgram = memo(({ idWell }) => { setData(data) setCategories(categories.filter(cat => { if (cat?.id && (cat.name || cat.shortName)) - if (data?.parts.findIndex((val) => val.idFileCategory === cat.id) < 0) + if (parts?.findIndex((val) => val.idFileCategory === cat.id) < 0) return true return false })) @@ -66,55 +94,64 @@ export const DrillingProgram = memo(({ idWell }) => { return ( - {data && ( -
-
-

Программа бурения

-
- - {data?.idState === 3 ? ( - <> - -
Размер: {data.program.size}
-
Загружен: {formatDate(data.program.uploadDate)}
- - ) : ( -

- {data?.idState <= 0 ? ( - - ) : ( - - )} - {stateString[data?.idState ?? -1]} -

- )} -
+
+
+

Программа бурения

+ {permissionToEdit && ( +
+ +
+ )}
- )} +
+ {stateId === idStateReady ? ( + <> + +
Размер: {program?.size}
+
Загружен: {formatDate(program?.uploadDate)}
+ + ) : ( +

+ + {(stateId === idStateError && error?.message) ? error.message : state.text} +

+ )} +
+
- {data?.parts?.map?.((part, idx) => part && ( + {parts?.map?.((part, idx) => part && ( ))} - + {permissionToEdit && ( + <> + - part.idFileCategory === selectedCategory) ?? {}} - /> + part.idFileCategory === selectedCategory) ?? {}} + /> + + )} .program_header { .drilling_category > .category_header(); } + + > .program_content { + display: flex; + justify-content: flex-start; + align-items: center; + background-color: white; + + .program_status { + margin: 10px; + color: black; + } + + .program_status.error { + color: red; + } + } } /** Миксин для столбцов сетки (размер, отступы, границы) */