2026-06-10 10:11:15 +08:00
|
|
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
|
|
|
|
import { Button, Form } from "antd";
|
|
|
|
|
import { useState } from "react";
|
|
|
|
|
import Page from "zy-react-library/components/Page";
|
2025-11-26 08:33:41 +08:00
|
|
|
import Search from "zy-react-library/components/Search";
|
|
|
|
|
import Table from "zy-react-library/components/Table";
|
|
|
|
|
import useTable from "zy-react-library/hooks/useTable";
|
2026-06-10 10:11:15 +08:00
|
|
|
import { NS_ACCIDENT } from "~/enumerate/namespace";
|
2025-11-26 08:33:41 +08:00
|
|
|
|
|
|
|
|
function SuperviseAccident(props) {
|
|
|
|
|
const [form] = Form.useForm();
|
2026-06-10 10:11:15 +08:00
|
|
|
|
2025-11-26 08:33:41 +08:00
|
|
|
const [accidentCountByCorpinfoAndType, setAccidentCountByCorpinfoAndType] = useState([]);
|
|
|
|
|
|
2026-06-10 10:11:15 +08:00
|
|
|
const getAccidentCountByCorpinfoAndType = async (corpinfoIds, type) => {
|
|
|
|
|
const { data } = await props["accidentCountByCorpinfoAndType"]({ corpinfoIds, eqAccidentType: type });
|
|
|
|
|
setAccidentCountByCorpinfoAndType(data);
|
|
|
|
|
};
|
2025-11-26 08:33:41 +08:00
|
|
|
|
2026-06-10 10:11:15 +08:00
|
|
|
const { tableProps, getData } = useTable(props["getCorpInfoList"], {
|
2025-11-26 08:33:41 +08:00
|
|
|
form,
|
2025-12-22 10:23:33 +08:00
|
|
|
params: {
|
2026-06-10 10:11:15 +08:00
|
|
|
inType: [0, 1, 6],
|
2025-12-22 10:23:33 +08:00
|
|
|
},
|
2026-06-10 10:11:15 +08:00
|
|
|
onSuccess: ({ data }) => {
|
|
|
|
|
getAccidentCountByCorpinfoAndType(data.map(item => item.id), form.getFieldValue("eqAccidentType"));
|
2025-11-26 08:33:41 +08:00
|
|
|
},
|
|
|
|
|
});
|
2026-06-10 10:11:15 +08:00
|
|
|
const getAccidentTotal = (id, key) => {
|
|
|
|
|
return accidentCountByCorpinfoAndType.find(item => item.corpinfoId === id)?.[key] || 0;
|
|
|
|
|
};
|
2025-11-26 08:33:41 +08:00
|
|
|
|
|
|
|
|
return (
|
2026-01-08 10:03:35 +08:00
|
|
|
<Page isShowAllAction={false}>
|
2025-11-26 08:33:41 +08:00
|
|
|
<Search
|
|
|
|
|
form={form}
|
|
|
|
|
onFinish={getData}
|
|
|
|
|
options={[
|
2026-06-10 10:11:15 +08:00
|
|
|
{ name: "likecorpName", label: `公司名称` },
|
2025-11-26 08:33:41 +08:00
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
<Table
|
2026-06-10 10:11:15 +08:00
|
|
|
|
2025-11-26 08:33:41 +08:00
|
|
|
columns={[
|
2026-06-10 10:11:15 +08:00
|
|
|
{ dataIndex: "corpName", title: `公司名称` },
|
|
|
|
|
{
|
|
|
|
|
dataIndex: "eventCount",
|
|
|
|
|
title: "事件总数",
|
|
|
|
|
width: 180,
|
2025-11-26 08:33:41 +08:00
|
|
|
render: (_, record) => (
|
2026-06-10 10:11:15 +08:00
|
|
|
<Button
|
|
|
|
|
type="link"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
props.history.push(`./info?corpinfoId=${record.id}&eqAccidentType=1`);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{getAccidentTotal(record.id, "eventCount")}
|
|
|
|
|
</Button>
|
|
|
|
|
|
2025-11-26 08:33:41 +08:00
|
|
|
),
|
2026-06-10 10:11:15 +08:00
|
|
|
},
|
2025-11-26 08:33:41 +08:00
|
|
|
{
|
2026-06-10 10:11:15 +08:00
|
|
|
dataIndex: "accidentCount",
|
|
|
|
|
title: "事故总数",
|
|
|
|
|
width: 180,
|
2025-11-26 08:33:41 +08:00
|
|
|
render: (_, record) => (
|
2026-06-10 10:11:15 +08:00
|
|
|
<Button
|
|
|
|
|
type="link"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
props.history.push(`./info?corpinfoId=${record.id}&eqAccidentType=2`);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{ getAccidentTotal(record.id, "accidentCount")}
|
|
|
|
|
</Button>
|
|
|
|
|
|
2025-11-26 08:33:41 +08:00
|
|
|
),
|
|
|
|
|
},
|
2026-06-10 10:11:15 +08:00
|
|
|
|
2025-11-26 08:33:41 +08:00
|
|
|
]}
|
|
|
|
|
{...tableProps}
|
|
|
|
|
/>
|
2026-01-08 10:03:35 +08:00
|
|
|
</Page>
|
2025-11-26 08:33:41 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Connect([NS_ACCIDENT], true)(SuperviseAccident);
|