From 6b6020758b9c5f98369f14521bc576b7dc62a8ff Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Thu, 24 Feb 2022 18:53:06 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=BE=D1=80=D0=BC=D0=B0=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=B3=D0=BE=D1=80=D0=B8=D0=B8=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D0=B0=20=D0=B2=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D0=BE=D0=BB=D0=BE=D0=B2=D0=BE=D0=BA=20=D0=B1=D0=BB?= =?UTF-8?q?=D0=BE=D0=BA=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=BC=D1=8B=20=D0=B1=D1=83=D1=80=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20=D1=81=D0=B1=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D0=BB=D0=B5=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/DrillingProgram/CategoryAdder.jsx | 62 +++++++++++++-------- src/pages/DrillingProgram/index.jsx | 36 ++++++------ 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/src/pages/DrillingProgram/CategoryAdder.jsx b/src/pages/DrillingProgram/CategoryAdder.jsx index c180457..390f8f9 100644 --- a/src/pages/DrillingProgram/CategoryAdder.jsx +++ b/src/pages/DrillingProgram/CategoryAdder.jsx @@ -1,12 +1,18 @@ -import { Button, Select } from 'antd' +import { Form, Select } from 'antd' import { FileAddOutlined } from '@ant-design/icons' import { memo, useCallback, useEffect, useState } from 'react' -import { DrillingProgramService } from '@api' +import Poprompt from '@components/Poprompt' import { invokeWebApiWrapperAsync } from '@components/factory' +import { DrillingProgramService } from '@api' import '@styles/drilling_program.less' +const catSelectorRules = [{ + required: true, + message: 'Пожалуйста, выберите категории' +}] + export const CategoryAdder = memo(({ categories, idWell, onUpdate, className, ...other }) => { const [options, setOptions] = useState([]) const [value, setValue] = useState([]) @@ -24,37 +30,47 @@ export const CategoryAdder = memo(({ categories, idWell, onUpdate, className, .. `Не удалось установить список доступных категорий для добавления` ), [categories]) - const onAddClick = useCallback(() => invokeWebApiWrapperAsync( + const onFinish = useCallback(({ categories }) => invokeWebApiWrapperAsync( async () => { - await DrillingProgramService.addParts(idWell, value) + if (!categories) return + await DrillingProgramService.addParts(idWell, categories) setValue([]) onUpdate?.() }, setShowLoader, `Не удалось добавить новые категорий программы бурения`, `Добавление категорий программы бурения` - ), [onUpdate, idWell, value]) + ), [onUpdate, idWell]) return ( -
- + + ) }) diff --git a/src/pages/DrillingProgram/index.jsx b/src/pages/DrillingProgram/index.jsx index 7e617d9..9f4a6d1 100644 --- a/src/pages/DrillingProgram/index.jsx +++ b/src/pages/DrillingProgram/index.jsx @@ -1,4 +1,4 @@ -import { Button, Layout } from 'antd' +import { Button, Layout, Menu } from 'antd' import { CheckOutlined, CloseOutlined, @@ -57,8 +57,6 @@ export const DrillingProgram = memo(({ idWell }) => { const state = stateString[stateId] const StateIcon = state.icon - console.log(parts) - const updateData = useCallback(async () => await invokeWebApiWrapperAsync( async () => { const data = await DrillingProgramService.getState(idWell) @@ -100,13 +98,11 @@ export const DrillingProgram = memo(({ idWell }) => {

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

{permissionToEdit && (
- +
)}
@@ -117,10 +113,20 @@ export const DrillingProgram = memo(({ idWell }) => {
Размер: {program?.size}
Загружен: {formatDate(program?.uploadDate)}
+ ) : stateId === idStateError ? ( + <> +

+ + {error?.message ?? state.text} +

+ + ) : ( -

+

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

)} @@ -139,12 +145,6 @@ export const DrillingProgram = memo(({ idWell }) => { {permissionToEdit && ( <> - -