99 lines
3.3 KiB
JavaScript
99 lines
3.3 KiB
JavaScript
|
|
import {Connect} from "@cqsjjb/jjb-dva-runtime";
|
||
|
|
import {Button, Form, Space} from "antd";
|
||
|
|
import {useEffect, useState} from "react";
|
||
|
|
import Search from "zy-react-library/components/Search";
|
||
|
|
import Table from "zy-react-library/components/Table";
|
||
|
|
import useTable from "zy-react-library/hooks/useTable";
|
||
|
|
import {NS_ACCIDENT} from "~/enumerate/namespace";
|
||
|
|
import useDictionary from "zy-react-library/hooks/useDictionary";
|
||
|
|
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
|
||
|
|
import useUrlQueryCriteria from "zy-react-library/hooks/useUrlQueryCriteria";
|
||
|
|
|
||
|
|
|
||
|
|
const TYPE = [
|
||
|
|
{name: "事件", bianma: "1"},
|
||
|
|
{name: "事故", bianma: "2"},
|
||
|
|
]
|
||
|
|
|
||
|
|
function SuperviseAccident(props) {
|
||
|
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
||
|
|
const [form] = Form.useForm();
|
||
|
|
const {getDictionary} = useDictionary();
|
||
|
|
const [accidentType, setAccidentType] = useState([]);
|
||
|
|
const {getUrlCriteriaQuery} = useUrlQueryCriteria();
|
||
|
|
const [accidentCountByCorpinfoAndType, setAccidentCountByCorpinfoAndType] = useState([]);
|
||
|
|
useEffect(() => {
|
||
|
|
getDictionary({dictValue: "accidentType"}).then(res => {
|
||
|
|
setAccidentType(res);
|
||
|
|
});
|
||
|
|
}, []);
|
||
|
|
|
||
|
|
const getAccidentCountByCorpinfoAndType=async (corpinfoIds,type)=>{
|
||
|
|
const {data} = await props["accidentCountByCorpinfoAndType"]({corpinfoIds,eqAccidentType:type})
|
||
|
|
setAccidentCountByCorpinfoAndType(data)
|
||
|
|
}
|
||
|
|
|
||
|
|
const {tableProps, getData} = useTable(props["getCorpInfoList"], {
|
||
|
|
form,
|
||
|
|
onSuccess: ({data}) => {
|
||
|
|
getAccidentCountByCorpinfoAndType(data.map(item => item.id),form.getFieldValue("eqAccidentType"))
|
||
|
|
},
|
||
|
|
});
|
||
|
|
const getAccidentCount=(id,type)=>{
|
||
|
|
return accidentCountByCorpinfoAndType.find(item => item.corpinfoId === id && item.incidentType === type)?.[`count`] || 0;
|
||
|
|
}
|
||
|
|
const searchType = getUrlCriteriaQuery("searchFormKeys","searchFormValues").eqAccidentType;
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div style={{padding: 10}}>
|
||
|
|
<Search
|
||
|
|
form={form}
|
||
|
|
values={{
|
||
|
|
eqAccidentType: "1",
|
||
|
|
}}
|
||
|
|
onFinish={getData}
|
||
|
|
options={[
|
||
|
|
{name: "likecorpName", label: `公司名称`},
|
||
|
|
{name: "eqAccidentType", label: `类型`, render: FORM_ITEM_RENDER_ENUM.SELECT, items: TYPE,componentProps: {allowClear: false }},
|
||
|
|
]}
|
||
|
|
/>
|
||
|
|
<Table
|
||
|
|
rowSelection={{
|
||
|
|
selectedRowKeys,
|
||
|
|
onChange: selectedRowKeys => setSelectedRowKeys(selectedRowKeys),
|
||
|
|
}}
|
||
|
|
columns={[
|
||
|
|
{dataIndex: "corpName", title: `所属公司`},
|
||
|
|
...accidentType.map(item => ({
|
||
|
|
dataIndex: `countByCorpinfoAndType_${item.dictValue}`,
|
||
|
|
title: `${item.dictLabel}`,
|
||
|
|
render: (_, record) => (
|
||
|
|
getAccidentCount(record.id,item.dictValue)
|
||
|
|
),
|
||
|
|
})),
|
||
|
|
{
|
||
|
|
title: "操作",
|
||
|
|
width: 160,
|
||
|
|
fixed: "right",
|
||
|
|
render: (_, record) => (
|
||
|
|
<Space>
|
||
|
|
<Button
|
||
|
|
type="link"
|
||
|
|
onClick={() => {
|
||
|
|
props.history.push(`./info?corpinfoId=${record.id}&eqAccidentType=${searchType}`)
|
||
|
|
}}
|
||
|
|
>
|
||
|
|
查看
|
||
|
|
</Button>
|
||
|
|
</Space>
|
||
|
|
),
|
||
|
|
},
|
||
|
|
]}
|
||
|
|
{...tableProps}
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
export default Connect([NS_ACCIDENT], true)(SuperviseAccident);
|