zy-react-library/src/components/HiddenInfo/gwj/index.js

532 lines
24 KiB
JavaScript
Raw Normal View History

2026-01-06 15:24:18 +08:00
import { request } from "@cqsjjb/jjb-common-lib/http.js";
2025-11-18 16:39:36 +08:00
import { Button, Descriptions, Divider, Space, Spin } from "antd";
2025-11-07 10:21:02 +08:00
import dayjs from "dayjs";
import { useEffect, useState } from "react";
2025-12-18 09:24:47 +08:00
import { HIDDEN_RECTIFICATION_TYPE_ENUM, HIDDEN_SOURCE_ENUM, HIDDEN_STATE_ENUM } from "../../../enum/hidden/gwj";
import { UPLOAD_FILE_TYPE_ENUM } from "../../../enum/uploadFile/gwj";
import useDownloadFile from "../../../hooks/useDownloadFile";
import useGetFile from "../../../hooks/useGetFile";
import useGetUrlQuery from "../../../hooks/useGetUrlQuery";
import { getFileName, getFileSuffix, getLabelName } from "../../../utils";
import VideoIcon from "../../Icon/VideoIcon";
import PreviewImg from "../../PreviewImg";
import PreviewPdf from "../../PreviewPdf";
import Video from "../../Video";
2025-11-07 10:21:02 +08:00
/**
* 隐患查看组件港务局版本
*/
function HiddenInfo(props) {
const {
id = "",
idKey = "id",
hiddenId = "",
hiddenIdKey = "hiddenId",
history = false,
2025-11-07 15:58:38 +08:00
onGetData,
2025-11-07 10:21:02 +08:00
} = props;
const [info, setInfo] = useState({
hiddenUserPresetsCO: {},
hiddenRectifyUserCO: [],
hiddenConfirmUserCO: [],
hiddenAcceptUserCO: [],
2025-12-26 11:49:38 +08:00
hiddenAcceptQualifiedUserCO: [],
hiddenAcceptUnqualifiedUserCO: [],
hiddenInspecCO: {},
2025-11-07 10:21:02 +08:00
hiddenSpecialList: [],
hiddenExtensionList: [],
});
const [hiddenImageFiles, setHiddenImageFiles] = useState([]);
const [hiddenVideoFiles, setHiddenVideoFiles] = useState([]);
const [afterRectificationImageFiles, setAfterRectificationImageFiles] = useState([]);
const [rectificationPlanImageFiles, setRectificationPlanImageFiles] = useState([]);
const [acceptImageFiles, setAcceptImageFiles] = useState([]);
const [inspectionAcceptImageFiles, setInspectionAcceptImageFiles] = useState([]);
const [loading, setLoading] = useState(true);
2025-12-03 09:55:18 +08:00
const [videoModalOpen, setVideoModalOpen] = useState(false);
2025-11-07 10:21:02 +08:00
const { getFile } = useGetFile();
2025-11-07 10:50:13 +08:00
const query = useGetUrlQuery();
2025-11-08 15:52:06 +08:00
const { loading: downloadFileLoading, downloadFile } = useDownloadFile();
2025-11-07 10:21:02 +08:00
2025-11-18 16:43:27 +08:00
const getFileData = async (info) => {
const hiddenImageFiles = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM["3"],
eqForeignKey: hiddenId || query[hiddenIdKey],
});
2025-11-07 10:21:02 +08:00
setHiddenImageFiles(hiddenImageFiles);
const hiddenVideoFiles = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM["102"],
eqForeignKey: hiddenId || query[hiddenIdKey],
});
2025-11-07 10:21:02 +08:00
setHiddenVideoFiles(hiddenVideoFiles);
2025-11-18 16:39:36 +08:00
if (info.hiddenRectifyUserCO && info.hiddenRectifyUserCO.length > 0) {
for (let i = 0; i < info.hiddenRectifyUserCO.length; i++) {
2025-12-22 13:38:31 +08:00
if (info.hiddenRectifyUserCO[i].hiddenUserId) {
const afterRectificationImageFiles = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM["4"],
eqForeignKey: info.hiddenRectifyUserCO[i].hiddenUserId,
});
2025-12-22 13:38:31 +08:00
setAfterRectificationImageFiles(prevState => [...prevState, afterRectificationImageFiles]);
}
if (info.hiddenRectifyUserCO[i].isRectificationScheme === 1 && info.hiddenRectifyUserCO[i].hiddenSchemeCO && Object.keys(info.hiddenRectifyUserCO[i].hiddenSchemeCO).length > 0) {
if (info.hiddenRectifyUserCO[i].hiddenSchemeCO.hiddenSchemeId) {
const rectificationPlanImageFiles = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM["8"],
eqForeignKey: info.hiddenRectifyUserCO[i].hiddenSchemeCO.hiddenSchemeId,
});
setRectificationPlanImageFiles(prevState => [...prevState, rectificationPlanImageFiles]);
}
}
2025-11-18 16:39:36 +08:00
}
}
2025-12-26 12:46:24 +08:00
if (info.hiddenAcceptQualifiedUserCO && info.hiddenAcceptQualifiedUserCO.length > 0) {
for (let i = 0; i < info.hiddenAcceptQualifiedUserCO.length; i++) {
if (info.hiddenAcceptQualifiedUserCO[i].hiddenUserId) {
2025-12-26 11:49:38 +08:00
const acceptImageFiles = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM["5"],
2025-12-26 12:46:24 +08:00
eqForeignKey: info.hiddenAcceptQualifiedUserCO[i].hiddenUserId,
2025-12-26 11:49:38 +08:00
});
setAcceptImageFiles(prevState => [...prevState, acceptImageFiles]);
}
}
2025-11-18 16:39:36 +08:00
}
if (info.hiddenInspecCO && Object.keys(info.hiddenInspecCO).length > 0) {
const inspectionAcceptImageFiles = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM["146"],
2025-11-20 16:43:06 +08:00
eqForeignKey: hiddenId || query[hiddenIdKey],
});
setInspectionAcceptImageFiles(inspectionAcceptImageFiles);
}
};
2025-11-18 16:43:27 +08:00
const getData = async () => {
request(!history ? `/hidden/hidden/${id || query[idKey]}` : `/hidden/hidden/history/${id || query[idKey]}`, "get").then((res) => {
2025-12-26 11:49:38 +08:00
res.data.hiddenAcceptQualifiedUserCO = [];
res.data.hiddenAcceptUnqualifiedUserCO = [];
if (res.data.hiddenAcceptUserCO && res.data.hiddenAcceptUserCO.length > 0) {
for (let i = 0; i < res.data.hiddenAcceptUserCO.length; i++) {
if (res.data.hiddenAcceptUserCO[i].status === 1) {
res.data.hiddenAcceptQualifiedUserCO.push(res.data.hiddenAcceptUserCO[i]);
}
else {
res.data.hiddenAcceptUnqualifiedUserCO.push(res.data.hiddenAcceptUserCO[i]);
}
}
}
2025-11-18 16:43:27 +08:00
setInfo(res.data);
getFileData(res.data);
setLoading(false);
onGetData?.(res.data);
});
2025-11-07 10:21:02 +08:00
};
useEffect(() => {
getData();
2025-11-18 16:39:36 +08:00
}, [props.id, props.hiddenId]);
2025-11-07 10:21:02 +08:00
return (
<div>
2025-11-08 15:52:06 +08:00
<Spin spinning={loading || downloadFileLoading}>
2025-12-24 15:45:07 +08:00
<Divider orientation="left">隐患信息</Divider>
<Descriptions
bordered
column={1}
styles={{ label: { width: 200 } }}
items={[
{ label: "隐患来源", children: getLabelName({ list: HIDDEN_SOURCE_ENUM, status: info.source }) },
{ label: "隐患类型", children: info.hiddenTypeName },
{ label: "隐患级别", children: info.hiddenLevelName },
{ label: "隐患状态", children: getLabelName({ list: HIDDEN_STATE_ENUM, status: info.state }) },
{ label: "隐患描述", children: info.hiddenDesc },
...(info.hiddenPartName ? [{ label: "隐患部位", children: info.hiddenPartName }] : []),
...(
(info.source === 2 || info.source === 3) && (info.hiddenCheckListCO && Object.keys(info.hiddenCheckListCO).length > 0)
? [
{ label: "风险点(单元)", children: info.hiddenCheckListCO.listRiskPoints },
{ label: "辨识部位", children: info.hiddenCheckListCO.identifiedLocations },
{ label: "存在风险", children: info.hiddenCheckListCO.existingRisks },
{ label: "风险分级", children: info.hiddenCheckListCO.riskLevel },
{ label: "隐患清单", children: info.hiddenCheckListCO.listName },
{ label: "检查内容", children: info.hiddenCheckListCO.inspectionContent },
]
: []
),
...(info.longitude
? [{
label: "隐患上报位置(经纬度)",
children: [info.longitude && `经度:${info.longitude}`, info.latitude && `纬度:${info.latitude}`].filter(Boolean).join(" "),
}]
: []),
...(info.positionDesc ? [{ label: "隐患位置描述", children: info.positionDesc }] : []),
{ label: "隐患发现人", children: info.creatorName },
{ label: "隐患发现时间", children: dayjs(info.hiddenFindTime).format("YYYY-MM-DD HH:mm:ss") },
{
label: "整改类型",
children: getLabelName({ list: HIDDEN_RECTIFICATION_TYPE_ENUM, status: info.rectificationType }),
},
{
label: "是否相关方",
children: getLabelName({
list: [{ bianma: "1", name: "是" }, { bianma: "0", name: "否" }],
status: info.isRelated,
}),
},
...(info.isRelated === 1 ? [{ label: "相关方项目", children: info.projectName }] : []),
{ label: "隐患图片", children: <PreviewImg files={hiddenImageFiles} /> },
...(hiddenVideoFiles.length > 0
? [{
label: "隐患视频",
children: (
<VideoIcon onClick={() => {
setVideoModalOpen(true);
}}
2025-11-08 15:52:06 +08:00
/>
),
2025-12-24 15:45:07 +08:00
}]
: []),
]}
/>
{
(info.hiddenUserPresetsCO && Object.keys(info.hiddenUserPresetsCO).length > 0) && (
<>
<Divider orientation="left">整改信息发现人预填</Divider>
<Descriptions
bordered
column={1}
styles={{ label: { width: 200 } }}
items={[
{ label: `整改${info.isRelated === 1 ? "单位" : "部门"}`, children: info.hiddenUserPresetsCO.rectifyDeptName },
{ label: "整改人", children: info.hiddenUserPresetsCO.rectifyUserName },
...(info.rectificationType === 2
? [
2025-11-08 15:52:06 +08:00
{
2025-12-24 15:45:07 +08:00
label: "整改期限",
2025-12-26 11:49:38 +08:00
children: info.hiddenUserPresetsCO.rectifyDeadline ? dayjs(info.hiddenUserPresetsCO.rectifyDeadline).format("YYYY-MM-DD") : "",
2025-11-08 15:52:06 +08:00
},
2025-12-24 15:45:07 +08:00
]
: []),
...(info.rectificationType === 1
? [
{ label: "验收部门", children: info.hiddenUserPresetsCO.checkDeptName },
{ label: "验收人", children: info.hiddenUserPresetsCO.checkUserName },
]
: []),
]}
/>
</>
)
}
{
(info.hiddenConfirmUserCO && info.hiddenConfirmUserCO.length > 0) && (
<>
<Divider orientation="left">隐患确认</Divider>
{
info.hiddenConfirmUserCO.map(item => (
<Descriptions
key={item.id}
bordered
column={1}
styles={{ label: { width: 200 } }}
items={[
...(item.hiddenLevelName ? [{ label: "隐患级别", children: item.hiddenLevelName }] : []),
...(item.userName ? [{ label: "隐患确认人", children: item.userName }] : []),
...(item.rectificationTime ? [{ label: "隐患确认时间", children: item.rectificationTime }] : []),
...(item.rectifyDeptName ? [{ label: `整改${info.isRelated === 1 ? "单位" : "部门"}`, children: item.rectifyDeptName }] : []),
...(item.rectifyUserName ? [{ label: "整改人", children: item.rectifyUserName }] : []),
...(item.rectificationDeadline ? [{ label: "整改完成期限", children: item.rectificationDeadline }] : []),
...(item.checkDeptName ? [{ label: "验收部门", children: item.checkDeptName }] : []),
...(item.checkUserName ? [{ label: "验收人", children: item.checkUserName }] : []),
...(item.repulseCause
? [
...(item.repulseCause ? [{ label: "打回意见", children: item.repulseCause }] : []),
...(item.rectificationTime ? [{ label: "打回时间", children: item.rectificationTime }] : []),
]
: []),
]}
/>
))
}
</>
)
}
{
info.hiddenExtensionList && info.hiddenExtensionList.length > 0 && (
<>
<Divider orientation="left">延期信息</Divider>
{
info.hiddenExtensionList.map(item => (
<Descriptions
key={item.id}
bordered
column={1}
styles={{ label: { width: 200 } }}
items={[
...(item.createTime ? [{ label: "申请延期日期", children: item.createTime }] : []),
...(item.delayTime ? [{ label: "延期日期", children: item.delayTime }] : []),
...(item.updateName ? [{ label: "审核人", children: item.updateName }] : []),
2025-12-26 11:49:38 +08:00
...(item.disposalPlan ? [{ label: "处置方案", children: item.disposalPlan }] : []),
...(item.disposalFile
? [{
label: "处置方案附件",
children: (
getFileSuffix(item.disposalFile) === "pdf"
? <PreviewPdf name={getFileName(item.disposalFile)} url={item.disposalFile} />
: (
<Space>
<span>{getFileName(item.disposalFile)}</span>
<Button
type="primary"
size="small"
2025-12-31 14:01:53 +08:00
onClick={() => downloadFile({ url: item.disposalFile })}
2025-12-26 11:49:38 +08:00
>
下载
</Button>
</Space>
)
),
}]
2025-12-24 15:45:07 +08:00
: []),
{
label: "延期审核状态",
children: (
<>
{item.state === 1 && <span>待审核</span>}
{item.state === 2 && <span>审批中</span>}
{item.state === 3 && <span>已通过</span>}
{item.state === 4 && <span>已拒绝</span>}
{item.state === 5 && <span>已撤回</span>}
</>
),
},
...((item.state === 3 || item.state === 4)
? [{
label: "延期审核时间",
children: item.updateTime,
}]
: []),
]}
/>
),
2025-11-07 10:21:02 +08:00
)
2025-12-24 15:45:07 +08:00
}
</>
)
}
{
info.hiddenSpecialList && info.hiddenSpecialList.length > 0 && (
<>
<Divider orientation="left">特殊处置审核信息</Divider>
{
info.hiddenSpecialList.map(item => (
<Descriptions
key={item.id}
bordered
column={1}
styles={{ label: { width: 200 } }}
items={[
...((item.state === 3 || item.state === 4)
? [
...(item.updateName ? [{ label: "审核人", children: item.updateName }] : []),
...(item.updateTime ? [{ label: "审核时间", children: item.updateTime }] : []),
]
: []),
{ label: "无法整改原因", children: item.examine },
...(item.state === 3
? [
...(item.disposalPlan ? [{ label: "处置方案", children: item.disposalPlan }] : []),
...(item.disposalFile
? [{
label: "处置方案附件",
children: (
getFileSuffix(item.disposalFile) === "pdf"
? <PreviewPdf name={getFileName(item.disposalFile)} url={item.disposalFile} />
: (
<Space>
<span>{getFileName(item.disposalFile)}</span>
<Button
type="primary"
size="small"
2025-12-31 14:01:53 +08:00
onClick={() => downloadFile({ url: item.disposalFile })}
2025-12-24 15:45:07 +08:00
>
下载
</Button>
</Space>
)
),
}]
: []),
{
label: "是否更换整改负责人",
children: item.rectifyUserCO && Object.keys(item.rectifyUserCO).length > 0 ? "是" : "否",
},
...(
item.rectifyUserCO && Object.keys(item.rectifyUserCO).length > 0
? [{ label: "整改负责人", children: item.rectifyUserCO.userName }]
: []),
]
: []),
{
label: "特殊处置审核状态",
children: (
<>
{item.state === 1 && <span>待审核</span>}
{item.state === 2 && <span>审批中</span>}
{item.state === 3 && <span>已通过</span>}
{item.state === 4 && <span>已拒绝</span>}
{item.state === 5 && <span>已撤回</span>}
</>
),
},
]}
/>
),
)
2025-12-24 15:45:07 +08:00
}
</>
)
}
{
(info.hiddenRectifyUserCO && info.hiddenRectifyUserCO.length > 0) && (
<>
<Divider orientation="left">整改信息</Divider>
{
info.hiddenRectifyUserCO.map((item, index) => (
<Descriptions
key={item.id}
bordered
column={1}
styles={{ label: { width: 200 } }}
items={[
...(item.deptName ? [{ label: `整改${info.isRelated === 1 ? "单位" : "部门"}`, children: item.deptName }] : []),
...(item.userName ? [{ label: "整改人", children: item.userName }] : []),
...(item.rectificationTime ? [{ label: "整改时间", children: item.rectificationTime }] : []),
...(item.descr ? [{ label: "整改描述", children: item.descr }] : []),
...(item.investmentFunds ? [{ label: "投入资金", children: `${item.investmentFunds}` }] : []),
...(info.tempSafeMeasure ? [{ label: "临时安全措施", children: info.tempSafeMeasure }] : []),
{ label: "整改后图片", children: <PreviewImg files={afterRectificationImageFiles[index]} /> },
{
label: "整改方案",
children: (
<>
{item.isRectificationScheme === 0 && <span></span>}
{item.isRectificationScheme === 1 && <span></span>}
</>
),
},
...((item.isRectificationScheme === 1 && item.hiddenSchemeCO && Object.keys(item.hiddenSchemeCO).length > 0)
? [
{ label: "治理标准", children: item.hiddenSchemeCO.governStanDards },
{ label: "治理方法", children: item.hiddenSchemeCO.governMethod },
{ label: "经费落实", children: item.hiddenSchemeCO.expenditure },
{ label: "负责人员", children: item.hiddenSchemeCO.principal },
{ label: "工时安排", children: item.hiddenSchemeCO.programming },
{ label: "时限要求", children: item.hiddenSchemeCO.timeLimitFor },
{ label: "工作要求", children: item.hiddenSchemeCO.jobRequireMent },
{ label: "其他事项", children: item.hiddenSchemeCO.otherBusiness },
{ label: "方案图片", children: <PreviewImg files={rectificationPlanImageFiles[index]} /> },
]
: []),
]}
/>
))
}
</>
)
}
{
2025-12-26 11:49:38 +08:00
info.hiddenAcceptQualifiedUserCO.length > 0
2025-12-24 15:45:07 +08:00
? (
2025-12-26 11:49:38 +08:00
<>
<Divider orientation="left">验收信息</Divider>
{
info.hiddenAcceptQualifiedUserCO.map((item, index) => (
<Descriptions
key={item.id}
bordered
column={1}
styles={{ label: { width: 200 } }}
items={[
{ label: "验收部门", children: item.deptName },
{ label: "验收人", children: item.userName },
{ label: "验收时间", children: item.rectificationTime },
...(item.repulseCause ? [{ label: "验收打回意见", children: item.repulseCause }] : []),
{ label: "是否合格", children: item.rectificationTime ? "合格" : "" },
...(item.descr ? [{ label: "验收描述", children: item.descr }] : []),
...((acceptImageFiles[index] && acceptImageFiles[index].length > 0) ? [{ label: "验收图片", children: <PreviewImg files={acceptImageFiles[index]} /> }] : []),
]}
/>
))
}
</>
)
: null
}
{
info.hiddenAcceptUnqualifiedUserCO.length > 0
? (
<>
<Divider orientation="left">验收打回信息</Divider>
{
info.hiddenAcceptUnqualifiedUserCO.map(item => (
<Descriptions
key={item.id}
bordered
column={1}
styles={{ label: { width: 200 } }}
items={[
{ label: "验收部门", children: item.deptName },
{ label: "验收人", children: item.userName },
{ label: "验收时间", children: item.rectificationTime },
{ label: "验收打回意见", children: item.repulseCause },
]}
/>
))
}
</>
2025-12-24 15:45:07 +08:00
)
: null
}
{
(info.hiddenInspecCO && Object.keys(info.hiddenInspecCO).length > 0)
? (
<>
<Divider orientation="left">安全环保验收信息</Divider>
<Descriptions
bordered
column={1}
styles={{ label: { width: 200 } }}
items={[
{ label: "验收人", children: info.hiddenInspecCO.finalCheckOr },
{ label: "验收时间", children: info.hiddenInspecCO.finalCheckTime },
{ label: "是否合格", children: info.hiddenInspecCO.finalCheck === 1 ? "合格" : "不合格" },
{ label: "验收描述", children: info.hiddenInspecCO.finalCheckDesc },
{ label: "验收图片", children: <PreviewImg files={inspectionAcceptImageFiles} /> },
]}
/>
</>
)
: null
}
</Spin>
2025-12-01 11:31:26 +08:00
{
videoModalOpen && (
<Video
visible={videoModalOpen}
source={hiddenVideoFiles[0].url}
onCancel={() => setVideoModalOpen(false)}
title="隐患视频"
/>
)
}
2025-11-07 10:21:02 +08:00
</div>
);
}
2025-12-24 15:45:07 +08:00
HiddenInfo.displayName = "HiddenInfo";
2025-11-07 10:21:02 +08:00
export default HiddenInfo;