提交 d8784ac8 authored 作者: 钟是志's avatar 钟是志

当前位置:

统计分析管理/宿舍入住统计 打印修改
上级 832b04ed
import React, { useEffect, useRef, useState } from 'react';
import ReactToPrint from 'react-to-print';
import styles from './index.less';
import { Button } from 'antd';
import IframeForRenderForm from './IframeForRenderForm';
import { getOneStopConfig } from '@/webPublic/zyd_public/utils/utils';
export default function PrintQnmz(props) {
const { location: {pathname} } = props;
const componentRef = useRef();
const [showPrint, setShowPrint] = useState(false);
const id = getOneStopConfig(pathname);
useEffect(() => {
setTimeout(() => {
setShowPrint(true);
}, 2000);
}, []);
return (<div>
<div id={'showButtonDiv'} className={styles.buttonDiv}>
{
showPrint ? <ReactToPrint
trigger={() => <Button type={'primary'}>打印</Button>}
content={() => componentRef.current}
onBeforePrint={() => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, 2000);
});
}}
/> : <div>正在加载信息, 请稍等</div>
}
{
showPrint && window.history.length > 1 &&
<Button type={'danger'} onClick={() => {
window.history.go(-1);
}}>返回</Button>
}
</div>
<div ref={componentRef}>
<div style={{
minHeight: '21cm',
minWidth: '29cm',
width: '42cm',
pageBreakAfter: 'always',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}>
<IframeForRenderForm id={id} {...props} />
</div>
</div>
</div>);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论