zcloud-gbs-bi-react/src/pages/Container/Map/components/Content/index.js

171 lines
7.0 KiB
JavaScript
Raw Normal View History

2026-01-08 14:57:25 +08:00
import { useContext, useState } from "react";
2026-01-07 16:38:01 +08:00
import collapseMenuImg1 from "~/assets/images/map_bi/content/collapse_menu1.png";
import collapseMenuImg2 from "~/assets/images/map_bi/content/collapse_menu2.png";
import collapseMenuBg1 from "~/assets/images/map_bi/content/collapse_menu_bg1.png";
import collapseMenuBg2 from "~/assets/images/map_bi/content/collapse_menu_bg2.png";
import { branchOfficeUtilsList } from "~/pages/Container/Map/components/BottomUtils/branchOfficeUtilsList";
2026-01-06 13:33:01 +08:00
import { portUtilsList } from "~/pages/Container/Map/components/BottomUtils/portUtilsList";
2026-01-14 14:56:00 +08:00
import BranchCamera from "~/pages/Container/Map/components/Content/branchOffice/Camera";
2026-01-09 16:40:53 +08:00
import BranchFengBi from "~/pages/Container/Map/components/Content/branchOffice/FengBi";
2026-01-08 14:57:25 +08:00
import BranchOfficeIndexLeft from "~/pages/Container/Map/components/Content/branchOffice/IndexLeft";
import BranchOfficeIndexRight from "~/pages/Container/Map/components/Content/branchOffice/IndexRight";
2026-01-09 09:10:49 +08:00
import BranchMenJin from "~/pages/Container/Map/components/Content/branchOffice/MenJin";
2026-01-09 14:48:39 +08:00
import BranchQiXiang from "~/pages/Container/Map/components/Content/branchOffice/QiXiang";
2026-01-09 11:41:52 +08:00
import BranchRenYuan from "~/pages/Container/Map/components/Content/branchOffice/RenYuan";
2026-01-08 16:12:58 +08:00
import BranchWeiXian from "~/pages/Container/Map/components/Content/branchOffice/WeiXian";
2026-01-09 10:30:14 +08:00
import BranchXiaoFang from "~/pages/Container/Map/components/Content/branchOffice/XiaoFang";
2026-01-09 16:16:01 +08:00
import BranchZhongDian from "~/pages/Container/Map/components/Content/branchOffice/ZhongDian";
2026-01-07 16:38:01 +08:00
import IndexInfo from "~/pages/Container/Map/components/Content/IndexInfo";
2026-01-07 14:03:14 +08:00
import PortFengBi from "~/pages/Container/Map/components/Content/port/FengBi";
2026-01-07 16:38:01 +08:00
import PortIndex from "~/pages/Container/Map/components/Content/port/Index";
2026-01-07 14:03:14 +08:00
import PortMenJin from "~/pages/Container/Map/components/Content/port/MenJin";
import PortQiXiang from "~/pages/Container/Map/components/Content/port/QiXiang";
import PortRenYuan from "~/pages/Container/Map/components/Content/port/RenYuan";
import PortWeiXian from "~/pages/Container/Map/components/Content/port/WeiXian";
import PortXiaoFang from "~/pages/Container/Map/components/Content/port/XiaoFang";
import PortZhongDian from "~/pages/Container/Map/components/Content/port/ZhongDian";
2026-01-05 14:53:49 +08:00
import { Context } from "~/pages/Container/Map/js/context";
import "./index.less";
function Content() {
const { currentPort, currentBranchOffice, pureMap, bottomUtilsCurrentIndex } = useContext(Context);
2026-01-08 14:57:25 +08:00
const [collapseLeft, setCollapseLeft] = useState(false);
const [collapseRight, setCollapseRight] = useState(false);
2026-01-05 14:53:49 +08:00
const renderPortContent = () => {
2026-01-07 16:38:01 +08:00
const bottomUtilsCurrentType = bottomUtilsCurrentIndex !== -1 ? portUtilsList[bottomUtilsCurrentIndex].type : "";
if (bottomUtilsCurrentType === "" || bottomUtilsCurrentType === "camera")
return <PortIndex />;
if (bottomUtilsCurrentType === "door")
return <PortMenJin />;
if (bottomUtilsCurrentType === "fire")
return <PortXiaoFang />;
if (bottomUtilsCurrentType === "danger")
return <PortWeiXian />;
if (bottomUtilsCurrentType === "weather")
return <PortQiXiang />;
if (bottomUtilsCurrentType === "people")
return <PortRenYuan />;
if (bottomUtilsCurrentType === "project")
return <PortZhongDian />;
if (bottomUtilsCurrentType === "closedArea")
return <PortFengBi />;
};
2026-01-08 14:57:25 +08:00
const renderBranchOfficeContentLeft = () => {
const bottomUtilsCurrentType = bottomUtilsCurrentIndex !== -1 ? branchOfficeUtilsList[bottomUtilsCurrentIndex].type : "";
2026-01-08 16:12:58 +08:00
if (bottomUtilsCurrentType === "")
2026-01-08 14:57:25 +08:00
return <BranchOfficeIndexLeft />;
2026-01-08 16:12:58 +08:00
if (bottomUtilsCurrentType === "danger")
return <BranchWeiXian />;
2026-01-09 09:10:49 +08:00
if (bottomUtilsCurrentType === "door")
return <BranchMenJin />;
2026-01-09 10:30:14 +08:00
if (bottomUtilsCurrentType === "fire")
return <BranchXiaoFang />;
2026-01-09 11:41:52 +08:00
if (bottomUtilsCurrentType === "people")
return <BranchRenYuan />;
2026-01-09 14:48:39 +08:00
if (bottomUtilsCurrentType === "weather")
return <BranchQiXiang />;
2026-01-09 16:16:01 +08:00
if (bottomUtilsCurrentType === "project")
return <BranchZhongDian />;
2026-01-09 16:40:53 +08:00
if (bottomUtilsCurrentType === "closedArea")
return <BranchFengBi />;
2026-01-14 14:56:00 +08:00
if (bottomUtilsCurrentType === "camera")
return <BranchCamera />;
2026-01-08 14:57:25 +08:00
};
const renderBranchOfficeContentRight = () => {
2026-01-07 16:38:01 +08:00
const bottomUtilsCurrentType = bottomUtilsCurrentIndex !== -1 ? branchOfficeUtilsList[bottomUtilsCurrentIndex].type : "";
2026-01-08 16:12:58 +08:00
if (bottomUtilsCurrentType === "")
2026-01-08 14:57:25 +08:00
return <BranchOfficeIndexRight />;
2026-01-05 14:53:49 +08:00
};
const renderContent = () => {
2026-01-08 14:57:25 +08:00
if (pureMap)
2026-01-07 13:51:33 +08:00
return null;
2026-01-05 14:53:49 +08:00
return (
2026-01-08 14:57:25 +08:00
<>
{!collapseLeft && (
<div
className={`map_content_container__content ${(!currentPort || (currentPort === "00003" && !currentBranchOffice)) ? "port" : "branch_office"}`}
style={{ left: 35 }}
>
{!currentPort && <IndexInfo />}
{(currentPort === "00003" && !currentBranchOffice) && renderPortContent()}
{currentBranchOffice && renderBranchOfficeContentLeft()}
</div>
)}
{!collapseRight && (
<div
className={`map_content_container__content ${(!currentPort || (currentPort === "00003" && !currentBranchOffice)) ? "port" : "branch_office"}`}
style={{ right: 35 }}
>
{currentBranchOffice && renderBranchOfficeContentRight()}
</div>
)}
</>
2026-01-05 14:53:49 +08:00
);
};
2026-01-07 13:51:33 +08:00
const renderCollapseMenu = () => {
if (pureMap)
return null;
2026-01-08 14:57:25 +08:00
2026-01-07 16:38:01 +08:00
if (currentPort === "00003" && !currentBranchOffice) {
return (
<div
2026-01-08 14:57:25 +08:00
className={`collapse_menu port left ${collapseLeft ? "active" : ""}`}
2026-01-07 16:38:01 +08:00
style={{ backgroundImage: `url(${collapseMenuBg1})` }}
2026-01-08 14:57:25 +08:00
onClick={() => {
setCollapseLeft(!collapseLeft);
}}
2026-01-07 16:38:01 +08:00
>
<img src={collapseMenuImg1} alt="" />
</div>
);
}
2026-01-08 14:57:25 +08:00
2026-01-07 16:38:01 +08:00
if (currentBranchOffice) {
2026-01-14 14:56:00 +08:00
const bottomUtilsCurrentType = bottomUtilsCurrentIndex !== -1 ? branchOfficeUtilsList[bottomUtilsCurrentIndex].type : "";
2026-01-07 13:51:33 +08:00
return (
2026-01-08 14:57:25 +08:00
<>
2026-01-14 14:56:00 +08:00
{bottomUtilsCurrentType !== "camera" && (
<div
className={`collapse_menu branch_office left ${collapseLeft ? "active" : ""}`}
style={{ backgroundImage: `url(${collapseMenuBg2})` }}
onClick={() => {
setCollapseLeft(!collapseLeft);
}}
>
<img src={collapseMenuImg2} alt="" />
</div>
)}
2026-01-08 14:57:25 +08:00
{bottomUtilsCurrentIndex === -1 && (
<div
className={`collapse_menu branch_office right ${collapseRight ? "active" : ""}`}
style={{ backgroundImage: `url(${collapseMenuBg2})` }}
onClick={() => {
setCollapseRight(!collapseRight);
}}
>
<img src={collapseMenuImg2} alt="" />
</div>
)}
</>
2026-01-07 13:51:33 +08:00
);
}
};
2026-01-05 14:53:49 +08:00
return (
<div className="map_content_container">
2026-01-08 14:57:25 +08:00
{renderContent()}
{renderCollapseMenu()}
2026-01-05 14:53:49 +08:00
</div>
);
}
export default Content;