import { Table, Tag, Button, Badge, Divider, Modal } from "antd";
import { useParams, Link } from "react-router-dom";
import { LineChartOutlined, ProfileOutlined } from "@ant-design/icons";
import { useState, useEffect } from "react";
import {
makeTextColumn,
makeNumericColumnPlanFact
} from "../../components/Table";
import { calcAndUpdateStatsBySections, makeFilterMinMaxFunction } from "./functions";
const filtersMinMax = [
{
text: "min",
value: "min",
},
{
text: "max",
value: "max",
},
];
const filtersSectionsType = [];
const ModalWindowButton = ({
buttonIcon,
buttonText,
modalTitle,
modalContent,
}) => {
const [isModalVisible, setIsModalVisible] = useState(false);
let content =
typeof modalContent === "string" ? (
) : (
modalContent
);
return (
<>
setIsModalVisible(false)}
onCancel={() => setIsModalVisible(false)}
width={1400}
>
{content}
>
);
};
const columns = [
makeTextColumn("скв №", "caption", null, null, (_, item) => (
{item.caption}
)),
makeTextColumn("Секция", "sectionType", filtersSectionsType),
makeNumericColumnPlanFact("Глубина", "sectionWellDepth", filtersMinMax, makeFilterMinMaxFunction),
makeNumericColumnPlanFact(
"Продолжительность",
"sectionBuildDays",
filtersMinMax,
makeFilterMinMaxFunction
), //Цикл строительства
makeNumericColumnPlanFact("МСП", "sectionRateOfPenetration", filtersMinMax, makeFilterMinMaxFunction),
makeNumericColumnPlanFact(
"Рейсовая скорость",
"sectionRouteSpeed",
filtersMinMax,
makeFilterMinMaxFunction
),
makeNumericColumnPlanFact("Спуск КНБК", "sectionBhaDownSpeed", filtersMinMax, makeFilterMinMaxFunction), //Скорость спуска КНБК
makeNumericColumnPlanFact("Подъем КНБК", "sectionBhaUpSpeed", filtersMinMax, makeFilterMinMaxFunction), //Скорость подъема КНБК
makeNumericColumnPlanFact(
"Скорость спуска ОК",
"sectionCasingDownSpeed",
filtersMinMax,
makeFilterMinMaxFunction
),
makeNumericColumnPlanFact(
"НПВ, сут",
"nonProductiveTime",
filtersMinMax,
makeFilterMinMaxFunction,
"70px"
),
{
title: "TVD",
render: (_, record) => (
}
modalTitle={`График по скв.:${record.caption}`}
/>
),
//modalContent = {resources['Chart' + record.caption]}/>,
},
{
title: "Операции",
render: (_, record) => (
}
modalTitle={`Операции по скв.:${record.caption}`}
/>
),
//modalContent = {resources['Table' + record.caption]},
},
{
title: "Подрядчики",
dataIndex: "companies",
render: (item) =>
item?.map((company) => {company.caption}),
},
];
export default function ClusterSections({ clusterData }) {
let { id } = useParams();
const [wellsStat, setWellsStat] = useState([]);
const [selectedWells, setSelectedWells] = useState([]);
const [selectedWellsKeys, setSelectedWellsKeys] = useState([]);
calcAndUpdateStatsBySections(wellsStat ?? [], [
"sectionWellDepthPlan",
"sectionWellDepthFact",
"sectionBuildDaysPlan",
"sectionBuildDaysFact",
"sectionRateOfPenetrationPlan",
"sectionRateOfPenetrationFact",
"sectionRouteSpeedPlan",
"sectionRouteSpeedFact",
"sectionBhaDownSpeedPlan",
"sectionBhaDownSpeedFact",
"sectionBhaUpSpeedPlan",
"sectionBhaUpSpeedFact",
"sectionCasingDownSpeedPlan",
"sectionCasingDownSpeedFact",
"nonProductiveTimePlan",
"nonProductiveTimeFact",
]);
useEffect(() => {
let rows = [];
clusterData.statsWells?.forEach((well) => {
well.sections.forEach((section) => {
let row = {
key: well.caption + section.id,
id: well.id,
caption: well.caption,
sectionType: section.caption,
sectionWellDepthPlan: section.plan?.wellDepthEnd,
sectionWellDepthFact: section.fact?.wellDepthEnd,
sectionBuildDaysPlan: (
(new Date(section.plan?.end) - new Date(section.plan?.start)) /
(1000 * 60 * 60 * 24)
).toFixed(2),
sectionBuildDaysFact: (
(new Date(section.fact?.end) - new Date(section.fact?.start)) /
(1000 * 60 * 60 * 24)
).toFixed(2),
sectionRateOfPenetrationPlan: section.plan?.rop.toFixed(2),
sectionRateOfPenetrationFact: section.fact?.rop.toFixed(2),
sectionRouteSpeedPlan: section.plan?.routeSpeed.toFixed(2),
sectionRouteSpeedFact: section.fact?.routeSpeed.toFixed(2),
sectionBhaDownSpeedPlan: section.plan?.bhaDownSpeed.toFixed(2),
sectionBhaDownSpeedFact: section.fact?.bhaDownSpeed.toFixed(2),
sectionBhaUpSpeedPlan: section.plan?.bhaUpSpeed.toFixed(2),
sectionBhaUpSpeedFact: section.fact?.bhaUpSpeed.toFixed(2),
sectionCasingDownSpeedPlan: section.plan?.casingDownSpeed.toFixed(2),
sectionCasingDownSpeedFact: section.fact?.casingDownSpeed.toFixed(2),
nonProductiveTimePlan: section.plan?.nonProductiveHours.toFixed(2),
nonProductiveTimeFact: section.fact?.nonProductiveHours.toFixed(2),
companies: well.companies,
};
rows.push(row);
if (!filtersSectionsType.some((el) => el.text === section.caption))
filtersSectionsType.push({
text: section.caption,
value: section.caption,
});
});
});
setWellsStat(rows);
}, [id, clusterData]);
const rowSelection = {
selectedRowKeys: selectedWellsKeys,
onChange: (keys, items) => {
setSelectedWells(items);
setSelectedWellsKeys(keys);
},
};
return (
<>
Выбранные секции<>>
>
);
}