import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { ReactFlow, ReactFlowProvider } from "@xyflow/react";
import { Button, Descriptions, Divider, message, Modal, Space, Spin } from "antd";
import { useEffect, useRef, useState } from "react";
import { useReactToPrint } from "react-to-print";
import HeaderBack from "zy-react-library/components/HeaderBack";
import HiddenInfo from "zy-react-library/components/HiddenInfo/gwj";
import PreviewImg from "zy-react-library/components/PreviewImg";
import Table from "zy-react-library/components/Table";
import { UPLOAD_FILE_TYPE_ENUM } from "zy-react-library/enum/uploadFile/gwj";
import useGetFile from "zy-react-library/hooks/useGetFile";
import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery";
import useGetUserInfo from "zy-react-library/hooks/useGetUserInfo";
import { getFileUrl, getLabelName } from "zy-react-library/utils";
import { PLAN_ENUM } from "~/enumerate/constant";
import { NS_INSPECTION } from "~/enumerate/namespace";
import { getFlowData } from "~/utils/flow";
import "./index.less";
function InspectionView(props) {
const query = useGetUrlQuery();
const { loading: getFileLoading, getFile } = useGetFile();
const { getUserInfo } = useGetUserInfo();
const [info, setInfo] = useState({
inspectedPartyConfirmation: {},
currentInspectorUser: {},
content: [],
inspectorVerificationList: [],
});
const [hiddenList, setHiddenList] = useState([]);
const [hiddenViewModalOpen, setHiddenViewModalOpen] = useState(false);
const [hiddenId, setHiddenId] = useState("");
const [hiddenUUId, setHiddenUUId] = useState("");
const [flowModalOpen, setFlowModalOpen] = useState(false);
const [currentId, setCurrentId] = useState("");
const contentRef = useRef(null);
const handlePrint = useReactToPrint({
contentRef,
pageStyle: ` @page {
size: landscape;
margin: 0mm;
}
@media print {
body {
margin: 10px;
padding: 10px;
}
}
`,
documentTitle: "",
});
const getData = async () => {
const userInfo = await getUserInfo();
const { data } = await props["inspectionView"]({ inspectionId: query.id });
for (let i = 0; i < data.content.length; i++) {
const files = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM["140"],
eqForeignKey: data.content[i].contentId,
});
data.content[i].files = files;
}
data.currentInspectorUser = data.inspectorVerificationList.filter(item => item.userId === userInfo.id)[0];
setInfo(data);
const { data: hiddenList } = await props["hiddenList"]({ foreignKey: query.inspectionId, pageIndex: 1, pageSize: 999 });
setHiddenList(hiddenList);
};
useEffect(() => {
getData();
}, []);
return (
{info.subject}
现场安全检查记录
检查情况
[
{ label: "检查情况", children: item.content },
{ label: "图片", children: () },
],
).flat()
}
/>
发现问题
(
) },
]}
/>
| 序号 |
隐患描述 |
隐患部位 |
{
(hiddenList || []).map((item, index) => (
| {index + 1} |
{item.hiddenDesc} |
{item.hiddenPartName} |
))
}
检查人员审核情况
(record.signature && ) },
]}
/>
| 序号 |
审核人员 |
审核意见 |
签字 |
{
info.inspectorVerificationList.map((item, index) => (
| {index + 1} |
{item.userName} |
{item.userRemarks} |
{item.signature && } |
))
}
被检查单位现场负责人确认情况
) },
]}
/>
{query.isExport !== "0" && }
{hiddenViewModalOpen && (
{
setHiddenViewModalOpen(false);
setHiddenId("");
setHiddenUUId("");
}}
/>
)}
{flowModalOpen && (
{
setFlowModalOpen(false);
setCurrentId("");
}}
/>
)}
);
}
function HiddenViewModal(props) {
return (
取消,
]}
>
);
}
function FlowModalComponent(props) {
const [nodes, setNodes] = useState([]);
const [edges, setEdges] = useState([]);
const getData = async () => {
const { success, data } = await props["hiddenFlowchart"]({ id: props.id });
if (success) {
const { nodes, edges } = getFlowData(data.flowCOList, data.thisFlow);
setNodes(nodes);
setEdges(edges);
}
else {
message.error("获取数据失败");
props.onCancel();
}
};
useEffect(() => {
getData();
}, []);
return (
取消,
]}
>
);
}
const FlowModal = Connect([NS_INSPECTION], true)(FlowModalComponent);
export default Connect([NS_INSPECTION], true)(InspectionView);