import React, { useEffect, useState } from 'react'; import { Modal, Button } from 'antd'; import PDF from 'react-pdf-js'; import ProCard from '@ant-design/pro-card'; import FileDown from '@/utils/Download'; import { checkFileExist } from './service'; /** * Pdf Modal弹窗公共组件 * 2021.8.25 zhoujianlong 根据定标结果通知书的弹出窗口改造初始版本,增加备注 */ interface PdfModalProps { fileId: string; //文档中心id downLoadFileName: string; //下载后的文件名称 modalVisible: boolean; //Modal 弹出还是关闭 onCancel: () => void; //关闭Modal方法 } const PdfModal: React.FC = (props) => { const { fileId, downLoadFileName, modalVisible, onCancel } = props; const [page, setPage] = useState(1); //页码 const [pages, setPages] = useState(0); //总页数 const [fileExist, setFileExist] = useState('0'); //0:未验证,1:验证后有,2:验证后没有 useEffect(() => { //判断文件是否存在 checkFileExist(fileId).then((res) => { if (res !== undefined && res.length > 0) { setFileExist('1'); } else { setFileExist('2'); } }); }, [fileId]); //文档总页码 const onDocumentComplete = (pages: any) => { setPage(1); setPages(pages); }; //上一页 const handlePrevious = () => { setPage(page - 1); }; //下一页 const handleNext = () => { setPage(page + 1); }; //下载链接 const downLoadFile = (fileId: string) => { const returnUrl = '/api/core-service-ebtp-updownload/v1/attachment/download/bid/' + fileId; return returnUrl; }; const modalHeight = (window.innerHeight * 96) / 100; return ( onCancel()} width={'80%'} centered style={{ maxHeight: modalHeight }} bodyStyle={{ maxHeight: modalHeight - 107, overflowY: 'auto' }} footer={[ <> {fileExist == '1' ? ( <> ) : null} , ]} > {fileExist == '0' ? (
) : fileExist == '1' ? ( <> ) : ( 对不起,您所查看的文件不存在,请与系统管理员联系! )} ); }; export default PdfModal;