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

98 lines
3.7 KiB
JavaScript
Raw Normal View History

2026-01-15 18:01:40 +08:00
import { motion } from "motion/react";
import { useContext } from "react";
2026-01-07 16:38:01 +08:00
import backImg1 from "~/assets/images/map_bi/back1.png";
import backImg2 from "~/assets/images/map_bi/back2.png";
2026-01-05 14:53:49 +08:00
import guangImg from "~/assets/images/map_bi/guang.png";
2026-01-07 16:38:01 +08:00
import topImg1 from "~/assets/images/map_bi/top1.png";
import topImg2 from "~/assets/images/map_bi/top2.png";
2026-01-05 14:53:49 +08:00
import { Context } from "~/pages/Container/Map/js/context";
import mitt from "~/pages/Container/Map/js/mitt";
import {
changePeopleTrajectorySelectVisibleMittKey,
clickBackMittKey,
clickBranchOfficePointMittKey,
clickPortPointMittKey,
deletePeoplePositionPointMittKey,
resetAllBottomUtilsCheckMittKey,
resetBottomCurrentIndexMittKey,
} from "~/pages/Container/Map/js/mittKey";
2026-01-15 18:01:40 +08:00
import { useHeaderAnimation } from "./useHeaderAnimation";
2026-01-05 14:53:49 +08:00
import "./index.less";
2026-01-07 16:38:01 +08:00
function Header(props) {
2026-01-05 14:53:49 +08:00
const { currentPort, currentBranchOffice, mapMethods, area } = useContext(Context);
2026-01-15 18:01:40 +08:00
const { controls, displayedTitle } = useHeaderAnimation(props.headerTitle);
2026-01-12 16:51:34 +08:00
2026-01-05 14:53:49 +08:00
const onBack = () => {
2026-01-07 16:38:01 +08:00
sessionStorage.removeItem("mapCurrentBranchOfficeId");
2026-01-05 14:53:49 +08:00
mitt.emit(deletePeoplePositionPointMittKey);
2026-01-19 14:09:05 +08:00
if (!currentPort) {
window.close();
setTimeout(() => {
if (!window.closed && !window.opener) {
window.location.href = "https://gbs-gateway.qhdsafety.com/";
}
}, 500);
}
else if (currentPort !== "00003" && currentBranchOffice) {
2026-01-07 16:38:01 +08:00
mitt.emit(clickPortPointMittKey, { id: "", name: "秦港股份" });
mitt.emit(clickBranchOfficePointMittKey, { id: "", corpName: "秦港股份" });
2026-01-05 14:53:49 +08:00
mapMethods.current.removeWall();
mapMethods.current.removeFourColorDiagram();
mapMethods.current.removeBranchOfficePoint();
mapMethods.current.removeMarkPoint();
mapMethods.current.flyTo();
mapMethods.current.addPortPoint();
}
else if (currentBranchOffice) {
2026-01-07 16:38:01 +08:00
mitt.emit(clickBranchOfficePointMittKey, { id: "", corpName: "秦港股份" });
2026-01-05 14:53:49 +08:00
mapMethods.current.removeBranchOfficePoint();
mapMethods.current.removeMarkPoint();
mapMethods.current.returnPreviousCenterPoint();
2026-01-15 18:01:40 +08:00
mapMethods.current.removeFourColorDiagram();
mapMethods.current.removeWall();
2026-01-12 16:51:34 +08:00
// setTimeout(() => {
mapMethods.current.addBranchOfficePoint(area);
// }, 2000);
2026-01-05 14:53:49 +08:00
}
else if (currentPort) {
2026-01-07 16:38:01 +08:00
mitt.emit(clickPortPointMittKey, { id: "", name: "秦港股份" });
2026-01-05 14:53:49 +08:00
mapMethods.current.removeWall();
mapMethods.current.removeFourColorDiagram();
mapMethods.current.removeBranchOfficePoint();
mapMethods.current.removeMarkPoint();
mapMethods.current.flyTo();
mapMethods.current.addPortPoint();
}
mitt.emit(resetBottomCurrentIndexMittKey);
mitt.emit(resetAllBottomUtilsCheckMittKey);
mitt.emit(clickBackMittKey);
mitt.emit(changePeopleTrajectorySelectVisibleMittKey, false);
};
return (
2026-01-08 11:27:19 +08:00
<div className="map_content_header_container">
2026-01-15 18:01:40 +08:00
<motion.header
animate={controls}
className={`${displayedTitle === "秦港股份安全监管平台" ? "port" : "branch_office"}`}
style={{ backgroundImage: `url(${displayedTitle === "秦港股份安全监管平台" ? topImg1 : topImg2})` }}
2026-01-08 14:57:25 +08:00
>
2026-01-19 14:09:05 +08:00
{(displayedTitle === "秦港股份安全监管平台") && (
2026-01-15 18:01:40 +08:00
<div style={{ backgroundImage: `url(${backImg1})` }} className="back" onClick={onBack} />
)}
{displayedTitle !== "秦港股份安全监管平台" && (
<div className="back" onClick={onBack}>
<img src={backImg2} alt="" />
<div>返回</div>
</div>
)}
<div className="title">{displayedTitle}</div>
<div style={{ backgroundImage: `url(${guangImg})` }} className="guang" />
</motion.header>
2026-01-05 14:53:49 +08:00
</div>
);
}
export default Header;