safety-eval-service-frontend/src/pages/Container/EnterpriseInfo/index.js

61 lines
1.5 KiB
JavaScript
Raw Normal View History

2026-06-26 14:27:49 +08:00
import { message, Spin } from "antd";
import { useEffect, useState } from "react";
import {
ensureOrgContext,
isOrgInfoPage,
ORG_INFO_PAGE_PATH,
} from "~/api/enterpriseInfo/orgBootstrap";
2026-06-25 16:30:37 +08:00
2026-06-26 14:27:49 +08:00
/**
* 企业信息模块入口进入时 getInfo有机构则缓存 orgInfoId无机构则仅允许访问机构信息管理页
*/
2026-06-23 18:07:30 +08:00
function EnterpriseInfo(props) {
2026-06-26 14:27:49 +08:00
const [checking, setChecking] = useState(true);
const onOrgInfoPage = isOrgInfoPage();
2026-06-25 16:30:37 +08:00
useEffect(() => {
2026-06-26 14:27:49 +08:00
let cancelled = false;
ensureOrgContext({ force: true })
.then((ctx) => {
if (cancelled) {
return;
}
if (ctx?.networkError && onOrgInfoPage) {
message.warning("机构信息加载失败,请确认后端服务已启动");
}
if (!ctx?.hasOrg && !onOrgInfoPage) {
message.warning("请先完善机构信息");
window.location.replace(ORG_INFO_PAGE_PATH);
return;
}
setChecking(false);
})
.catch((err) => {
console.warn("[EnterpriseInfo] ensureOrgContext failed:", err);
if (!cancelled) {
if (onOrgInfoPage) {
message.warning("机构信息加载失败,请确认后端服务已启动");
}
setChecking(false);
}
});
return () => {
cancelled = true;
};
}, [onOrgInfoPage]);
if (checking) {
return <Spin fullscreen tip="正在加载机构信息..." />;
}
2026-06-25 16:30:37 +08:00
2026-06-23 18:07:30 +08:00
return (
2026-06-29 16:45:58 +08:00
<div style={{ height: "100%" }}>
2026-06-23 18:07:30 +08:00
{props.children}
</div>
);
}
export default EnterpriseInfo;