|
@@ -76,7 +76,7 @@ class ComplexModal extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.onPrint = this.onPrint.bind(this);
|
|
|
- this.doPrint3 = this.doPrint3.bind(this);
|
|
|
+ // this.doPrint3 = this.doPrint3.bind(this);
|
|
|
}
|
|
|
|
|
|
onPrint() {
|
|
@@ -86,41 +86,40 @@ class ComplexModal extends Component {
|
|
|
// printContainer: true,
|
|
|
// operaSupport: false,
|
|
|
// });
|
|
|
- let bdhtml=window.document.body.innerHTML;//获取当前页的html代码
|
|
|
- let sprnstr="<i>111111</i>";//设置打印开始区域
|
|
|
- let eprnstr="<i>222222</i>";//设置打印结束区域
|
|
|
- let prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
|
|
|
- let domWrap = document.createElement('div')
|
|
|
- prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
|
|
|
- domWrap.innerHTML=prnhtml;
|
|
|
- console.log(domWrap)
|
|
|
+ // let bdhtml=window.document.body.innerHTML;//获取当前页的html代码
|
|
|
+ // let sprnstr="<i>111111</i>";//设置打印开始区域
|
|
|
+ // let eprnstr="<i>222222</i>";//设置打印结束区域
|
|
|
+ // let prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
|
|
|
+ // let domWrap = document.createElement('div')
|
|
|
+ // prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
|
|
|
+ // domWrap.innerHTML=prnhtml;
|
|
|
+ // console.log(domWrap)
|
|
|
// window.document.body.innerHTML=prnhtml;
|
|
|
- // window.print()
|
|
|
+ window.print()
|
|
|
// console.log(prnhtml)
|
|
|
}
|
|
|
- doPrint3(){
|
|
|
-
|
|
|
- //判断iframe是否存在,不存在则创建iframe
|
|
|
- var iframe=document.getElementById("print-iframe");
|
|
|
- if(!iframe){
|
|
|
- var el = document.getElementById("printcontent");
|
|
|
- iframe = document.createElement('IFRAME');
|
|
|
- var doc = null;
|
|
|
- iframe.setAttribute("id", "print-iframe");
|
|
|
- iframe.setAttribute('style', 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
|
|
|
- document.body.appendChild(iframe);
|
|
|
- doc = iframe.contentWindow.document;
|
|
|
- //这里可以自定义样式
|
|
|
- //doc.write("<LINK rel="stylesheet" type="text/css" href="css/print.css">");
|
|
|
- doc.write('<div>' + el.innerHTML + '</div>');
|
|
|
- doc.close();
|
|
|
- iframe.contentWindow.focus();
|
|
|
- }
|
|
|
- iframe.contentWindow.print();
|
|
|
- if (navigator.userAgent.indexOf("MSIE") > 0){
|
|
|
- document.body.removeChild(iframe);
|
|
|
- }
|
|
|
- }
|
|
|
+ // doPrint3(){
|
|
|
+ // //判断iframe是否存在,不存在则创建iframe
|
|
|
+ // var iframe=document.getElementById("print-iframe");
|
|
|
+ // if(!iframe){
|
|
|
+ // var el = document.getElementById("printcontent");
|
|
|
+ // iframe = document.createElement('IFRAME');
|
|
|
+ // var doc = null;
|
|
|
+ // iframe.setAttribute("id", "print-iframe");
|
|
|
+ // iframe.setAttribute('style', 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
|
|
|
+ // document.body.appendChild(iframe);
|
|
|
+ // doc = iframe.contentWindow.document;
|
|
|
+ // //这里可以自定义样式
|
|
|
+ // //doc.write("<LINK rel="stylesheet" type="text/css" href="css/print.css">");
|
|
|
+ // doc.write('<div>' + el.innerHTML + '</div>');
|
|
|
+ // doc.close();
|
|
|
+ // iframe.contentWindow.focus();
|
|
|
+ // }
|
|
|
+ // iframe.contentWindow.print();
|
|
|
+ // if (navigator.userAgent.indexOf("MSIE") > 0){
|
|
|
+ // document.body.removeChild(iframe);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
render() {
|
|
|
const { onclose,title,children,footer,shadeClose,icon,width,top,bottom} = this.props;
|
|
@@ -130,17 +129,17 @@ class ComplexModal extends Component {
|
|
|
return ReactDom.createPortal(<div className={style['container']} id="printcontent">
|
|
|
<div className={style['shade']} onClick={shadeClose===false?'':onclose}></div>
|
|
|
|
|
|
- <i>111111</i>
|
|
|
- <div className={style['modal']} style={{width: width?width:'auto', marginLeft:marginLeft, top:top?top+'px':'',bottom:bottom?bottom+'px':''}}>
|
|
|
- <div className={style['close']} onClick={this.doPrint3}>
|
|
|
+ <div className={style['modal']} style={{width: '820px', marginLeft:'-410px', top:'20px',bottom:'20px'}}>
|
|
|
+ {/* <div className={style['modal']} style={{width: width?width:'auto', marginLeft:marginLeft, top:top?top+'px':'',bottom:bottom?bottom+'px':''}}> */}
|
|
|
+ <div className={style['close']} onClick={this.onPrint}>
|
|
|
{icon?<img src={icon} />:''}
|
|
|
{title}
|
|
|
<img src={close} onClick={onclose} className={style['closeIcon']} />
|
|
|
</div>
|
|
|
+ <i className={style['flg']}>患者基本信息</i>
|
|
|
<div className={style["content"]} style = {{width: width?width:'auto'}}>{children}</div>
|
|
|
<div className={style['footer']} style = {{width: width?width:'auto'}}>{footer}</div>
|
|
|
</div>
|
|
|
- <i>222222</i>
|
|
|
</div>,domNode);
|
|
|
}
|
|
|
}
|