From 60507fba406574d5be5b13a256525342fd3c4897 Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Thu, 24 Feb 2022 17:40:17 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=B8,=20=D1=83=D1=81=D0=B8=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/DrillingProgram/CategoryRender.jsx | 52 ++++---- src/pages/DrillingProgram/index.jsx | 125 ++++++++++++------- src/styles/drilling_program.less | 19 ++- 3 files changed, 126 insertions(+), 70 deletions(-) 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; + } + } } /** Миксин для столбцов сетки (размер, отступы, границы) */