Подготовка к обновлению AntD и мелкие исправления

This commit is contained in:
goodmice 2022-10-13 18:49:26 +05:00
parent 718d32f2b9
commit d14513e249
No known key found for this signature in database
GPG Key ID: 63EA771203189CF1
30 changed files with 74 additions and 57 deletions

View File

@ -63,7 +63,7 @@ export const ChangePassword = memo<ChangePasswordProps>(({ user, visible, onCanc
{user && <>&nbsp;(<UserView user={user} />)</>} {user && <>&nbsp;(<UserView user={user} />)</>}
</> </>
)} )}
visible={visible} open={visible}
onCancel={onModalCancel} onCancel={onModalCancel}
onOk={() => form.submit()} onOk={() => form.submit()}
okText={'Сохранить'} okText={'Сохранить'}

View File

@ -106,7 +106,7 @@ export const ColorPicker = memo<ColorPickerProps>(({ value = '#AA33BB', onChange
return ( return (
<Popover <Popover
trigger={'click'} trigger={'click'}
onVisibleChange={onClose} onOpenChange={onClose}
content={( content={(
<div className={'asb-color-picker-content'}> <div className={'asb-color-picker-content'}>
<div className={'asb-color-picker-sliders'}> <div className={'asb-color-picker-sliders'}>

View File

@ -84,7 +84,7 @@ const _TableSettingsChanger = <T extends object>({ title, columns, settings, onC
<> <>
<Modal <Modal
centered centered
visible={visible} open={visible}
onCancel={onModalCancel} onCancel={onModalCancel}
onOk={onModalOk} onOk={onModalOk}
title={title ?? 'Настройка отображения таблицы'} title={title ?? 'Настройка отображения таблицы'}

View File

@ -135,7 +135,7 @@ const _D3MonitoringEditor = <DataType extends BaseDataType>({
<Modal <Modal
centered centered
width={800} width={800}
visible={visible} open={visible}
title={'Настройка групп графиков'} title={'Настройка групп графиков'}
onCancel={onCancel} onCancel={onCancel}
footer={( footer={(

View File

@ -39,8 +39,8 @@ export const Poprompt = memo<PopromptProps>(({ formProps, buttonProps, footer, c
)} )}
trigger={'click'} trigger={'click'}
{...other} {...other}
visible={visible} open={visible}
onVisibleChange={(visible) => setVisible(visible)} onOpenChange={(visible) => setVisible(visible)}
> >
<Button {...buttonProps}>{text}</Button> <Button {...buttonProps}>{text}</Button>
</Popover> </Popover>

View File

@ -20,7 +20,7 @@ export const WidgetSettingsWindow = memo<WidgetSettingsWindowProps>(({ settings,
return ( return (
<Modal <Modal
{...other} {...other}
visible={!!settings} open={!!settings}
title={( title={(
<> <>
Настройка виджета {settings?.label ? `"${settings?.label}"` : ''} Настройка виджета {settings?.label ? `"${settings?.label}"` : ''}

View File

@ -36,7 +36,6 @@ export const AdminNavigationMenu = memo((props) => (
{...props} {...props}
items={menuItems} items={menuItems}
rootPath={'/admin'} rootPath={'/admin'}
inlineCollapsed={true}
selectable={false} selectable={false}
mode={'inline'} mode={'inline'}
theme={'dark'} theme={'dark'}

View File

@ -179,7 +179,7 @@ const ClusterWells = memo(({ statsWells }) => {
<Modal <Modal
title={'TVD'} title={'TVD'}
centered centered
visible={isTVDModalVisible} open={isTVDModalVisible}
onCancel={() => setIsTVDModalVisible(false)} onCancel={() => setIsTVDModalVisible(false)}
width={1500} width={1500}
footer={null} footer={null}
@ -192,7 +192,7 @@ const ClusterWells = memo(({ statsWells }) => {
<Modal <Modal
title={'Операции'} title={'Операции'}
centered centered
visible={isOpsModalVisible} open={isOpsModalVisible}
onCancel={() => setIsOpsModalVisible(false)} onCancel={() => setIsOpsModalVisible(false)}
width={1500} width={1500}
footer={null} footer={null}
@ -205,7 +205,7 @@ const ClusterWells = memo(({ statsWells }) => {
<Modal <Modal
title={'Участники'} title={'Участники'}
centered centered
visible={isCompaniesModalVisible} open={isCompaniesModalVisible}
onCancel={() => setIsCompaniesModalVisible(false)} onCancel={() => setIsCompaniesModalVisible(false)}
width={1500} width={1500}
footer={null} footer={null}

View File

@ -1,10 +1,10 @@
import { memo, useMemo } from 'react' import { memo, useMemo } from 'react'
import { BankOutlined } from '@ant-design/icons' import { BankOutlined } from '@ant-design/icons'
import { makeTextColumn, Table } from '@components/Table' import { makeColumn, makeTextColumn, Table } from '@components/Table'
const columns = [ const columns = [
makeTextColumn('', 'logo'), makeColumn('', 'logo'),
makeTextColumn('Название компании', 'caption'), makeTextColumn('Название компании', 'caption'),
makeTextColumn('Тип компании', 'companyTypeCaption'), makeTextColumn('Тип компании', 'companyTypeCaption'),
] ]
@ -12,7 +12,11 @@ const columns = [
const CompaniesTable = memo(({ companies }) => { const CompaniesTable = memo(({ companies }) => {
const dataCompanies = useMemo(() => companies?.map((company) => ({ const dataCompanies = useMemo(() => companies?.map((company) => ({
key: company.id, key: company.id,
logo: company?.logo ? <img src={company.logo}/> : <BankOutlined/>, logo: (
<div className={'centered'}>
{company?.logo ? <img src={company.logo}/> : <BankOutlined/>}
</div>
),
caption: company.caption, caption: company.caption,
companyTypeCaption: company.companyTypeCaption, companyTypeCaption: company.companyTypeCaption,
})), [companies]) })), [companies])

View File

@ -7,8 +7,8 @@ import { getPrecision } from '@utils/functions'
const columns = [ const columns = [
makeTextColumn('Конструкция секции', 'sectionType'), makeTextColumn('Конструкция секции', 'sectionType'),
makeTextColumn('Операция', 'operationName'), makeTextColumn('Операция', 'operationName'),
makeNumericColumnPlanFact('Глубина забоя', 'depth', null, null, getPrecision), makeNumericColumnPlanFact('Глубина забоя', 'depth', null, null, (number) => getPrecision(number)),
makeNumericColumnPlanFact('Часы', 'durationHours', null, null, getPrecision), makeNumericColumnPlanFact('Часы', 'durationHours', null, null, (number) => getPrecision(number)),
makeNumericColumnPlanFact('Комментарий', 'comment', null, null, (text) => text ?? '-') makeNumericColumnPlanFact('Комментарий', 'comment', null, null, (text) => text ?? '-')
] ]

View File

@ -7,7 +7,7 @@ import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory' import { invokeWebApiWrapperAsync } from '@components/factory'
import { DrillParamsService } from '@api' import { DrillParamsService } from '@api'
import { getColumns } from '@asb/pages/Well/WellOperations/WellDrillParams' import { getColumns } from '@pages/Well/WellOperations/WellDrillParams'
export const NewParamsTable = memo(({ selectedWellsKeys }) => { export const NewParamsTable = memo(({ selectedWellsKeys }) => {
const [params, setParams] = useState([]) const [params, setParams] = useState([])
@ -54,7 +54,7 @@ export const NewParamsTable = memo(({ selectedWellsKeys }) => {
<Modal <Modal
title={'Заполнить режимы текущей скважины'} title={'Заполнить режимы текущей скважины'}
centered centered
visible={isParamsModalVisible} open={isParamsModalVisible}
onCancel={() => setIsParamsModalVisible(false)} onCancel={() => setIsParamsModalVisible(false)}
width={1700} width={1700}
footer={( footer={(

View File

@ -1,7 +1,7 @@
import { Link, useLocation } from 'react-router-dom' import { Link, useLocation } from 'react-router-dom'
import { useState, useEffect, memo, useMemo } from 'react' import { useState, useEffect, memo, useMemo, lazy, Suspense } from 'react'
import { LineChartOutlined, ProfileOutlined, TeamOutlined } from '@ant-design/icons' import { LineChartOutlined, ProfileOutlined, TeamOutlined } from '@ant-design/icons'
import { Table, Tag, Button, Badge, Divider, Modal, Row, Col } from 'antd' import { Table, Button, Badge, Divider, Modal, Row, Col } from 'antd'
import { useWell } from '@asb/context' import { useWell } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal' import LoaderPortal from '@components/LoaderPortal'
@ -16,10 +16,12 @@ import {
getOperations getOperations
} from '@utils' } from '@utils'
import Tvd from '@asb/pages/Well/WellOperations/Tvd'
import WellOperationsTable from '@pages/Cluster/WellOperationsTable'
import NewParamsTable from './NewParamsTable' import NewParamsTable from './NewParamsTable'
import CompaniesTable from '@pages/Cluster/CompaniesTable' import SuspenseFallback from '@asb/components/SuspenseFallback'
const Tvd = lazy(() => import('@pages/Well/WellOperations/Tvd'))
const CompaniesTable = lazy(() => import('@pages/Cluster/CompaniesTable'))
const WellOperationsTable = lazy(() => import('@pages/Cluster/WellOperationsTable'))
const filtersMinMax = [ const filtersMinMax = [
{ text: 'min', value: 'min' }, { text: 'min', value: 'min' },
@ -222,38 +224,44 @@ const WellCompositeSections = memo(({ statsWells, selectedSections }) => {
<Modal <Modal
title={'TVD'} title={'TVD'}
centered centered
visible={isTVDModalVisible} open={isTVDModalVisible}
onCancel={() => setIsTVDModalVisible(false)} onCancel={() => setIsTVDModalVisible(false)}
width={1500} width={1500}
footer={null} footer={null}
> >
<Suspense fallback={<SuspenseFallback style={{ minHeight: '100%' }} />}>
<Tvd well={selectedWell} style={{ height: '80vh' }} /> <Tvd well={selectedWell} style={{ height: '80vh' }} />
</Suspense>
</Modal> </Modal>
<Modal <Modal
title={'Операции'} title={'Операции'}
centered centered
visible={isOpsModalVisible} open={isOpsModalVisible}
onCancel={() => setIsOpsModalVisible(false)} onCancel={() => setIsOpsModalVisible(false)}
width={1500} width={1500}
footer={null} footer={null}
> >
<Suspense fallback={<SuspenseFallback style={{ minHeight: '100%' }} />}>
<LoaderPortal show={showLoader}> <LoaderPortal show={showLoader}>
<WellOperationsTable wellOperations={wellOperations} /> <WellOperationsTable wellOperations={wellOperations} />
</LoaderPortal> </LoaderPortal>
</Suspense>
</Modal> </Modal>
<Modal <Modal
title={'Участники'} title={'Участники'}
centered centered
visible={isCompaniesModalVisible} open={isCompaniesModalVisible}
onCancel={() => setIsCompaniesModalVisible(false)} onCancel={() => setIsCompaniesModalVisible(false)}
width={1500} width={1500}
footer={null} footer={null}
> >
<Suspense fallback={<SuspenseFallback style={{ minHeight: '100%' }} />}>
<LoaderPortal show={showLoader}> <LoaderPortal show={showLoader}>
<CompaniesTable companies={companies} /> <CompaniesTable companies={companies} />
</LoaderPortal> </LoaderPortal>
</Suspense>
</Modal> </Modal>
</> </>
) )

View File

@ -1,17 +1,18 @@
import { Navigate, Route, Routes } from 'react-router-dom' import { Navigate, Route, Routes } from 'react-router-dom'
import { useState, useEffect, memo, Suspense } from 'react' import { useState, useEffect, memo, Suspense, lazy } from 'react'
import { Row } from 'antd' import { Row } from 'antd'
import { useWell } from '@asb/context' import { useWell } from '@asb/context'
import LoaderPortal from '@components/LoaderPortal' import LoaderPortal from '@components/LoaderPortal'
import SuspenseFallback from '@components/SuspenseFallback'
import WellSelector from '@components/selectors/WellSelector' import WellSelector from '@components/selectors/WellSelector'
import { invokeWebApiWrapperAsync } from '@components/factory' import { invokeWebApiWrapperAsync } from '@components/factory'
import { arrayOrDefault, NoAccessComponent, wrapPrivateComponent } from '@utils' import { arrayOrDefault, NoAccessComponent, wrapPrivateComponent } from '@utils'
import { OperationStatService, WellCompositeService } from '@api' import { OperationStatService, WellCompositeService } from '@api'
import ClusterWells from '@pages/Cluster/ClusterWells'
import WellCompositeSections from './WellCompositeSections' import WellCompositeSections from './WellCompositeSections'
import SuspenseFallback from '@asb/components/SuspenseFallback'
const ClusterWells = lazy(() => import('@pages/Cluster/ClusterWells'))
const properties = { const properties = {
requirements: ['OperationStat.get', 'WellComposite.get'], requirements: ['OperationStat.get', 'WellComposite.get'],
@ -64,16 +65,16 @@ const WellCompositeEditor = memo(() => {
return ( return (
<LoaderPortal show={showLoader}> <LoaderPortal show={showLoader}>
<Row align={'middle'} justify={'space-between'} wrap={false} style={{ backgroundColor: 'white' }}> <Row align={'middle'} justify={'space-between'} wrap={false} style={{ backgroundColor: 'white', marginBottom: '15px' }}>
<WellSelector onChange={setSelectedIdWells} value={selectedIdWells} /> <WellSelector onChange={setSelectedIdWells} value={selectedIdWells} />
</Row> </Row>
<Suspense fallback={<SuspenseFallback style={{ minHeight: '100%' }} />}> <Suspense fallback={<SuspenseFallback style={{ minHeight: '100%' }} />}>
<Routes> <Routes>
<Route index element={<Navigate to={ClusterWells.route} replace/>} /> <Route index element={<Navigate to={'wells'} replace/>} />
<Route path={'*'} element={<NoAccessComponent />} /> <Route path={'*'} element={<NoAccessComponent />} />
<Route path={ClusterWells.route} element={<ClusterWells statsWells={statsWells} />} /> <Route path={'wells'} element={<ClusterWells statsWells={statsWells} />} />
<Route path={WellCompositeSections.route} element={<WellCompositeSections statsWells={statsWells} selectedSections={selectedSections} />} /> <Route path={'sections'} element={<WellCompositeSections statsWells={statsWells} selectedSections={selectedSections} />} />
</Routes> </Routes>
</Suspense> </Suspense>
</LoaderPortal> </LoaderPortal>

View File

@ -159,7 +159,7 @@ export const CategoryEditor = memo(({ visible, category, onClosed }) => {
<Modal <Modal
centered centered
width={1000} width={1000}
visible={visible} open={visible}
footer={null} footer={null}
onCancel={onModalClosed} onCancel={onModalClosed}
title={`Редактирование пользователей категории ${title}`} title={`Редактирование пользователей категории ${title}`}

View File

@ -94,7 +94,7 @@ export const CategoryHistory = ({ idCategory, visible, onClose }) => {
title={'История категории'} title={'История категории'}
width={1200} width={1200}
centered centered
visible={!!visible} open={!!visible}
onCancel={onClose} onCancel={onClose}
footer={( footer={(
<Button onClick={onClose}>Закрыть</Button> <Button onClick={onClose}>Закрыть</Button>

View File

@ -35,7 +35,7 @@ export const InclinometryTable = memo(({ group, visible, onClose }) => {
<Modal <Modal
title={group?.title} title={group?.title}
centered centered
visible={visible} open={visible}
onCancel={onClose} onCancel={onClose}
width={1900} width={1900}
footer={null} footer={null}

View File

@ -68,7 +68,6 @@ export const NavigationMenu = memo((props) => (
{...props} {...props}
items={menuItems} items={menuItems}
rootPath={'/well/{wellId}'} rootPath={'/well/{wellId}'}
inlineCollapsed={true}
mode={'inline'} mode={'inline'}
theme={'dark'} theme={'dark'}
style={{ backgroundColor: 'transparent' }} style={{ backgroundColor: 'transparent' }}

View File

@ -374,7 +374,7 @@ export const ReportEditor = memo(({ visible, data, onDone, onCancel, checkIsDate
<Modal <Modal
centered centered
width={1200} width={1200}
visible={visible} open={visible}
onCancel={onCancel} onCancel={onCancel}
okText={'Сохранить'} okText={'Сохранить'}
title={data ? ( title={data ? (

View File

@ -53,7 +53,7 @@ export const DrillerList = memo(({ loading, drillers, onChange }) => {
centered centered
width={500} width={500}
footer={null} footer={null}
visible={showModal} open={showModal}
onCancel={onModalCancel} onCancel={onModalCancel}
title={'Список бурильщиков'} title={'Список бурильщиков'}
> >

View File

@ -100,7 +100,7 @@ export const DrillerSchedule = memo(({ drillers, loading, onChange }) => {
centered centered
width={1600} width={1600}
footer={null} footer={null}
visible={modalVisible} open={modalVisible}
onCancel={onModalCancel} onCancel={onModalCancel}
title={'Настройка бурильщиков и расписаний'} title={'Настройка бурильщиков и расписаний'}
> >

View File

@ -96,7 +96,7 @@ export const TargetEditor = memo(({ loading, onChange }) => {
centered centered
width={1000} width={1000}
footer={null} footer={null}
visible={showModal} open={showModal}
onCancel={onModalCancel} onCancel={onModalCancel}
title={'Цели бурения'} title={'Цели бурения'}
> >

View File

@ -80,7 +80,7 @@ export const SetpointSender = memo(({ onClose, visible, setpointNames }) => {
<Modal <Modal
width={800} width={800}
title={'Рекомендовать уставки'} title={'Рекомендовать уставки'}
visible={visible} open={visible}
onCancel={onClose} onCancel={onClose}
onOk={onModalOk} onOk={onModalOk}
okText={'Отправить'} okText={'Отправить'}

View File

@ -38,7 +38,7 @@ export const SetpointViewer = memo(({ setpoint, visible, onClose, setpointNames
width={800} width={800}
title={`Уставка от ${date}`} title={`Уставка от ${date}`}
onCancel={onClose} onCancel={onClose}
visible={visible} open={visible}
footer={null} footer={null}
> >
<Grid> <Grid>

View File

@ -89,7 +89,7 @@ export const Setpoints = memo(({ ...other }) => {
</Button> </Button>
</> </>
)} )}
visible={isModalVisible} open={isModalVisible}
onCancel={() => setIsModalVisible(false)} onCancel={() => setIsModalVisible(false)}
footer={null} footer={null}
> >

View File

@ -33,7 +33,7 @@ export const WirelineRunOut = memo(() => {
return ( return (
<WirelineView <WirelineView
wireline={twro} wireline={twro}
onVisibleChange={onTooltipVisibleChanged} onOpenChange={onTooltipVisibleChanged}
buttonProps={{ loading: isLoading }} buttonProps={{ loading: isLoading }}
/> />
) )

View File

@ -117,7 +117,7 @@ export const WellCaseEditor = memo(({ categories: currentCategories, show, onClo
<Modal <Modal
centered centered
width={1000} width={1000}
visible={show} open={show}
onOk={onModalOk} onOk={onModalOk}
onCancel={onModalCancel} onCancel={onModalCancel}
okText={'Сохранить'} okText={'Сохранить'}

View File

@ -62,7 +62,7 @@ const WellCase = memo(() => {
}), }),
makeDateColumn('Дата загрузки', 'uploadDate'), makeDateColumn('Дата загрузки', 'uploadDate'),
makeColumn('Ответственные', 'publishers', { makeColumn('Ответственные', 'publishers', {
render: (publishers) => publishers?.map((user) => <UserView user={user} style={{ marginLeft: 10 }} />), render: (publishers) => publishers?.map((user, i) => <UserView key={`${i}`} user={user} style={{ marginLeft: 10 }} />),
}), }),
], [well, updateTable]) ], [well, updateTable])

View File

@ -48,7 +48,7 @@ export const ImportExportBar = memo(({ well: givenWell, onImported, disabled })
<Modal <Modal
title={'Импорт операций'} title={'Импорт операций'}
visible={isImportModalVisible} open={isImportModalVisible}
onCancel={() => setIsImportModalVisible(false)} onCancel={() => setIsImportModalVisible(false)}
footer={null} footer={null}
> >

View File

@ -49,8 +49,6 @@ const Well = memo(() => {
const setLayoutProps = useLayoutProps() const setLayoutProps = useLayoutProps()
useEffect(() => console.log(well), [well])
const updateWell = useCallback((data) => invokeWebApiWrapperAsync( const updateWell = useCallback((data) => invokeWebApiWrapperAsync(
async () => { async () => {
const newWell = { ...well, ...data } const newWell = { ...well, ...data }

View File

@ -109,3 +109,11 @@ tr.table_row_size {
display: none; display: none;
} }
} }
.centered {
display: flex;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
}