import { Button, Spin, Table } from "antd";
import { useEffect, useState } from "react";
import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
import { Get } from "@cqsjjb/jjb-common-lib/http";
import FilingTabs from "~/pages/Container/QualificationReview/FilingTabs";
const LIST_PATH = "/container/supervision/basicInfo/registeredOrg/list";
function parseQueryId(location) {
const search = location?.search || window.location.search || "";
return new URLSearchParams(search).get("id");
}
/**
* 机构基础信息详情(原型 mod-filing-detail)
* - 数据获取使用变更接口:按变更记录 id 调 GET /safetyEval/qual-filing-change/detail(5 表聚合),
* 六项 Tab 直接复用 FilingTabs(基础信息/管理人员/专职评价师/申请材料/设备清单/机构负责人签字)
* - 变更记录 Tab:GET /safetyEval/qual-filing-change/history?filingId=(filingId 取详情返回的 filingId)
* 返回 changeTime/changeItemName/operatorName/changeCount(原型「提交类型/审核状态/查看提交件」后端未返回,待补充)
* 变更时间:2026-08-10(按用户要求改用带 change 的详情接口)
*/
function RegisteredOrgDetailPage(props) {
const id = parseQueryId(props.location);
const [detail, setDetail] = useState({});
const [changes, setChanges] = useState([]);
const [loading, setLoading] = useState(Boolean(id));
useEffect(() => {
if (!id) {
setLoading(false);
return;
}
let cancelled = false;
setLoading(true);
(async () => {
try {
// 详情:变更聚合接口(QualFilingChangeAggregationCO:基础信息 + materials/equipmentList/commitment/personnelList)
const detailRes = await Get(
"/safetyEval/qual-filing-change/detail",
{ id },
{ token: sessionStorage.getItem("token") },
).catch(() => ({ data: {} }));
if (cancelled) return;
const filingId = detailRes?.data?.filingId || id;
// 变更记录:history 按原备案 filingId 查询(优先取详情返回的 filingId)
const historyRes = await Get(
"/safetyEval/qual-filing-change/history",
{ filingId },
{ token: sessionStorage.getItem("token") },
).catch(() => ({ data: {} }));
if (cancelled) return;
setDetail(detailRes?.data || {});
// 变更记录:history 返回 { changeCount, records:[{id, changeItemName, changeTime, operatorName}] }
setChanges(historyRes?.data?.records || []);
} finally {
if (!cancelled) setLoading(false);
}
})();
return () => {
cancelled = true;
};
}, [id]);
const goBack = () => {
if (props.history?.goBack && props.history.length > 1) {
props.history.goBack();
return;
}
if (props.history?.push) {
props.history.push(LIST_PATH);
return;
}
window.location.href = `/certificate${LIST_PATH}`;
};
if (!id) {
return (
缺少机构 ID 参数