6.5 需求变更
parent
3c6497b9f8
commit
bd5bb63a51
|
|
@ -1,38 +1,42 @@
|
||||||
import { declareRequest } from '@cqsjjb/jjb-dva-runtime';
|
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
||||||
|
|
||||||
export const accidentList = declareRequest(
|
export const accidentList = declareRequest(
|
||||||
'accidentLoading',
|
"accidentLoading",
|
||||||
'Post > @/accident/accident/list',
|
"Post > @/accident/accident/list",
|
||||||
);
|
);
|
||||||
export const accidentAdd = declareRequest(
|
export const accidentAdd = declareRequest(
|
||||||
'accidentLoading',
|
"accidentLoading",
|
||||||
'Post > @/accident/accident/save'
|
"Post > @/accident/accident/save",
|
||||||
);
|
);
|
||||||
export const accidentEdit = declareRequest(
|
export const accidentEdit = declareRequest(
|
||||||
'accidentLoading',
|
"accidentLoading",
|
||||||
'Put > @/accident/accident/edit'
|
"Put > @/accident/accident/edit",
|
||||||
);
|
);
|
||||||
export const accidentDelete = declareRequest(
|
export const accidentDelete = declareRequest(
|
||||||
'accidentLoading',
|
"accidentLoading",
|
||||||
'Delete > @/accident/accident/{id}'
|
"Delete > @/accident/accident/{id}",
|
||||||
);
|
);
|
||||||
export const accidentBatchDelete = declareRequest(
|
export const accidentBatchDelete = declareRequest(
|
||||||
'accidentLoading',
|
"accidentLoading",
|
||||||
'Delete > @/accident/accident/ids?ids={ids}'
|
"Delete > @/accident/accident/ids?ids={ids}",
|
||||||
);
|
);
|
||||||
export const accidentInfo = declareRequest('accidentLoading', 'Get > /accident/accident/{id}');
|
export const accidentInfo = declareRequest("accidentLoading", "Get > /accident/accident/{id}");
|
||||||
|
|
||||||
export const accidentCountByCorpinfoAndType = declareRequest(
|
export const accidentCountByCorpinfoAndType = declareRequest(
|
||||||
'accidentLoading',
|
"accidentLoading",
|
||||||
'Post > @/accident/accident/countByCorpinfoAndType'
|
"Post > @/accident/accident/countByCorpinfoAndType",
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getCorpInfoList = declareRequest(
|
export const getCorpInfoList = declareRequest(
|
||||||
'accidentLoading',
|
"accidentLoading",
|
||||||
'Post > @/basicInfo/corpInfo/list'
|
"Post > @/basicInfo/corpInfo/list",
|
||||||
);
|
);
|
||||||
|
|
||||||
export const accidentExport = declareRequest(
|
export const accidentExport = declareRequest(
|
||||||
'accidentLoading',
|
"accidentLoading",
|
||||||
'Post > @/accident/accident/export'
|
"Post > @/accident/accident/export",
|
||||||
|
);
|
||||||
|
export const countByIncidentType = declareRequest(
|
||||||
|
"accidentLoading",
|
||||||
|
"Post > @/accident/accident/countByIncidentType",
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,27 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import { Permission } from "@cqsjjb/jjb-common-decorator/permission";
|
||||||
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import { Button, Descriptions, Form, message, Modal, Space } from "antd";
|
import { Button, Descriptions, Form, message, Modal, Space } from "antd";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
import FormBuilder from "zy-react-library/components/FormBuilder";
|
import FormBuilder from "zy-react-library/components/FormBuilder";
|
||||||
|
import AddIcon from "zy-react-library/components/Icon/AddIcon";
|
||||||
|
import DeleteIcon from "zy-react-library/components/Icon/DeleteIcon";
|
||||||
|
import ExportIcon from "zy-react-library/components/Icon/ExportIcon";
|
||||||
|
import Page from "zy-react-library/components/Page";
|
||||||
|
import PreviewImg from "zy-react-library/components/PreviewImg";
|
||||||
import Search from "zy-react-library/components/Search";
|
import Search from "zy-react-library/components/Search";
|
||||||
|
import DictionarySelect from "zy-react-library/components/Select/Dictionary";
|
||||||
import Table from "zy-react-library/components/Table";
|
import Table from "zy-react-library/components/Table";
|
||||||
import Upload from "zy-react-library/components/Upload";
|
import Upload from "zy-react-library/components/Upload";
|
||||||
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
|
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
|
||||||
import { UPLOAD_FILE_TYPE_ENUM } from "zy-react-library/enum/uploadFile/gwj";
|
import { UPLOAD_FILE_TYPE_ENUM } from "zy-react-library/enum/uploadFile/gwj";
|
||||||
import { TWO_DECIMAL_PLACES } from "zy-react-library/regular";
|
|
||||||
import useTable from "zy-react-library/hooks/useTable";
|
|
||||||
import useDeleteFile from "zy-react-library/hooks/useDeleteFile";
|
import useDeleteFile from "zy-react-library/hooks/useDeleteFile";
|
||||||
import useGetFile from "zy-react-library/hooks/useGetFile";
|
|
||||||
import useUploadFile from "zy-react-library/hooks/useUploadFile";
|
|
||||||
import { NS_ACCIDENT } from "~/enumerate/namespace";
|
|
||||||
import AddIcon from "zy-react-library/components/Icon/AddIcon";
|
|
||||||
import DeleteIcon from "zy-react-library/components/Icon/DeleteIcon";
|
|
||||||
import ExportIcon from "zy-react-library/components/Icon/ExportIcon";
|
|
||||||
import DictionarySelect from "zy-react-library/components/Select/Dictionary";
|
|
||||||
import useDownloadBlob from "zy-react-library/hooks/useDownloadBlob";
|
import useDownloadBlob from "zy-react-library/hooks/useDownloadBlob";
|
||||||
import useUrlQueryCriteria from "zy-react-library/hooks/useUrlQueryCriteria";
|
|
||||||
import PreviewImg from "zy-react-library/components/PreviewImg";
|
|
||||||
import useDownloadFile from "zy-react-library/hooks/useDownloadFile";
|
import useDownloadFile from "zy-react-library/hooks/useDownloadFile";
|
||||||
import { Permission } from "@cqsjjb/jjb-common-decorator/permission";
|
import useGetFile from "zy-react-library/hooks/useGetFile";
|
||||||
import Page from "zy-react-library/components/Page";
|
import useTable from "zy-react-library/hooks/useTable";
|
||||||
|
import useUploadFile from "zy-react-library/hooks/useUploadFile";
|
||||||
|
import useUrlQueryCriteria from "zy-react-library/hooks/useUrlQueryCriteria";
|
||||||
|
import { NS_ACCIDENT } from "~/enumerate/namespace";
|
||||||
|
|
||||||
function Accident(props) {
|
function Accident(props) {
|
||||||
const [addModalVisible, setAddModalVisible] = useState(false);
|
const [addModalVisible, setAddModalVisible] = useState(false);
|
||||||
|
|
@ -41,8 +39,8 @@ function Accident(props) {
|
||||||
eqCorpinfoId: props.corpinfoId,
|
eqCorpinfoId: props.corpinfoId,
|
||||||
},
|
},
|
||||||
transform: data => ({
|
transform: data => ({
|
||||||
geIncidentDate: data.incidentDate?.[0] ? (data.incidentDate[0] + " 00:00:00") : "",
|
geIncidentDate: data.incidentDate?.[0] ? (`${data.incidentDate[0]} 00:00:00`) : "",
|
||||||
leIncidentDate: data.incidentDate?.[1] ? (data.incidentDate[1] + " 23:59:59") : "",
|
leIncidentDate: data.incidentDate?.[1] ? (`${data.incidentDate[1]} 23:59:59`) : "",
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const typeName = props.type === 1 ? "事件" : "事故";
|
const typeName = props.type === 1 ? "事件" : "事故";
|
||||||
|
|
@ -70,18 +68,28 @@ function Accident(props) {
|
||||||
}}
|
}}
|
||||||
toolBarRender={() => (
|
toolBarRender={() => (
|
||||||
<Space>
|
<Space>
|
||||||
{!props.isSupervise && props.permission(props.addPermission) &&
|
{!props.isSupervise && props.permission(props.addPermission)
|
||||||
<Button type="primary" icon={<AddIcon />} onClick={() => setAddModalVisible(true)}>新增</Button>
|
&& <Button type="primary" icon={<AddIcon />} onClick={() => setAddModalVisible(true)}>新增</Button>}
|
||||||
}
|
{props.permission(props.exportPermission)
|
||||||
{props.permission(props.exportPermission) &&
|
&& (
|
||||||
<Button type="primary" loading={loading} icon={<ExportIcon />} ghost onClick={async () => {
|
<Button
|
||||||
|
type="primary"
|
||||||
|
loading={loading}
|
||||||
|
icon={<ExportIcon />}
|
||||||
|
ghost
|
||||||
|
onClick={async () => {
|
||||||
const exportParams = getUrlCriteriaQuery("searchFormKeys", "searchFormValues");
|
const exportParams = getUrlCriteriaQuery("searchFormKeys", "searchFormValues");
|
||||||
|
|
||||||
await downloadBlob("/accident/accident/export", { params: { ...exportParams, eqType: props.type } })
|
await downloadBlob("/accident/accident/export", { params: { ...exportParams, eqType: props.type } });
|
||||||
}}>全部导出</Button>
|
}}
|
||||||
}
|
>
|
||||||
{!props.isSupervise && props.permission(props.deleteBatchPermission) &&
|
全部导出
|
||||||
<Button icon={<DeleteIcon />}
|
</Button>
|
||||||
|
)}
|
||||||
|
{!props.isSupervise && props.permission(props.deleteBatchPermission)
|
||||||
|
&& (
|
||||||
|
<Button
|
||||||
|
icon={<DeleteIcon />}
|
||||||
ghost
|
ghost
|
||||||
type="primary"
|
type="primary"
|
||||||
danger
|
danger
|
||||||
|
|
@ -101,7 +109,7 @@ function Accident(props) {
|
||||||
>
|
>
|
||||||
批量删除
|
批量删除
|
||||||
</Button>
|
</Button>
|
||||||
}
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
)}
|
)}
|
||||||
columns={[
|
columns={[
|
||||||
|
|
@ -127,7 +135,8 @@ function Accident(props) {
|
||||||
>
|
>
|
||||||
查看
|
查看
|
||||||
</Button>
|
</Button>
|
||||||
{!props.isSupervise && props.permission(props.editPermission) &&
|
{!props.isSupervise && props.permission(props.editPermission)
|
||||||
|
&& (
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
@ -138,8 +147,9 @@ function Accident(props) {
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</Button>
|
</Button>
|
||||||
}
|
)}
|
||||||
{!props.isSupervise && props.permission(props.deletePermission) &&
|
{!props.isSupervise && props.permission(props.deletePermission)
|
||||||
|
&& (
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
danger
|
danger
|
||||||
|
|
@ -156,14 +166,15 @@ function Accident(props) {
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
</Button>
|
</Button>
|
||||||
}
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
{...tableProps}
|
{...tableProps}
|
||||||
/>
|
/>
|
||||||
{addModalVisible && <AddModal
|
{addModalVisible && (
|
||||||
|
<AddModal
|
||||||
currentId={currentId}
|
currentId={currentId}
|
||||||
accidentId={accidentId}
|
accidentId={accidentId}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
|
|
@ -174,9 +185,11 @@ function Accident(props) {
|
||||||
type={props.type}
|
type={props.type}
|
||||||
typeName={typeName}
|
typeName={typeName}
|
||||||
getData={getData}
|
getData={getData}
|
||||||
/>}
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{infoModalVisible && <InfoModal
|
{infoModalVisible && (
|
||||||
|
<InfoModal
|
||||||
currentId={currentId}
|
currentId={currentId}
|
||||||
accidentId={accidentId}
|
accidentId={accidentId}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
|
|
@ -186,7 +199,8 @@ function Accident(props) {
|
||||||
}}
|
}}
|
||||||
typeName={typeName}
|
typeName={typeName}
|
||||||
getData={getData}
|
getData={getData}
|
||||||
/>}
|
/>
|
||||||
|
)}
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -218,7 +232,7 @@ function AddModalComponent(props) {
|
||||||
const values = {
|
const values = {
|
||||||
...data,
|
...data,
|
||||||
imageFiles,
|
imageFiles,
|
||||||
attachmentFiles
|
attachmentFiles,
|
||||||
};
|
};
|
||||||
|
|
||||||
form.setFieldsValue(values);
|
form.setFieldsValue(values);
|
||||||
|
|
@ -255,31 +269,32 @@ function AddModalComponent(props) {
|
||||||
await uploadFile({
|
await uploadFile({
|
||||||
single: false,
|
single: false,
|
||||||
files: values.imageFiles,
|
files: values.imageFiles,
|
||||||
params: { type: UPLOAD_FILE_TYPE_ENUM["136"], foreignKey: accidentId }
|
params: { type: UPLOAD_FILE_TYPE_ENUM["136"], foreignKey: accidentId },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (values.attachmentFiles && values.attachmentFiles.length > 0) {
|
if (values.attachmentFiles && values.attachmentFiles.length > 0) {
|
||||||
await uploadFile({
|
await uploadFile({
|
||||||
single: false,
|
single: false,
|
||||||
files: values.attachmentFiles,
|
files: values.attachmentFiles,
|
||||||
params: { type: UPLOAD_FILE_TYPE_ENUM["137"], foreignKey: accidentId }
|
params: { type: UPLOAD_FILE_TYPE_ENUM["137"], foreignKey: accidentId },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存基本信息
|
// 保存基本信息
|
||||||
await props["accidentEdit"]({ ...values, ...dicNames, id: props.currentId });
|
await props["accidentEdit"]({ ...values, ...dicNames, id: props.currentId });
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// 上传文件
|
// 上传文件
|
||||||
const { id } = await uploadFile({
|
const { id } = await uploadFile({
|
||||||
single: false,
|
single: false,
|
||||||
files: values.imageFiles,
|
files: values.imageFiles,
|
||||||
params: { type: UPLOAD_FILE_TYPE_ENUM["136"], foreignKey: "" }
|
params: { type: UPLOAD_FILE_TYPE_ENUM["136"], foreignKey: "" },
|
||||||
});
|
});
|
||||||
if (values.attachmentFiles && values.attachmentFiles.length > 0) {
|
if (values.attachmentFiles && values.attachmentFiles.length > 0) {
|
||||||
await uploadFile({
|
await uploadFile({
|
||||||
single: false,
|
single: false,
|
||||||
files: values.attachmentFiles,
|
files: values.attachmentFiles,
|
||||||
params: { type: UPLOAD_FILE_TYPE_ENUM["137"], foreignKey: id }
|
params: { type: UPLOAD_FILE_TYPE_ENUM["137"], foreignKey: id },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -294,7 +309,8 @@ function AddModalComponent(props) {
|
||||||
onCancel();
|
onCancel();
|
||||||
props.getData();
|
props.getData();
|
||||||
message.success("操作成功");
|
message.success("操作成功");
|
||||||
} catch (error) {
|
}
|
||||||
|
catch (error) {
|
||||||
message.error("操作失败,请重试");
|
message.error("操作失败,请重试");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -318,8 +334,8 @@ function AddModalComponent(props) {
|
||||||
options={[
|
options={[
|
||||||
{ name: "incidentNumber", label: `${typeName}案号` },
|
{ name: "incidentNumber", label: `${typeName}案号` },
|
||||||
{ name: "incidentName", label: `${typeName}名称` },
|
{ name: "incidentName", label: `${typeName}名称` },
|
||||||
{ name: "incidentType", label: `${typeName}类型`, render: <DictionarySelect dictValue="accidentType" onGetLabel={(label) => setDicNames({ ...dicNames, incidentTypeName: label })} /> },
|
{ name: "incidentType", label: `${typeName}类型`, render: <DictionarySelect dictValue="accidentType" onGetLabel={label => setDicNames({ ...dicNames, incidentTypeName: label })} /> },
|
||||||
{ name: "incidentLevel", label: `${typeName}等级`, render: <DictionarySelect dictValue="accidentLevel" onGetLabel={(label) => setDicNames({ ...dicNames, incidentLevelName: label })} /> },
|
{ name: "incidentLevel", label: `${typeName}等级`, render: <DictionarySelect dictValue="accidentLevel" onGetLabel={label => setDicNames({ ...dicNames, incidentLevelName: label })} /> },
|
||||||
{ name: "location", label: `${typeName}发生地点` },
|
{ name: "location", label: `${typeName}发生地点` },
|
||||||
{ name: "incidentDate", label: `${typeName}发生时间`, render: FORM_ITEM_RENDER_ENUM.DATETIME },
|
{ name: "incidentDate", label: `${typeName}发生时间`, render: FORM_ITEM_RENDER_ENUM.DATETIME },
|
||||||
{ name: "directLoss", label: "直接经济损失(万元)", render: FORM_ITEM_RENDER_ENUM.NUMBER, componentProps: { precision: 2, min: 0 }, required: false },
|
{ name: "directLoss", label: "直接经济损失(万元)", render: FORM_ITEM_RENDER_ENUM.NUMBER, componentProps: { precision: 2, min: 0 }, required: false },
|
||||||
|
|
@ -344,7 +360,7 @@ function AddModalComponent(props) {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
span: 24
|
span: 24,
|
||||||
},
|
},
|
||||||
// 添加附件上传
|
// 添加附件上传
|
||||||
{
|
{
|
||||||
|
|
@ -359,7 +375,7 @@ function AddModalComponent(props) {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
span: 24
|
span: 24,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
@ -371,7 +387,7 @@ function InfoModalComponent(props) {
|
||||||
const [info, setInfo] = useState({});
|
const [info, setInfo] = useState({});
|
||||||
const [imageFiles, setImageFiles] = useState([]);
|
const [imageFiles, setImageFiles] = useState([]);
|
||||||
const [attachmentFiles, setAttachmentFiles] = useState([]);
|
const [attachmentFiles, setAttachmentFiles] = useState([]);
|
||||||
const { loading, downloadFile } = useDownloadFile()
|
const { loading, downloadFile } = useDownloadFile();
|
||||||
const typeName = props.typeName;
|
const typeName = props.typeName;
|
||||||
|
|
||||||
const { getFile } = useGetFile();
|
const { getFile } = useGetFile();
|
||||||
|
|
@ -432,7 +448,7 @@ function InfoModalComponent(props) {
|
||||||
label: `${typeName}图片`,
|
label: `${typeName}图片`,
|
||||||
children: (
|
children: (
|
||||||
<PreviewImg files={imageFiles} />
|
<PreviewImg files={imageFiles} />
|
||||||
)
|
),
|
||||||
},
|
},
|
||||||
// 显示附件
|
// 显示附件
|
||||||
{
|
{
|
||||||
|
|
@ -448,7 +464,7 @@ function InfoModalComponent(props) {
|
||||||
))}
|
))}
|
||||||
{attachmentFiles.length === 0 && <span>无</span>}
|
{attachmentFiles.length === 0 && <span>无</span>}
|
||||||
</div>
|
</div>
|
||||||
)
|
),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@ import Accident from "../Accident/components/Accident";
|
||||||
|
|
||||||
function AccidentContainer(props) {
|
function AccidentContainer(props) {
|
||||||
return (
|
return (
|
||||||
<Accident type={1}
|
<Accident
|
||||||
addPermission={"zcloud-event-add"}
|
type={1}
|
||||||
editPermission={"zcloud-event-edit"}
|
addPermission="zcloud-event-add"
|
||||||
deletePermission={"zcloud-event-delete"}
|
editPermission="zcloud-event-edit"
|
||||||
deleteBatchPermission={"zcloud-event-delete-batch"}
|
deletePermission="zcloud-event-delete"
|
||||||
exportPermission={"zcloud-event-export"}
|
deleteBatchPermission="zcloud-event-delete-batch"
|
||||||
|
exportPermission="zcloud-event-export"
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,62 @@
|
||||||
import Accident from "../../Accident/components/Accident";
|
import { Permission } from "@cqsjjb/jjb-common-decorator/permission";
|
||||||
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||||
|
import { Form } from "antd";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import Page from "zy-react-library/components/Page";
|
||||||
|
import Table from "zy-react-library/components/Table";
|
||||||
|
import useDictionary from "zy-react-library/hooks/useDictionary";
|
||||||
import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery";
|
import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery";
|
||||||
|
import useTable from "zy-react-library/hooks/useTable";
|
||||||
|
import { NS_ACCIDENT } from "~/enumerate/namespace";
|
||||||
|
|
||||||
|
function Bulletin(props) {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const query = useGetUrlQuery();
|
||||||
|
const { getDictionary } = useDictionary();
|
||||||
|
const [accidentType, setAccidentType] = useState([]);
|
||||||
|
const [countByIncidentType, setCountByIncidentType] = useState([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getDictionary({ dictValue: "accidentType" }).then((res) => {
|
||||||
|
setAccidentType(res);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const { tableProps } = useTable(props["countByIncidentType"], {
|
||||||
|
form,
|
||||||
|
usePagination: false,
|
||||||
|
params: {
|
||||||
|
eqAccidentType: query.eqAccidentType,
|
||||||
|
corpinfoId: query.corpinfoId,
|
||||||
|
},
|
||||||
|
onSuccess: ({ data }) => {
|
||||||
|
setCountByIncidentType(data);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const getAccidentCount = (corpinfoId, incidentType) => {
|
||||||
|
return countByIncidentType.find(item => item.corpinfoId === corpinfoId && item.incidentType === incidentType)?.count || 0;
|
||||||
|
};
|
||||||
|
|
||||||
function AccidentContainer(props) {
|
|
||||||
const {corpinfoId,eqAccidentType} = useGetUrlQuery();
|
|
||||||
return (
|
return (
|
||||||
<Accident type={Number(eqAccidentType)}
|
<Page isShowAllAction={false}>
|
||||||
isSupervise={true}
|
|
||||||
corpinfoId={corpinfoId}
|
<Table
|
||||||
exportPermission = { "zcloud-accident-supervise-export" }
|
columns={[
|
||||||
{...props}
|
...accidentType.map(item => ({
|
||||||
|
dataIndex: `countByCorpinfoAndType_${item.dictValue}`,
|
||||||
|
title: `${item.dictLabel}`,
|
||||||
|
render: (_, record) => (
|
||||||
|
getAccidentCount(record.corpinfoId, item.dictValue)
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
]}
|
||||||
|
{...tableProps}
|
||||||
|
dataSource={[{ corpinfoId: query.corpinfoId || countByIncidentType[0]?.corpinfoId }]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AccidentContainer;
|
export default Connect([NS_ACCIDENT], true)(Permission(Bulletin));
|
||||||
|
|
|
||||||
|
|
@ -1,97 +1,81 @@
|
||||||
import {Connect} from "@cqsjjb/jjb-dva-runtime";
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import {Button, Form, Space} from "antd";
|
import { Button, Form } from "antd";
|
||||||
import {useEffect, useState} from "react";
|
import { useState } from "react";
|
||||||
|
import Page from "zy-react-library/components/Page";
|
||||||
import Search from "zy-react-library/components/Search";
|
import Search from "zy-react-library/components/Search";
|
||||||
import Table from "zy-react-library/components/Table";
|
import Table from "zy-react-library/components/Table";
|
||||||
import useTable from "zy-react-library/hooks/useTable";
|
import useTable from "zy-react-library/hooks/useTable";
|
||||||
import {NS_ACCIDENT} from "~/enumerate/namespace";
|
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) {
|
function SuperviseAccident(props) {
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const {getDictionary} = useDictionary();
|
|
||||||
const [accidentType, setAccidentType] = useState([]);
|
|
||||||
const {getUrlCriteriaQuery} = useUrlQueryCriteria();
|
|
||||||
const [accidentCountByCorpinfoAndType, setAccidentCountByCorpinfoAndType] = useState([]);
|
const [accidentCountByCorpinfoAndType, setAccidentCountByCorpinfoAndType] = useState([]);
|
||||||
useEffect(() => {
|
|
||||||
getDictionary({dictValue: "accidentType"}).then(res => {
|
|
||||||
setAccidentType(res);
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const getAccidentCountByCorpinfoAndType=async (corpinfoIds,type)=>{
|
const getAccidentCountByCorpinfoAndType = async (corpinfoIds, type) => {
|
||||||
const {data} = await props["accidentCountByCorpinfoAndType"]({corpinfoIds,eqAccidentType:type})
|
const { data } = await props["accidentCountByCorpinfoAndType"]({ corpinfoIds, eqAccidentType: type });
|
||||||
setAccidentCountByCorpinfoAndType(data)
|
setAccidentCountByCorpinfoAndType(data);
|
||||||
}
|
};
|
||||||
|
|
||||||
const {tableProps, getData} = useTable(props["getCorpInfoList"], {
|
const { tableProps, getData } = useTable(props["getCorpInfoList"], {
|
||||||
form,
|
form,
|
||||||
params: {
|
params: {
|
||||||
inType: [0,1,6],
|
inType: [0, 1, 6],
|
||||||
},
|
},
|
||||||
onSuccess: ({data}) => {
|
onSuccess: ({ data }) => {
|
||||||
getAccidentCountByCorpinfoAndType(data.map(item => item.id),form.getFieldValue("eqAccidentType"))
|
getAccidentCountByCorpinfoAndType(data.map(item => item.id), form.getFieldValue("eqAccidentType"));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const getAccidentCount=(id,type)=>{
|
const getAccidentTotal = (id, key) => {
|
||||||
return accidentCountByCorpinfoAndType.find(item => item.corpinfoId === id && item.incidentType === type)?.[`count`] || 0;
|
return accidentCountByCorpinfoAndType.find(item => item.corpinfoId === id)?.[key] || 0;
|
||||||
}
|
};
|
||||||
const searchType = getUrlCriteriaQuery("searchFormKeys","searchFormValues").eqAccidentType;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page isShowAllAction={false}>
|
<Page isShowAllAction={false}>
|
||||||
<Search
|
<Search
|
||||||
form={form}
|
form={form}
|
||||||
values={{
|
|
||||||
eqAccidentType: "1",
|
|
||||||
}}
|
|
||||||
onFinish={getData}
|
onFinish={getData}
|
||||||
options={[
|
options={[
|
||||||
{name: "likecorpName", label: `公司名称`},
|
{ name: "likecorpName", label: `公司名称` },
|
||||||
{name: "eqAccidentType", label: `类型`, render: FORM_ITEM_RENDER_ENUM.SELECT, items: TYPE,componentProps: {allowClear: false }},
|
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<Table
|
<Table
|
||||||
rowSelection={{
|
|
||||||
selectedRowKeys,
|
|
||||||
onChange: selectedRowKeys => setSelectedRowKeys(selectedRowKeys),
|
|
||||||
}}
|
|
||||||
columns={[
|
columns={[
|
||||||
{dataIndex: "corpName", title: `公司名称`},
|
{ dataIndex: "corpName", title: `公司名称` },
|
||||||
...accidentType.map(item => ({
|
|
||||||
dataIndex: `countByCorpinfoAndType_${item.dictValue}`,
|
|
||||||
title: `${item.dictLabel}`,
|
|
||||||
render: (_, record) => (
|
|
||||||
getAccidentCount(record.id,item.dictValue)
|
|
||||||
),
|
|
||||||
})),
|
|
||||||
{
|
{
|
||||||
title: "操作",
|
dataIndex: "eventCount",
|
||||||
width: 160,
|
title: "事件总数",
|
||||||
fixed: "right",
|
width: 180,
|
||||||
render: (_, record) => (
|
render: (_, record) => (
|
||||||
<Space>
|
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
props.history.push(`./info?corpinfoId=${record.id}&eqAccidentType=${searchType}`)
|
props.history.push(`./info?corpinfoId=${record.id}&eqAccidentType=1`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
查看
|
{getAccidentTotal(record.id, "eventCount")}
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
dataIndex: "accidentCount",
|
||||||
|
title: "事故总数",
|
||||||
|
width: 180,
|
||||||
|
render: (_, record) => (
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
onClick={() => {
|
||||||
|
props.history.push(`./info?corpinfoId=${record.id}&eqAccidentType=2`);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{ getAccidentTotal(record.id, "accidentCount")}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
]}
|
]}
|
||||||
{...tableProps}
|
{...tableProps}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue