Added TVD to modal window in ClusterWells table

This commit is contained in:
KharchenkoVV 2021-08-29 14:43:02 +05:00
parent e586e7ae59
commit 673fc6c4af
2 changed files with 69 additions and 11 deletions

View File

@ -1,7 +1,7 @@
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { Table, Tag, Button } from "antd"; import { Table, Tag, Button, Modal } from "antd";
import { import {
makeTextColumn, makeTextColumn,
makeGroupColumn, makeGroupColumn,
@ -9,6 +9,9 @@ import {
makeNumericColumnPlanFact, makeNumericColumnPlanFact,
calcAndUpdateStatsBySections, calcAndUpdateStatsBySections,
} from "../../components/Table"; } from "../../components/Table";
import { invokeWebApiWrapperAsync } from '../../components/factory';
import { WellOperationStatService } from '../../services/api';
import DepthToDay from '../../components/charts/DepthToDay';
const filtersMinMax = [ const filtersMinMax = [
{ {
@ -35,6 +38,43 @@ const filtersWellsType = [
export default function ClusterWells({ clusterData }) { export default function ClusterWells({ clusterData }) {
let { id } = useParams(); let { id } = useParams();
const [wellsStat, setWellsStat] = useState([]); const [wellsStat, setWellsStat] = useState([]);
const [selectedWellId, setSelectedWellId] = useState(0);
const [isModalVisible, setIsModalVisible] = useState(false)
const [dataPlan, setDataPlan] = useState([]);
const [dataFact, setDataFact] = useState([]);
const [dataForecast, setDataForecast] = useState([]);
useEffect(() => {
invokeWebApiWrapperAsync(
async () => {
const operations = await WellOperationStatService.getTvd(selectedWellId);
const planData = operations.map(el => {
return {key: el.plan?.id, depth: el.plan?.wellDepth, date: el.plan?.startDate}
}).filter(el => el.key)
setDataPlan(planData)
const factData = operations.map(el => {
return {key: el.fact?.id, depth: el.fact?.wellDepth, date: el.fact?.startDate}
}).filter(el => el.key)
setDataFact(factData)
const predictData = operations.map(el => {
return {key: el.predict?.id, depth: el.predict?.wellDepth, date: el.predict?.startDate}
}).filter(el => el.key)
setDataForecast(predictData)
},
null,
`Не удалось загрузить операции по скважине "${selectedWellId}"`,
);
}, [selectedWellId]);
const closeModal = () => {
setIsModalVisible(false)
}
calcAndUpdateStatsBySections(wellsStat ?? [], [ calcAndUpdateStatsBySections(wellsStat ?? [], [
"factStart", "factStart",
@ -97,7 +137,10 @@ export default function ClusterWells({ clusterData }) {
makeNumericColumnPlanFact("НПВ, сут", "notProductiveTime", filtersMinMax), makeNumericColumnPlanFact("НПВ, сут", "notProductiveTime", filtersMinMax),
{ {
title: "График глубина-день", title: "График глубина-день",
render: (_, item) => <Button>Открыть</Button>, render: (_, item) => <Button onClick={()=> {
setIsModalVisible(true)
setSelectedWellId(_.id)
}}>Открыть</Button>,
}, },
{ {
title: "Таблица по операциям", title: "Таблица по операциям",
@ -113,6 +156,7 @@ export default function ClusterWells({ clusterData }) {
]; ];
return ( return (
<div>
<Table <Table
columns={columns} columns={columns}
dataSource={wellsStat} dataSource={wellsStat}
@ -121,5 +165,20 @@ export default function ClusterWells({ clusterData }) {
pagination={false} pagination={false}
rowKey={(record) => record.id} rowKey={(record) => record.id}
/> />
<Modal
title='Modal'
centered
visible={isModalVisible}
onOk={closeModal}
onCancel={closeModal}
width={800}
>
<DepthToDay
dataPlan={dataPlan}
dataFact={dataFact}
dataForecast={dataForecast} />
</Modal>
</div>
); );
} }

View File

@ -40,7 +40,6 @@ export const TVD = ({ idWell }) => {
<div> <div>
<h2 className={'mt-20px'}>График Глубина-день</h2> <h2 className={'mt-20px'}>График Глубина-день</h2>
<DepthToDay <DepthToDay
idWell={idWell}
dataPlan={dataPlan} dataPlan={dataPlan}
dataFact={dataFact} dataFact={dataFact}
dataForecast={dataForecast} /> dataForecast={dataForecast} />