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"; import Page from "zy-react-library/components/Page"; 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, params: { inType: [0,1], }, 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 ( 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) => ( ), }, ]} {...tableProps} /> ); } export default Connect([NS_ACCIDENT], true)(SuperviseAccident);