添加相关方隐患模块

majorHidden
853931625@qq.com 2026-05-22 08:51:41 +08:00
parent d3679c4d3b
commit 736f176782
10 changed files with 583 additions and 5 deletions

View File

@ -32,7 +32,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-to-print": "^3.2.0",
"zy-react-library": "^1.3.6"
"zy-react-library": "^1.3.14"
},
"devDependencies": {
"@antfu/eslint-config": "^5.4.1",

View File

@ -62,6 +62,7 @@ function List(props) {
label: "是否相关方",
render: FORM_ITEM_RENDER_ENUM.SELECT,
items: IS_RELATED_ENUM,
hidden: props.type === "Stakeholder",
},
]}
form={form}
@ -103,7 +104,7 @@ function List(props) {
fixed: "right",
render: (_, record) => (
<Space>
{props.permission("fgs-yqzg-ck") && (
{props.permission(props.ckButton || "fgs-yqzg-ck") && (
<Button
type="link"
onClick={() => {
@ -113,7 +114,7 @@ function List(props) {
查看
</Button>
)}
{props.permission("fgs-yqzg-zg") && (
{props.permission(props.zgButton || "fgs-yqzg-zg") && (
<Button
type="link"
onClick={() => {
@ -123,7 +124,7 @@ function List(props) {
整改
</Button>
)}
{props.permission("fgs-yqzg-lsaqcs") && (
{props.permission(props.lsaqcsButton || "fgs-yqzg-lsaqcs") && (
<Button
type="link"
onClick={() => {
@ -134,7 +135,7 @@ function List(props) {
临时安全措施
</Button>
)}
{props.permission("fgs-yqzg-sqyq") && !record.noReviewExtensionNum && (
{props.permission(props.sqyqButton || "fgs-yqzg-sqyq") && !record.noReviewExtensionNum && (
<Button
type="link"
onClick={() => {

View File

@ -0,0 +1,487 @@
import { Permission } from "@cqsjjb/jjb-common-decorator/permission";
import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Button, Checkbox, Form, message, Modal, Space } from "antd";
import dayjs from "dayjs";
import { useEffect, useMemo, useRef, useState } from "react";
import { useReactToPrint } from "react-to-print";
import FormBuilder from "zy-react-library/components/FormBuilder";
import ExportIcon from "zy-react-library/components/Icon/ExportIcon";
import PrintIcon from "zy-react-library/components/Icon/PrintIcon";
import Page from "zy-react-library/components/Page";
import Search from "zy-react-library/components/Search";
import DepartmentSelectTree from "zy-react-library/components/SelectTree/Department/Gwj";
import DictionarySelectTree from "zy-react-library/components/SelectTree/Dictionary";
import HiddenLevelSelectTree from "zy-react-library/components/SelectTree/HiddenLevel/Gwj";
import Table from "zy-react-library/components/Table";
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
import { HIDDEN_RECTIFICATION_TYPE_ENUM, HIDDEN_SOURCE_ENUM, HIDDEN_STATE_ENUM } from "zy-react-library/enum/hidden/gwj";
import useDownloadBlob from "zy-react-library/hooks/useDownloadBlob";
import useTable from "zy-react-library/hooks/useTable";
import { getLabelName, getUnmatchedItems } from "zy-react-library/utils";
import { IS_RELATED_ENUM } from "~/enumerate/constant";
import { NS_LEDGER } from "~/enumerate/namespace";
import "./index.less";
function List(props) {
const [form] = Form.useForm();
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const [exportByColumnModalOpen, setExportByColumnModalOpen] = useState(false);
const [printModalOpen, setPrintModalOpen] = useState(false);
const { tableProps, getData } = useTable(props["ledgerList"], {
form,
transform: formData => ({
hiddenFindTime: formData.hiddenFindTime?.[0],
hiddenFindTimeLe: formData.hiddenFindTime?.[1],
state: formData.state ? [formData.state] : undefined,
hiddenLevels: ["hiddenLevel1001", "hiddenLevel1004", "hiddenLevel1002"],
}),
});
return (
<Page isShowAllAction={false}>
<Search
options={[
{ name: "source", label: "隐患来源", render: FORM_ITEM_RENDER_ENUM.SELECT, items: HIDDEN_SOURCE_ENUM },
{ name: "hiddenDesc", label: "隐患描述" },
{ name: "hiddenFindTime", label: "隐患发现时间", render: FORM_ITEM_RENDER_ENUM.DATE_RANGE },
{ name: "hiddenFindDept", label: "隐患发现部门", render: <DepartmentSelectTree /> },
{
name: "hiddenType",
label: "隐患类型",
render: <DictionarySelectTree dictValue="hiddenType" onlyLastLevel />,
},
{
name: "hiddenLevel",
label: "隐患级别",
render: (
<HiddenLevelSelectTree isShowLarger={false} isShowMajor={false} />
),
},
{ name: "creatorName", label: "隐患发现人" },
{
name: "state",
label: "隐患状态",
render: FORM_ITEM_RENDER_ENUM.SELECT,
items: getUnmatchedItems({ list: HIDDEN_STATE_ENUM, value: ["98", "102"] }),
},
{ name: "confirmUserName", label: "确认人" },
{ name: "rectificationUserName", label: "整改人" },
{ name: "rectificationDeptId", label: "整改部门", render: <DepartmentSelectTree /> },
{ name: "checkUserName", label: "验收人" },
{
name: "isAi",
label: "是否使用AI",
render: FORM_ITEM_RENDER_ENUM.SELECT,
items: [{ bianma: "1", name: "是" }, { bianma: "0", name: "否" }],
},
]}
form={form}
onFinish={getData}
/>
<Table
rowSelection={{
preserveSelectedRowKeys: true,
selectedRowKeys,
onChange: (selectedRowKeys) => {
setSelectedRowKeys(selectedRowKeys);
},
}}
toolBarRender={() => (
<>
{props.permission("xgf-yhjl-dy") && (
<Button
type="primary"
icon={<PrintIcon />}
ghost
onClick={() => {
if (selectedRowKeys.length === 0) {
message.error("请选中要打印的数据");
return;
}
setPrintModalOpen(true);
}}
>
打印
</Button>
)}
{props.permission("xgf-yhjl-aldc") && (
<Button
type="primary"
icon={<ExportIcon />}
ghost
onClick={() => {
setExportByColumnModalOpen(true);
}}
>
导出
</Button>
)}
</>
)}
columns={[
{
title: "隐患来源",
dataIndex: "source",
render: (_, record) => getLabelName({ list: HIDDEN_SOURCE_ENUM, status: record.source }),
},
{ title: "隐患描述", dataIndex: "hiddenDesc" },
{ title: "隐患级别", dataIndex: "hiddenLevelName", width: 100 },
{ title: "隐患类型", dataIndex: "hiddenTypeName" },
{ title: "隐患发现部门", dataIndex: "hiddenFindDeptName", width: 180 },
{ title: "隐患发现人", dataIndex: "createName", width: 130 },
{
title: "隐患发现时间",
dataIndex: "hiddenFindTime",
width: 180,
render: (_, record) => record.hiddenFindTime ? dayjs(record.hiddenFindTime).format("YYYY-MM-DD HH:mm:ss") : "",
},
{
title: "整改类型",
dataIndex: "rectificationType",
width: 100,
render: (_, record) => getLabelName({
list: HIDDEN_RECTIFICATION_TYPE_ENUM,
status: record.rectificationType,
}),
},
{ title: "确认人", dataIndex: "confirmUserName", width: 100 },
{ title: "整改人", dataIndex: "rectifyUserName", width: 100 },
{
title: "整改时间",
dataIndex: "rectificationTime",
width: 180,
render: (_, record) => record.rectificationTime ? dayjs(record.rectificationTime).format("YYYY-MM-DD HH:mm:ss") : "",
},
{ title: "验收人", dataIndex: "hiddenYUserName", width: 100 },
{
title: "是否相关方",
dataIndex: "isRelated",
width: 150,
render: (_, record) => getLabelName({
list: IS_RELATED_ENUM,
status: record.isRelated,
}),
},
{
title: "隐患状态",
dataIndex: "state",
render: (_, record) => getLabelName({ list: HIDDEN_STATE_ENUM, status: record.state }),
},
{
title: "操作",
width: 180,
fixed: "right",
render: (_, record) => (
<Space>
{props.permission("xgf-yhjl-ck") && (
<Button
type="link"
onClick={() => {
props.history.push(`../HiddenView?id=${record.id}&hiddenId=${record.hiddenId}`);
}}
>
查看
</Button>
)}
{props.permission("xgf-yhjl-gcjl") && (
<Button
type="link"
onClick={() => {
props.history.push(`../HiddenView?id=${record.id}&hiddenId=${record.hiddenId}&history=1`);
}}
>
过程记录
</Button>
)}
</Space>
),
},
]}
{...tableProps}
/>
{exportByColumnModalOpen && (
<ExportByColumnModal
hiddenFindTime={form.getFieldValue("hiddenFindTime")}
selectedRowKeys={selectedRowKeys}
onCancel={() => setExportByColumnModalOpen(false)}
/>
)}
{printModalOpen && (
<PrintModal
selectedRowKeys={selectedRowKeys}
onCancel={() => setPrintModalOpen(false)}
/>
)}
</Page>
);
}
const ExportByColumnModalComponent = (props) => {
const [form] = Form.useForm();
const exportFields = Form.useWatch("exportFields", form);
const { loading, downloadBlob } = useDownloadBlob();
const [items, setItems] = useState([]);
const indeterminate = useMemo(
() => {
if (!exportFields)
return false;
return exportFields.length > 0 && exportFields.length < items.length;
},
[exportFields],
);
const getExportColumn = async () => {
const { data } = await props["hiddenExportColumn"]();
setItems(data.map(item => ({ bianma: item, name: item })));
const defaultExportFields = data.filter(item => !item.includes("图片"));
form.setFieldsValue({ exportFields: [...defaultExportFields] });
};
useEffect(() => {
getExportColumn();
}, []);
const onSubmit = async (values) => {
const hiddenFindTime = props.hiddenFindTime;
const selectedRowKeys = props.selectedRowKeys;
// 检查导出字段是否包含"图片"
const hasPictureField = values.exportFields && values.exportFields.some(field => field.includes("图片"));
if (hasPictureField) {
// 包含图片字段的验证逻辑
if (!selectedRowKeys || selectedRowKeys.length === 0) {
message.error("请选择要导出的数据");
return;
}
if (selectedRowKeys.length > 10) {
message.error("选择的数据超过10条请重新选择");
return;
}
// 执行导出
Modal.confirm({
title: "导出确认",
content: "确定要导出excel吗",
onOk: async () => {
await downloadBlob("/hidden/hidden/exportHidden", {
params: { ids: props.selectedRowKeys.join(","), ...values },
});
message.success("导出成功");
props.onCancel();
},
});
}
else {
// 不包含图片字段的验证逻辑
if (!hiddenFindTime || hiddenFindTime.length === 0) {
message.error("请选择隐患发现时间");
return;
}
// 执行导出
Modal.confirm({
title: "导出确认",
content: "确定要导出excel吗",
onOk: async () => {
await downloadBlob("/hidden/hidden/exportHidden", {
params: { hiddenFindTime: hiddenFindTime[0], hiddenFindTimeLe: hiddenFindTime[1], ...values },
});
message.success("导出成功");
props.onCancel();
},
});
}
};
return (
<Modal
title="导出"
width={800}
open
maskClosable={false}
onCancel={props.onCancel}
onOk={form.submit}
confirmLoading={loading}
>
<FormBuilder
loading={loading}
form={form}
span={24}
labelCol={{ span: 6 }}
showActionButtons={false}
onFinish={onSubmit}
options={[
{
key: "indeterminate",
label: "",
render: (
<Checkbox
indeterminate={indeterminate}
onChange={(e) => {
const checked = e.target.checked;
if (checked) {
form.setFieldsValue({ exportFields: items.map(item => item.bianma) });
}
else {
form.setFieldsValue({ exportFields: [] });
}
}}
checked={items.length === (exportFields || []).length}
>
全选为保障导出效率导出带图片的excel最多10条
</Checkbox>
),
required: false,
},
{
name: "exportFields",
label: "导出内容",
render: FORM_ITEM_RENDER_ENUM.CHECKBOX,
items,
checkboxCol: 6,
},
]}
/>
</Modal>
);
};
const PrintModalComponent = (props) => {
const [list, setList] = useState([]);
const contentRef = useRef(null);
const handlePrint = useReactToPrint({
contentRef,
pageStyle: `@page {
size: landscape;
margin: 3mm;
}
@media print {
body {
margin: 10px;
padding: 10px;
}
}
`,
documentTitle: "",
});
const getData = async () => {
const { data } = await props["hiddenPrintList"]({
ids: props.selectedRowKeys.join(","),
});
setList(data);
};
useEffect(() => {
getData();
}, []);
const getIsQualified = (isQualified) => {
if (isQualified === "1")
return "合格";
else if (isQualified === "0")
return "不合格";
return "";
};
return (
<Modal
title="打印"
width={1500}
okText="打印"
open
maskClosable={false}
onCancel={props.onCancel}
onOk={handlePrint}
>
<Table
options={false}
disabledResizer={false}
dataSource={list}
pagination={false}
columns={[
{
title: "排查时间",
dataIndex: "hiddenFindTime",
render: (_, record) => dayjs(record.hiddenFindTime).format("YYYY-MM-DD HH:mm:ss"),
},
{ title: "检查人", dataIndex: "createName" },
{ title: "责任部门", dataIndex: "hiddenFindDeptName" },
{ title: "事故隐患", dataIndex: "hiddenDesc" },
{ title: "隐患级别", dataIndex: "hiddenLevelName" },
{ title: "治理措施", dataIndex: "rectificationDesc" },
{
title: "完成时限",
dataIndex: "rectificationDeadline",
render: (_, record) => record.rectificationDeadline && dayjs(record.rectificationDeadline).format("YYYY-MM-DD HH:mm:ss"),
},
{ title: "整改责任人", dataIndex: "rectifyUserName" },
{
title: "验收人",
dataIndex: "hiddenYUserName",
render: (_, record) => record.state === 301 ? record.hiddenYUserName : "",
},
{
title: "验收时间",
dataIndex: "hiddenYTime",
render: (_, record) => record.hiddenYTime && dayjs(record.hiddenYTime).format("YYYY-MM-DD HH:mm:ss"),
},
{
title: "验收结果",
dataIndex: "isQualified",
render: (_, record) => record.hiddenLevelName !== "忽略隐患" ? (record.state === 301 ? getIsQualified(record.isQualified) : "") : "",
},
]}
/>
<div ref={contentRef}>
<table className="print-table">
<thead>
<tr>
<th>排查时间</th>
<th>检查人</th>
<th>责任部门</th>
<th>事故隐患</th>
<th>隐患级别</th>
<th>治理措施</th>
<th>完成时限</th>
<th>整改责任人</th>
<th>验收人</th>
<th>验收时间</th>
<th>验收结果</th>
</tr>
</thead>
<tbody>
{list.map(item => (
<tr key={item.id}>
<td>{item.hiddenFindTime ? dayjs(item.hiddenFindTime).format("YYYY-MM-DD HH:mm:ss") : ""}</td>
<td>{item.createName}</td>
<td>{item.hiddenFindDeptName}</td>
<td>{item.hiddenDesc}</td>
<td>{item.hiddenLevelName}</td>
<td>{item.rectificationDesc}</td>
<td>{item.rectificationDeadline ? dayjs(item.rectificationDeadline).format("YYYY-MM-DD HH:mm:ss") : ""}</td>
<td>{item.rectifyUserName}</td>
<td>{item.state === 301 ? item.hiddenYUserName : ""}</td>
<td>{item.hiddenYTime ? dayjs(item.hiddenYTime).format("YYYY-MM-DD HH:mm:ss") : ""}</td>
<td>{item.state === 301 ? getIsQualified(item.isQualified) : ""}</td>
</tr>
))}
</tbody>
</table>
</div>
</Modal>
);
};
const PrintModal = Connect([NS_LEDGER], true)(PrintModalComponent);
const ExportByColumnModal = Connect([NS_LEDGER], true)(ExportByColumnModalComponent);
export default Connect([NS_LEDGER], true)(Permission(List));

View File

@ -0,0 +1,17 @@
.print-table {
display: none;
border-collapse: collapse;
width: 100%;
font-size: 14px;
td, th {
border: 1px solid #eaeaea;
padding: 8px;
line-height: 1.6;
text-align: center;
}
@media print {
display: table;
}
}

View File

@ -0,0 +1,9 @@
function HiddenRecord(props) {
return (
<div>
{props.children}
</div>
);
}
export default HiddenRecord;

View File

@ -0,0 +1,15 @@
import HiddenInfo from "zy-react-library/components/HiddenInfo/gwj";
import Page from "zy-react-library/components/Page";
import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery";
function HiddenView() {
const query = useGetUrlQuery();
return (
<Page headerTitle={query.history === "1" ? "过程记录" : "查看"} contentPadding="0 20px 20px 20px">
<HiddenInfo history={query.history === "1"} />
</Page>
);
}
export default HiddenView;

View File

@ -0,0 +1,18 @@
import PageList from "~/pages/Container/BranchCompany/Average/Rectification/List";
function List(props) {
return (
<div>
<PageList
{...props}
ckButton="xgf-yqzg-ck"
zgButton="xgf-yqzg-zg"
lsaqcsButton="xgf-yqzg-lsaqcs"
sqyqButton="xgf-yqzg-sqyq"
type="Stakeholder"
/>
</div>
);
}
export default List;

View File

@ -0,0 +1,13 @@
import PageView from "~/pages/Container/BranchCompany/Average/Rectification/Review";
function Review(props) {
return (
<div>
<PageView
{...props}
/>
</div>
);
}
export default Review;

View File

@ -0,0 +1,9 @@
function Rectification(props) {
return (
<div>
{props.children}
</div>
);
}
export default Rectification;

View File

@ -0,0 +1,9 @@
function Stakeholder(props) {
return (
<div>
{props.children}
</div>
);
}
export default Stakeholder;