Luolei 6 年之前
父節點
當前提交
790b1127a0

+ 36 - 37
src/common/components/ComplexModal/index.jsx

@@ -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);
   }
 }

+ 11 - 5
src/common/components/ComplexModal/index.less

@@ -14,11 +14,17 @@
     bottom:30px;
     text-align: right;
   }
-  /*@media print {
-    .shade{
-      display: none;
-    }
-  }*/
+  // @media print {
+  //   .close{
+  //     display: none;
+  //   }
+  //   .flg {
+  //     display: block !important;
+  //   }
+  // }
+  .flg {
+    display: none;
+  }
   .shade {
     position: fixed;
     left: 0;

+ 5 - 0
src/modules/HomePage/index.less

@@ -1,3 +1,8 @@
+@media print {
+  // .home-page{
+  //   display: none;
+  // }
+}
 .mask {
     position: fixed;
     top: 0;

+ 2 - 1
src/utils/ajax.js

@@ -5,7 +5,8 @@ $.support.cors = true;
 const axios=require('axios');
 const qs=require('querystring');
 const isLocal = window.location.hostname.indexOf('localhost')!=-1;
-const qhost = isLocal?host+prefix:prefix;
+// const qhost = isLocal?host+prefix:prefix;
+const qhost = isLocal?host+prefix : host+prefix;
 axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
 //axios.defaults.baseURL = host;       //默认地址
 // axios.defaults.timeout = 60000;       //请求超时