Добавлено модальное окно для участников на страницах "Анализ скважин куста", "Мониторинг"

This commit is contained in:
ts_salikhov 2022-08-12 14:35:57 +04:00
parent 423e575483
commit 0148fed514
3 changed files with 33 additions and 23 deletions

View File

@ -1,6 +1,6 @@
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 } from 'react'
import { LineChartOutlined, ProfileOutlined } 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, Tag, Button, Badge, Divider, Modal, Row, Col } from 'antd'
import { useIdWell } from '@asb/context' import { useIdWell } from '@asb/context'
@ -20,6 +20,7 @@ import {
import Tvd from '@pages/WellOperations/Tvd' import Tvd from '@pages/WellOperations/Tvd'
import WellOperationsTable from '@pages/Cluster/WellOperationsTable' import WellOperationsTable from '@pages/Cluster/WellOperationsTable'
import NewParamsTable from './NewParamsTable' import NewParamsTable from './NewParamsTable'
import CompaniesTable from "@pages/Cluster/CompaniesTable";
const filtersMinMax = [ const filtersMinMax = [
{ text: 'min', value: 'min' }, { text: 'min', value: 'min' },
@ -34,11 +35,13 @@ const DAY_IN_MS = 1000 * 60 * 60 * 24
const WellCompositeSections = memo(({ statsWells, selectedSections }) => { const WellCompositeSections = memo(({ statsWells, selectedSections }) => {
const [selectedWells, setSelectedWells] = useState([]) const [selectedWells, setSelectedWells] = useState([])
const [wellOperations, setWellOperations] = useState([]) const [wellOperations, setWellOperations] = useState([])
const [companies, setCompanies] = useState([])
const [selectedWellsKeys, setSelectedWellsKeys] = useState([]) const [selectedWellsKeys, setSelectedWellsKeys] = useState([])
const [selectedWellId, setSelectedWellId] = useState(0) const [selectedWellId, setSelectedWellId] = useState(0)
const [showLoader, setShowLoader] = useState(false) const [showLoader, setShowLoader] = useState(false)
const [isTVDModalVisible, setIsTVDModalVisible] = useState(false) const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
const [isOpsModalVisible, setIsOpsModalVisible] = useState(false) const [isOpsModalVisible, setIsOpsModalVisible] = useState(false)
const [isCompaniesModalVisible, setIsCompaniesModalVisible] = useState(false)
const idWell = useIdWell() const idWell = useIdWell()
@ -177,11 +180,14 @@ const WellCompositeSections = memo(({ statsWells, selectedSections }) => {
{ {
title: 'Участники', title: 'Участники',
dataIndex: 'companies', dataIndex: 'companies',
render: (item) => item?.map((company) => ( render: (value) => {
<Tag key={company.caption} color={'blue'}> return <Button onClick={() => {
<CompanyView company={company} /> setCompanies(value)
</Tag> setIsCompaniesModalVisible(true)
)) ?? '-', }}>
<TeamOutlined/>
</Button>
},
}, },
], [location.pathname]) ], [location.pathname])
@ -236,6 +242,19 @@ const WellCompositeSections = memo(({ statsWells, selectedSections }) => {
<WellOperationsTable wellOperations={wellOperations} /> <WellOperationsTable wellOperations={wellOperations} />
</LoaderPortal> </LoaderPortal>
</Modal> </Modal>
<Modal
title={'Участники'}
centered
visible={isCompaniesModalVisible}
onCancel={() => setIsCompaniesModalVisible(false)}
width={1500}
footer={null}
>
<LoaderPortal show={showLoader}>
<CompaniesTable companies={companies} />
</LoaderPortal>
</Modal>
</> </>
) )
}) })

View File

@ -69,17 +69,6 @@ const ClusterWells = memo(({ statsWells }) => {
) )
}, [selectedWellId, isOpsModalVisible]) }, [selectedWellId, isOpsModalVisible])
useEffect(() => {
if (!isCompaniesModalVisible || selectedWellId <= 0) {
setCompanies([])
return
}
const selectedCompanies = statsWells.find(well => well.id === selectedWellId)?.companies;
setCompanies(selectedCompanies ? selectedCompanies : []);
}, [selectedWellId, isCompaniesModalVisible])
useEffect(() => { useEffect(() => {
let data = statsWells?.map((well) => { let data = statsWells?.map((well) => {
if (!filtersWellsType.some((el) => el.text === well.wellType)) if (!filtersWellsType.some((el) => el.text === well.wellType))
@ -154,8 +143,11 @@ const ClusterWells = memo(({ statsWells }) => {
makeColumn('Операции', 'operations', { align: 'center', render: (_, value) => ( makeColumn('Операции', 'operations', { align: 'center', render: (_, value) => (
<Button onClick={() => { setSelectedWellId(value?.id); setIsOpsModalVisible(true) }} children={<ProfileOutlined />} /> <Button onClick={() => { setSelectedWellId(value?.id); setIsOpsModalVisible(true) }} children={<ProfileOutlined />} />
) }), ) }),
makeColumn('Участники', 'companies', { align: 'center', render: (_, value) => ( makeColumn('Участники', 'companies', { align: 'center', render: (value) => (
<Button onClick={() => { setSelectedWellId(value?.id); setIsCompaniesModalVisible(true) }} children={<TeamOutlined />} /> <Button onClick={() => {
setCompanies(value);
setIsCompaniesModalVisible(true);
}} children={<TeamOutlined />} />
) }), ) }),
], [location.pathname]) ], [location.pathname])

View File

@ -1,4 +1,4 @@
import React, {memo} from 'react'; import React, {memo, useMemo} from 'react';
import {makeTextColumn} from "@components/Table"; import {makeTextColumn} from "@components/Table";
import {Table} from "antd"; import {Table} from "antd";
@ -8,12 +8,11 @@ const columns = [
] ]
const CompaniesTable = memo(({companies}) => { const CompaniesTable = memo(({companies}) => {
console.log(companies) const dataCompanies = useMemo(() => companies?.map((company) => ({
const dataCompanies = companies?.map((company) => ({
key: company.id, key: company.id,
caption: company.caption, caption: company.caption,
companyTypeCaption: company.companyTypeCaption, companyTypeCaption: company.companyTypeCaption,
})); })), [companies]);
return ( return (
<Table <Table