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

106 lines
4.0 KiB
JavaScript
Raw Normal View History

import { AnimatePresence, motion } from "motion/react";
2026-01-15 18:01:40 +08:00
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";
import "./index.less";
// 标题切换时先让旧标题离开,再让新标题进入,保留原来的上下滑动和淡入淡出效果。
const headerAnimation = {
initial: { y: -100, opacity: 0 },
animate: { y: 0, opacity: 1, transition: { duration: 0.5, ease: "easeOut" } },
exit: { y: -100, opacity: 0, transition: { duration: 0.3, ease: "easeIn" } },
};
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);
const isPortTitle = 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">
<AnimatePresence mode="wait">
<motion.header
key={props.headerTitle}
{...headerAnimation}
className={isPortTitle ? "port" : "branch_office"}
style={{ backgroundImage: `url(${isPortTitle ? topImg1 : topImg2})` }}
>
{isPortTitle
? <div style={{ backgroundImage: `url(${backImg1})` }} className="back" onClick={onBack} />
: (
<div className="back" onClick={onBack}>
<img src={backImg2} alt="" />
<div>返回</div>
</div>
)}
<div className="title">{props.headerTitle}</div>
<div style={{ backgroundImage: `url(${guangImg})` }} className="guang" />
</motion.header>
</AnimatePresence>
2026-01-05 14:53:49 +08:00
</div>
);
}
export default Header;