Added Well operations modal window to Cluster info table

This commit is contained in:
KharchenkoVV 2021-08-31 11:14:35 +05:00
parent a7293f616b
commit 6795b6c936
2 changed files with 90 additions and 26 deletions

View File

@ -12,6 +12,7 @@ import { calcAndUpdateStatsBySections, makeFilterMinMaxFunction } from "./functi
import { invokeWebApiWrapperAsync } from '../../components/factory'; import { invokeWebApiWrapperAsync } from '../../components/factory';
import { WellOperationStatService } from '../../services/api'; import { WellOperationStatService } from '../../services/api';
import ChartDepthToDay from '../../components/charts/ChartDepthToDay'; import ChartDepthToDay from '../../components/charts/ChartDepthToDay';
import WellOperationsTable from './WellOperationsTable'
const filtersMinMax = [ const filtersMinMax = [
{ {
@ -38,35 +39,39 @@ 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 [selectedWellId, setSelectedWellId] = useState([]);
const [isModalVisible, setIsModalVisible] = useState(false) const [isTVDModalVisible, setIsTVDModalVisible] = useState(false)
const [dataPlan, setDataPlan] = useState([]); const [isOpsModalVisible, setIsOpsModalVisible] = useState(false)
const [dataFact, setDataFact] = useState([]); const [tvdDataPlan, setTvdDataPlan] = useState([]);
const [dataForecast, setDataForecast] = useState([]); const [tvdDataFact, setTvdDataFact] = useState([]);
const [tvdDataForecast, setTvdDataForecast] = useState([]);
const [wellOperations, setWellOperations] = useState([]);
useEffect(() => { useEffect(() => {
if (selectedWellId > 0) { if (selectedWellId > 0) {
invokeWebApiWrapperAsync( invokeWebApiWrapperAsync(
async () => { async () => {
const operations = await WellOperationStatService.getTvd(selectedWellId); const operations = await WellOperationStatService.getTvd(selectedWellId);
const planData = operations.map(el => { setWellOperations(operations)
const tvdPlanData = operations.map(el => {
return {key: el.plan?.id, depth: el.plan?.wellDepth, date: el.plan?.startDate} return {key: el.plan?.id, depth: el.plan?.wellDepth, date: el.plan?.startDate}
}).filter(el => el.key) }).filter(el => el.key)
setTvdDataPlan(tvdPlanData)
setDataPlan(planData) const tvdFactData = operations.map(el => {
const factData = operations.map(el => {
return {key: el.fact?.id, depth: el.fact?.wellDepth, date: el.fact?.startDate} return {key: el.fact?.id, depth: el.fact?.wellDepth, date: el.fact?.startDate}
}).filter(el => el.key) }).filter(el => el.key)
setDataFact(factData) setTvdDataFact(tvdFactData)
const predictData = operations.map(el => { const tvdPredictData = operations.map(el => {
return {key: el.predict?.id, depth: el.predict?.wellDepth, date: el.predict?.startDate} return {key: el.predict?.id, depth: el.predict?.wellDepth, date: el.predict?.startDate}
}).filter(el => el.key) }).filter(el => el.key)
setDataForecast(predictData) setTvdDataForecast(tvdPredictData)
}, },
null, null,
`Не удалось загрузить операции по скважине "${selectedWellId}"`, `Не удалось загрузить операции по скважине "${selectedWellId}"`,
@ -131,14 +136,17 @@ export default function ClusterWells({ clusterData }) {
makeNumericColumnPlanFact("НПВ, сут", "notProductiveTime", filtersMinMax, makeFilterMinMaxFunction), makeNumericColumnPlanFact("НПВ, сут", "notProductiveTime", filtersMinMax, makeFilterMinMaxFunction),
{ {
title: "График глубина-день", title: "График глубина-день",
render: (_, item) => <Button onClick={()=> { render: (value) => <Button onClick={()=> {
setIsModalVisible(true) setSelectedWellId(value.id)
setSelectedWellId(_.id) setIsTVDModalVisible(true)
}}>Открыть</Button>, }}>Открыть</Button>,
}, },
{ {
title: "Таблица по операциям", title: "Таблица по операциям",
render: (_) => <Button>Открыть</Button>, render: (value) => <Button onClick={()=> {
setSelectedWellId(value.id)
setIsOpsModalVisible(true)
}}>Открыть</Button>,
}, },
{ {
title: "Подрядчики", title: "Подрядчики",
@ -161,17 +169,30 @@ export default function ClusterWells({ clusterData }) {
/> />
<Modal <Modal
title='TVD' title='TVD'
centered centered
visible={isModalVisible} visible={isTVDModalVisible}
onCancel={() => setIsModalVisible(false)} onCancel={() => setIsTVDModalVisible(false)}
width={1500} width={1500}
footer={null} footer={null}
> >
<ChartDepthToDay <ChartDepthToDay
dataPlan={dataPlan} dataPlan={tvdDataPlan}
dataFact={dataFact} dataFact={tvdDataFact}
dataForecast={dataForecast} /> dataForecast={tvdDataForecast} />
</Modal>
<Modal
title='Операции'
centered
visible={isOpsModalVisible}
onCancel={() => setIsOpsModalVisible(false)}
width={1500}
footer={null}
>
<WellOperationsTable
wellOperations={wellOperations}
/>
</Modal> </Modal>
</div> </div>
); );

View File

@ -0,0 +1,43 @@
import { Table } from "antd";
import {
makeTextColumn,
makeNumericColumnPlanFact
} from "../../components/Table"
export default function WellOperationsTable({wellOperations}) {
const columns = [
makeTextColumn("","index"),
makeTextColumn("Конструкция секции","sectionType"),
makeTextColumn("Операция","operationName"),
makeNumericColumnPlanFact("Глубина забоя", "depth"),
makeNumericColumnPlanFact("Часы", "durationHours")
];
let i = 1;
const operations = wellOperations.map(el => {
return {
key: el.plan ? el.plan.id : el.fact.id,
index: i++,
sectionType: el.plan ? el.plan.wellSectionTypeName : el.fact.wellSectionTypeName,
operationName: el.plan ? el.plan.categoryName : el.fact.categoryName,
depthPlan: el.plan ? el.plan.wellDepth : '-',
depthFact: el.fact ? el.fact.wellDepth : '-',
durationHoursPlan: el.plan ? el.plan.durationHours : '-',
durationHoursFact: el.fact ? el.fact.durationHours : '-'
}
})
return(
<Table
columns={columns}
dataSource={operations}
size={"small"}
bordered
pagination={false}
rowKey={(record) => record.id}
/>
)
}