diff --git a/accident/accident.html b/accident/accident.html new file mode 100644 index 0000000..1e0727d --- /dev/null +++ b/accident/accident.html @@ -0,0 +1,23 @@ +--
\ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js index 06fcf00..b695218 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,10 +1,8 @@ import antfu from "@antfu/eslint-config"; export default antfu({ - formatters: { - html: false, - css: true, - }, + // Remove formatter configuration that might be causing issues + formatters: false, test: false, typescript: true, react: true, diff --git a/jjb.config.js b/jjb.config.js index 430127f..274bbea 100644 --- a/jjb.config.js +++ b/jjb.config.js @@ -9,7 +9,7 @@ module.exports = { // 应用后端分支名称,部署上线需要 javaGitBranch: "", // 接口服务地址 - API_HOST: "http://192.168.10.37:80", + API_HOST: "http://192.168.20.100:30140", }, production: { // 应用后端分支名称,部署上线需要 @@ -24,7 +24,7 @@ module.exports = { contextInject: { // 应用Key appKey: "", - fileUrl: "附件地址", + fileUrl: "http://192.168.20.240:9787/mnt", }, // public/index.html注入全局变量 windowInject: { diff --git a/package.json b/package.json index dce1eb3..1af600e 100644 --- a/package.json +++ b/package.json @@ -25,12 +25,12 @@ "@cqsjjb/jjb-dva-runtime": "latest", "@cqsjjb/jjb-react-admin-component": "latest", "ahooks": "^3.9.5", - "antd": "latest", + "antd": "5.27.6", "dayjs": "^1.11.7", "lodash-es": "^4.17.21", "react": "^18.2.0", "react-dom": "^18.2.0", - "zy-react-library": "^1.0.34" + "zy-react-library": "^1.0.127" }, "devDependencies": { "@antfu/eslint-config": "^5.4.1", diff --git a/public/index.html b/public/index.html index caf0d15..54af0fc 100644 --- a/public/index.html +++ b/public/index.html @@ -49,6 +49,6 @@ <% const { root } = $element; %> -
+
diff --git a/src/api/accident/index.js b/src/api/accident/index.js index 07594ea..6f85108 100644 --- a/src/api/accident/index.js +++ b/src/api/accident/index.js @@ -22,3 +22,17 @@ export const accidentBatchDelete = declareRequest( ); export const accidentInfo = declareRequest('accidentLoading', 'Get > /accident/accident/{id}'); +export const accidentCountByCorpinfoAndType = declareRequest( + 'accidentLoading', + 'Post > @/accident/accident/countByCorpinfoAndType' +); + +export const getCorpInfoList = declareRequest( + 'accidentLoading', + 'Post > @/basic-info/corpInfo/list' +); + +export const accidentExport = declareRequest( + 'accidentLoading', + 'Post > @/accident/accident/export' +); \ No newline at end of file diff --git a/src/pages/Container/Accident/components/Accident/index.js b/src/pages/Container/Accident/components/Accident/index.js index d0562d1..c9603d9 100644 --- a/src/pages/Container/Accident/components/Accident/index.js +++ b/src/pages/Container/Accident/components/Accident/index.js @@ -1,26 +1,41 @@ +import React, { useEffect, useState } from "react"; import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { Button, Descriptions, Form, message, Modal, Space } from "antd"; -import { useEffect, useState } from "react"; import FormBuilder from "zy-react-library/components/FormBuilder"; import Search from "zy-react-library/components/Search"; import Table from "zy-react-library/components/Table"; +import Upload from "zy-react-library/components/Upload"; import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender"; +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 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 HeaderBack from "zy-react-library/components/HeaderBack"; +import DictionarySelect from "zy-react-library/components/Select/Dictionary"; +import useDownloadBlob from "zy-react-library/hooks/useDownloadBlob"; +import useUrlQueryCriteria from "zy-react-library/hooks/useUrlQueryCriteria"; + function Accident(props) { const [addModalVisible, setAddModalVisible] = useState(false); const [infoModalVisible, setInfoModalVisible] = useState(false); const [currentId, setCurrentId] = useState(""); + const [accidentId, setAccidentId] = useState(""); const [selectedRowKeys, setSelectedRowKeys] = useState([]); + const { loading, downloadBlob } = useDownloadBlob(); + const {getUrlCriteriaQuery} = useUrlQueryCriteria(); const [form] = Form.useForm(); const { tableProps, getData } = useTable(props["accidentList"], { form, params: { eqType: props.type, + eqCorpinfoId: props.corpinfoId, }, transform: data => ({ geIncidentDate: data.incidentDate?.[0], @@ -30,14 +45,14 @@ function Accident(props) { const typeName = props.type === 1 ? "事件" : "事故"; return (
+ {props.isSupervise && } }, + { name: "eqIncidentLevel", label: `${typeName}级别`, render: }, { name: "likeLocation", label: `${typeName}发生地点` }, { name: "incidentDate", label: `${typeName}发生时间`, render: FORM_ITEM_RENDER_ENUM.DATE_RANGE }, ]} @@ -49,25 +64,34 @@ function Accident(props) { }} toolBarRender={() => ( - - + + {!props.isSupervise && ( + + + + + )} )} columns={[ @@ -85,64 +109,72 @@ function Accident(props) { type="link" onClick={() => { setCurrentId(record.id); + setAccidentId(record.accidentId); setInfoModalVisible(true); }} > 查看 - - + {!props.isSupervise && + + } + {!props.isSupervise && + + } ), }, ]} {...tableProps} /> - { setAddModalVisible(false); setCurrentId(""); + setAccidentId(""); }} type={props.type} typeName={typeName} getData={getData} - /> + />} - { setInfoModalVisible(false); setCurrentId(""); + setAccidentId(""); }} typeName={typeName} getData={getData} - /> + />}
); } @@ -150,32 +182,117 @@ function Accident(props) { function AddModalComponent(props) { const [form] = Form.useForm(); const typeName = props.typeName; + const [dicNames, setDicNames] = useState({}); + + // 文件相关状态和hooks + const [deleteImageFiles, setDeleteImageFiles] = useState([]); + const [deleteAttachmentFiles, setDeleteAttachmentFiles] = useState([]); + const { deleteFile } = useDeleteFile(); + const { uploadFile } = useUploadFile(); + const { getFile } = useGetFile(); + useEffect(() => { if (props.currentId) { - props["accidentInfo"]({ id: props.currentId }).then((res) => { - form.setFieldsValue(res.data); - }); + loadData(); } }, [props.currentId]); + + const loadData = async () => { + const { data } = await props["accidentInfo"]({ id: props.currentId }); + // 获取已上传的文件 + const imageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["136"], eqForeignKey: props.currentId }); + const attachmentFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["137"], eqForeignKey: props.currentId }); + + const values = { + ...data, + imageFiles, + attachmentFiles + }; + + form.setFieldsValue(values); + setDicNames({ + incidentTypeName: data.incidentTypeName, + incidentLevelName: data.incidentLevelName, + }); + }; + const onCancel = () => { form.resetFields(); + setDeleteImageFiles([]); + setDeleteAttachmentFiles([]); props.onCancel(); }; + const submit = async (values) => { - if (props.currentId) { - await props["accidentEdit"]({ ...values, id: props.currentId }) - } else { - await props["accidentAdd"]({ ...values, type: props.type, id: 485738919865 }); + try { + // 保存基本信息 + const accidentId = props.accidentId; + + // 编辑模式 + if (accidentId) { + // 删除标记为删除的文件 + if (deleteImageFiles.length > 0) { + await deleteFile({ single: false, files: deleteImageFiles }); + } + if (deleteAttachmentFiles.length > 0) { + await deleteFile({ single: false, files: deleteAttachmentFiles }); + } + + // 上传新文件 + if (values.imageFiles && values.imageFiles.length > 0) { + await uploadFile({ + single: false, + files: values.imageFiles, + params: { type: UPLOAD_FILE_TYPE_ENUM["136"], foreignKey: accidentId } + }); + } + if (values.attachmentFiles && values.attachmentFiles.length > 0) { + await uploadFile({ + single: false, + files: values.attachmentFiles, + params: { type: UPLOAD_FILE_TYPE_ENUM["137"], foreignKey: accidentId } + }); + } + + // 保存基本信息 + await props["accidentEdit"]({ ...values, ...dicNames, id: props.currentId }); + } else { + // 上传文件 + const { id } = await uploadFile({ + single: false, + files: values.imageFiles, + params: { type: UPLOAD_FILE_TYPE_ENUM["136"], foreignKey: "" } + }); + if (values.attachmentFiles && values.attachmentFiles.length > 0) { + await uploadFile({ + single: false, + files: values.attachmentFiles, + params: { type: UPLOAD_FILE_TYPE_ENUM["137"], foreignKey: id } + }); + } + + const result = await props["accidentAdd"]({ + ...values, + ...dicNames, + accidentId: id, + type: props.type, + }); + } + + onCancel(); + props.getData(); + message.success("操作成功"); + } catch (error) { + message.error("操作失败,请重试"); + console.error("提交失败:", error); } - onCancel(); - props.getData(); }; return ( @@ -188,8 +305,8 @@ function AddModalComponent(props) { options={[ { name: "incidentNumber", label: `${typeName}案号` }, { name: "incidentName", label: `${typeName}名称` }, - { name: "incidentType", label: `${typeName}类型` }, - { name: "incidentLevel", label: `${typeName}级别` }, + { name: "incidentType", label: `${typeName}类型`, render: setDicNames({ ...dicNames, incidentTypeName: label })} /> }, + { name: "incidentLevel", label: `${typeName}级别`, render: setDicNames({ ...dicNames, incidentLevelName: label })} /> }, { name: "incidentNature", label: `${typeName}性质` }, { name: "location", label: `${typeName}发生地点` }, { name: "incidentDate", label: `${typeName}发生时间`, render: FORM_ITEM_RENDER_ENUM.DATETIME }, @@ -203,6 +320,33 @@ function AddModalComponent(props) { { name: "suggestions", label: "考核建议", render: FORM_ITEM_RENDER_ENUM.TEXTAREA }, { name: "measures", label: "整改措施", render: FORM_ITEM_RENDER_ENUM.TEXTAREA }, { name: "reportDate", label: "报出日期", render: FORM_ITEM_RENDER_ENUM.DATETIME }, + // 添加图片上传 + { + name: "imageFiles", + label: "事故图片", + render: ( + { + setDeleteImageFiles([...deleteImageFiles, file]); + }} + /> + ), + span: 24 + }, + // 添加附件上传 + { + name: "attachmentFiles", + label: "事故附件", + render: ( + { + setDeleteAttachmentFiles([...deleteAttachmentFiles, file]); + }} + /> + ), + span: 24 + }, ]} /> @@ -211,18 +355,34 @@ function AddModalComponent(props) { function InfoModalComponent(props) { const [info, setInfo] = useState({}); + const [imageFiles, setImageFiles] = useState([]); + const [attachmentFiles, setAttachmentFiles] = useState([]); const typeName = props.typeName; + + const { getFile } = useGetFile(); + useEffect(() => { if (props.currentId) { - props["accidentInfo"]({ id: props.currentId }).then((res) => { - setInfo(res.data); - }); + loadData(); } }, [props.currentId]); + const loadData = async () => { + // 获取基本信息 + const { data } = await props["accidentInfo"]({ id: props.currentId }); + setInfo(data); + + // 获取图片和附件 + const images = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["136"], eqForeignKey: props.currentId }); + const attachments = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["137"], eqForeignKey: props.currentId }); + + setImageFiles(images); + setAttachmentFiles(attachments); + }; + return ( 关闭} title={`查看${typeName}`} @@ -251,6 +411,38 @@ function InfoModalComponent(props) { { children: info.suggestions, label: "考核建议" }, { children: info.measures, label: "整改措施" }, { children: info.reportDate, label: "报出日期" }, + // 显示图片 + { + label: "事故图片", + children: ( +
+ {imageFiles.map((file, index) => ( +
+ + {file.originalName} + +
+ ))} + {imageFiles.length === 0 && } +
+ ) + }, + // 显示附件 + { + label: "事故附件", + children: ( +
+ {attachmentFiles.map((file, index) => ( +
+ + {file.originalName} + +
+ ))} + {attachmentFiles.length === 0 && } +
+ ) + }, ]} />
diff --git a/src/pages/Container/SuperviseAccident/Info/index.js b/src/pages/Container/SuperviseAccident/Info/index.js new file mode 100644 index 0000000..f478222 --- /dev/null +++ b/src/pages/Container/SuperviseAccident/Info/index.js @@ -0,0 +1,15 @@ +import Accident from "../../Accident/components/Accident"; +import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery"; + +function AccidentContainer(props) { + const {corpinfoId,eqAccidentType} = useGetUrlQuery(); + return ( + + ); +} + +export default AccidentContainer; diff --git a/src/pages/Container/SuperviseAccident/List/index.js b/src/pages/Container/SuperviseAccident/List/index.js new file mode 100644 index 0000000..eec4566 --- /dev/null +++ b/src/pages/Container/SuperviseAccident/List/index.js @@ -0,0 +1,98 @@ +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 ( +
+ + 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); diff --git a/src/pages/Container/SuperviseAccident/index.js b/src/pages/Container/SuperviseAccident/index.js new file mode 100644 index 0000000..a391c30 --- /dev/null +++ b/src/pages/Container/SuperviseAccident/index.js @@ -0,0 +1,4 @@ +function SuperviseAccidentContainer(props) { + return props.children; +} +export default SuperviseAccidentContainer; \ No newline at end of file