master
parent
2c0355049d
commit
3a103e5c93
|
|
@ -0,0 +1,80 @@
|
||||||
|
import { Button, Descriptions, Modal } from "antd";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import PreviewImg from "zy-react-library/components/PreviewImg";
|
||||||
|
import PreviewPdf from "zy-react-library/components/PreviewPdf";
|
||||||
|
import { UPLOAD_FILE_TYPE_ENUM } from "zy-react-library/enum/uploadFile/gwj";
|
||||||
|
import useGetFile from "zy-react-library/hooks/useGetFile";
|
||||||
|
import { getFileSuffix } from "zy-react-library/utils";
|
||||||
|
|
||||||
|
const ViewProjectReviewDetailsModal = (props) => {
|
||||||
|
const { getFile } = useGetFile();
|
||||||
|
const getData = async () => {
|
||||||
|
const file = await getFile({
|
||||||
|
eqType: UPLOAD_FILE_TYPE_ENUM["151"],
|
||||||
|
eqForeignKey: props.data.projectFileId,
|
||||||
|
});
|
||||||
|
props.data.files = file;
|
||||||
|
};
|
||||||
|
const previewFile = () => {
|
||||||
|
const imgFiles = [];
|
||||||
|
const pdfFiles = [];
|
||||||
|
const files = props.data?.files || [];
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
if (getFileSuffix(files[i].name) === "pdf") {
|
||||||
|
pdfFiles.push(files[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
imgFiles.push(files[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (imgFiles.length > 0 && pdfFiles.length > 0) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div><PreviewImg files={imgFiles} /></div>
|
||||||
|
<div style={{ marginTop: 20 }}><PreviewPdf files={pdfFiles} urlKey="url" /></div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (imgFiles.length > 0) {
|
||||||
|
return <PreviewImg files={imgFiles} />;
|
||||||
|
}
|
||||||
|
if (pdfFiles.length > 0) {
|
||||||
|
return <PreviewPdf files={pdfFiles} />;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
getData();
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title="项目资料信息"
|
||||||
|
width={800}
|
||||||
|
open
|
||||||
|
maskClosable={false}
|
||||||
|
onCancel={props.onCancel}
|
||||||
|
footer={[
|
||||||
|
<Button key="cancel" onClick={props.onCancel}>取消</Button>,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Descriptions
|
||||||
|
bordered
|
||||||
|
column={1}
|
||||||
|
styles={{ label: { width: 200 } }}
|
||||||
|
items={[
|
||||||
|
{ label: "资料名称", children: props.data.dataName },
|
||||||
|
{
|
||||||
|
label: "有效时间",
|
||||||
|
children: (() => {
|
||||||
|
const start = props.data?.startValidityPeriod;
|
||||||
|
const end = props.data?.endValidityPeriod;
|
||||||
|
return start && end ? `${start}至${end}` : "-";
|
||||||
|
})(),
|
||||||
|
},
|
||||||
|
{ label: "资质", children: previewFile() },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ViewProjectReviewDetailsModal;
|
||||||
Loading…
Reference in New Issue