소스 검색

打印功能已添加,样式仍需调整

Luolei 6 년 전
부모
커밋
45015fab36

+ 3 - 106
src/common/components/ComplexModal/index.jsx

@@ -2,7 +2,6 @@ import React, { Component } from "react";
 import ReactDom from "react-dom";
 import style from "./index.less";
 import Notify from '@commonComp/Notify';
-import $ from 'jquery';
 import close from '@common/images/icon_close.png';
 /**
  * title:标题
@@ -15,123 +14,21 @@ import close from '@common/images/icon_close.png';
  *height:弹窗的高度
  * **/
 
-(function ($) {
-  var opt;
-
-  $.fn.jqprint = function (options) {
-    opt = $.extend({}, $.fn.jqprint.defaults, options);
-
-    var $element = (this instanceof $) ? this : $(this);
-
-    if (opt.operaSupport && $.browser.opera) {
-      var tab = window.open("", "jqPrint-preview");
-      tab.document.open();
-
-      var doc = tab.document;
-    }
-    else {
-      var $iframe = $("<iframe  />");
-
-      if (!opt.debug) { $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-300px", top: "-300px" }); }
-
-      $iframe.appendTo("body");
-      var doc = $iframe[0].contentWindow.document;
-    }
-
-    if (opt.importCSS) {
-      if ($("link[media=print]").length > 0) {
-        $("link[media=print]").each(function () {
-          doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' media='print' />");
-        });
-      }
-      else {
-        $("link").each(function () {
-          doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' />");
-        });
-      }
-    }
-
-    if (opt.printContainer) { doc.write($element.outer()); }
-    else { $element.each(function () { doc.write($(this).html()); }); }
-
-    doc.close();
-
-    (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).focus();
-    setTimeout(function () { (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).print(); if (tab) { tab.close(); } }, 1000);
-  }
-
-  $.fn.jqprint.defaults = {
-    debug: false,
-    importCSS: true,
-    printContainer: true,
-    operaSupport: true
-  };
-
-  $.fn.outer = function () {
-    return $($('<div></div>').html(this.clone())).html();
-  }
-})($);
 
 class ComplexModal extends Component {
   constructor(props) {
     super(props);
-    this.onPrint = this.onPrint.bind(this);
-    // this.doPrint3 = this.doPrint3.bind(this);
   }
-  
-  onPrint() {
-    // $("#contents").jqprint({
-    //   debug: false,
-    //   importCSS: true,
-    //   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)
-    // window.document.body.innerHTML=prnhtml;  
-    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);
-  //   } 
-  // }
 
   render() {
     const { onclose,title,children,footer,shadeClose,icon,width,top,bottom} = this.props;
     const marginLeft = width? -parseInt(width)/2 : '';
     //const marginTop = height? -parseInt(height)/2: '';
     const domNode = document.getElementById('root');
-    return ReactDom.createPortal(<div className={style['container']} id="printcontent">
+    return ReactDom.createPortal(<div className={style['container']}>
       <div className={style['shade']} onClick={shadeClose===false?'':onclose}></div>
-
-      <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}>
+      <div className={style['modal']} style={{width: width?width:'auto', marginLeft:marginLeft, top:top?top+'px':'',bottom:bottom?bottom+'px':''}}>
+        <div className={style['close']}>
           {icon?<img src={icon} />:''}
           {title}
           <img src={close} onClick={onclose} className={style['closeIcon']} />

+ 1 - 1
src/common/js/func.js

@@ -96,7 +96,7 @@ export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
       value = '',
       item={},
       checkHiddenDefault=false;
-  arr.map((it,i)=>{
+  arr&&arr.map((it,i)=>{
     notText = notTextLabel(it);
     value = it.value||'';
     textLabel = !ifEmpty&&i==0?Object.assign({},JSON.parse(config.textLabel),{showInCheck:true}):JSON.parse(config.textLabel);

+ 40 - 35
src/components/AssessResult/index.jsx

@@ -1,80 +1,85 @@
 import React, { Component } from "react";
 import style from "./index.less";
-import { Radio} from '@commonComp';
+import { Radio } from '@commonComp';
 import Notify from '@commonComp/Notify';
 import ChooseItem from "./ChooseItem";
 import ScaleItem from "./ScaleItem";
+import Information from '../Information'
 import ChartItem from "./ChartItem";
+import $ from "jquery";
 
 class AssessResult extends Component {
   constructor(props) {
     super(props);
-    this.state={
-      chooseSelecteds:{},     //大数据选择模块
-      chartTimeTypes:{},      //图表模块
-      wholeAssessItems:props.wholeIndexs,     //整体评估模块
-      wholeAssessText:props.wholeText||''     //整体评估补充说明
+    this.state = {
+      chooseSelecteds: {},     //大数据选择模块
+      chartTimeTypes: {},      //图表模块
+      wholeAssessItems: props.wholeIndexs,     //整体评估模块
+      wholeAssessText: props.wholeText || ''     //整体评估补充说明
     }
     this.handleChooseChange = this.handleChooseChange.bind(this);
     this.handleScaleDel = this.handleScaleDel.bind(this);
     this.handleScaleText = this.handleScaleText.bind(this);
   }
-  componentWillMount(){
+  componentWillMount() {
     //获取评估
     this.props.getAssess();
   }
-  handleScaleText(text){
-      this.setState({
-        wholeAssessText:text
-      })
+  handleScaleText(text) {
+    this.setState({
+      wholeAssessText: text
+    })
   }
-  handleScaleDel(i,j){
-    const items = Object.assign({},this.state.wholeAssessItems);
-    const inx = items[i].findIndex(x=>x==j);
-    items[i].splice(inx,1);
+  handleScaleDel(i, j) {
+    const items = Object.assign({}, this.state.wholeAssessItems);
+    const inx = items[i].findIndex(x => x == j);
+    items[i].splice(inx, 1);
     this.setState({
       wholeAssessItems: items
     });
   }
-  handleChooseChange(i,selects){
-    const {chooseSelecteds} = this.state;
+  handleChooseChange(i, selects) {
+    const { chooseSelecteds } = this.state;
     this.setState({
-      chooseSelecteds: Object.assign(chooseSelecteds,{[i]:selects})
+      chooseSelecteds: Object.assign(chooseSelecteds, { [i]: selects })
     });
   }
-  handleChartChange(i,selects){
-    const {chartTimeTypes} = this.state;
+  handleChartChange(i, selects) {
+    const { chartTimeTypes } = this.state;
     this.setState({
-      chartTimeTypes:Object.assign(chartTimeTypes,{[i]:selects})
+      chartTimeTypes: Object.assign(chartTimeTypes, { [i]: selects })
     });
   }
-  componentWillUnmount(){
+  componentWillUnmount() {
     //点确定关闭弹窗时把参数传到父组件去
-    const {handleSave,isAssessConfirm} = this.props;
-    isAssessConfirm&&handleSave(this.state);
+    const { handleSave, isAssessConfirm } = this.props;
+    isAssessConfirm && handleSave(this.state);
   }
-  handoutTypes(item,i){
-    const {getIndexData,indexData,timeTypes,wholeAssessData,wholeIndexs} =this.props;
+  handoutTypes(item, i) {
+    const { getIndexData, indexData, timeTypes, wholeAssessData, wholeIndexs } = this.props;
     //console.log(indexData)
     const chartData = indexData;
-    const name = item.regionName+":";
-    const list = item.data&&item.data.rows;
-    switch (+item.regionType){
+    const name = item.regionName + ":";
+    const list = item.data && item.data.rows;
+    switch (+item.regionType) {
       case 0:     //数据来源与右侧手动添加
         return <ScaleItem title={name} data={wholeAssessData} handleRemove={this.handleScaleDel} handleInp={this.handleScaleText} indexs={this.state.wholeAssessItems}></ScaleItem>;
       case 1:     //数据来源于大数据
-        return <ChooseItem title={name} data={list} handleChange={this.handleChooseChange.bind(this,i)}></ChooseItem>;
+        return <ChooseItem title={name} data={list} handleChange={this.handleChooseChange.bind(this, i)}></ChooseItem>;
       case 10:    //数据来源于后台
-        return <ChartItem title={name} data={chartData||{}} timeTypes={timeTypes} initFn={getIndexData} handleChange={this.handleChartChange.bind(this,i)}></ChartItem>;
+        return <ChartItem title={name} data={chartData || {}} timeTypes={timeTypes} initFn={getIndexData} handleChange={this.handleChartChange.bind(this, i)}></ChartItem>;
       default:
         return '';
     }
   }
   render() {
-    const { onClose,data } = this.props;
-    return <div className={style['assess-cont']}>
-      {data&&data.map((it,i)=>{
-        return this.handoutTypes(it,i);
+    const { onClose, data } = this.props;
+    return <div className={style['assess-cont']} id="AssistResult">
+      <div className={style['printShow']}>
+        <Information></Information>
+      </div> 
+      {data && data.map((it, i) => {
+        return this.handoutTypes(it, i);
       })}
     </div>;
   }

+ 8 - 0
src/components/AssessResult/index.less

@@ -89,4 +89,12 @@
       }
     }
   }
+}
+.printShow {
+  display: none;
+}
+@media print {
+  .printShow {
+    display: block;
+  }
 }

+ 13 - 3
src/components/ChronicInfo/index.jsx

@@ -54,8 +54,18 @@ class ChronicInfo extends React.Component{
     this.closeFormula = this.closeFormula.bind(this); //关闭计算公式
     this.handleAddAssessItem = this.handleAddAssessItem.bind(this);   //加入病例记录
     this.handleSaveAssess = this.handleSaveAssess.bind(this);       //评估弹窗确定
+    this.onPrint = this.onPrint.bind(this); 
   }
 
+  onPrint() {
+    let dom = this.state.showTable?$("#printcontent"):$("#AssistResult");
+    dom.jqprint({
+      debug: false,
+      importCSS: true,
+      printContainer: true,
+      operaSupport: false,
+    });
+  }
   componentWillReceiveProps() {
     $(this.$content.current)[0].scrollIntoView(true);
   }
@@ -160,7 +170,7 @@ class ChronicInfo extends React.Component{
                                 close={this.closeInfo}>
                           {pureText}
                       </MiniToast>
-                      {v.details.map((it,j)=>{
+                      {v.details&&v.details.map((it,j)=>{
                         if(it.type==1){
                           return <p>
                                 <span className={style["listName"]} onClick={this.showTable.bind(this,it.content)}>{'【'+it.content.name+'】'}</span>
@@ -261,7 +271,7 @@ class ChronicInfo extends React.Component{
 
   render(){
     const footer = <div className={style['footer']}>
-      <span className={style['print']}><img src={printIcon} alt=""/>打印</span>
+      <span className={style['print']} onClick={this.onPrint}><img src={printIcon} alt=""/>打印</span>
       <span className={style['okBtn']} onClick={()=>this.handleSaveAssess()}>确定</span>
     </div>;
     const {chronicMagItem,showList,tableList,scaleInfo,data,saveAssessInfos,chronicDesease} = this.props;
@@ -308,7 +318,7 @@ class ChronicInfo extends React.Component{
                 <ScaleTable data={scaleInfo} title={tableName}></ScaleTable>
               </ComplexModal>:''}
               {showAssess?<ComplexModal onclose={this.showAssessFn} footer={footer}
-                      title='管理和评估' 
+                      title='管理和评估'
                       icon={manageIcon}
                       top={20}
                       bottom={20}

+ 41 - 0
src/components/Information/index.jsx

@@ -0,0 +1,41 @@
+import React, { Component } from "react";
+import style from "./index.less";
+import store from "@store";
+import $ from "jquery";
+
+
+class Information extends Component {
+  constructor(props) {
+    super(props)
+    this.$content = React.createRef();
+  }
+
+  componentWillReceiveProps() {
+    $(this.$content.current)[0].scrollIntoView(true);
+  }
+  render() {
+    const { baseObj } = this.props;
+    let baseData = store.getState()
+    let preInfo = baseData.patInfo.message;
+    const noData = JSON.stringify(preInfo) == '{}';
+    return <div className={style['information']}>
+        <div ref={this.$content} className={style['title']}>{preInfo.hospitalName}</div>
+        <table className={style['patInfo']}>
+          <tr>
+            <td>卡号:{baseObj ? baseObj.patientIdNo : noData ? '' : preInfo.patientIdNo}</td>
+            <td>姓名:{baseObj ? baseObj.patientName : noData ? '' : preInfo.patientName}</td>
+            <td>年龄:{baseObj ? baseObj.patientAge : noData ? '' : preInfo.patientAge}</td>
+            <td>性别:{baseObj ? baseObj.patientSex : noData ? '' : preInfo.patientSex}</td>
+          </tr>
+          <tr>
+            <td>就诊时间:{baseObj ? baseObj.inquiryDate : (noData ? '' : preInfo.systemTime.split(' ')[0])}</td>
+            <td>科室:{baseObj ? baseObj.hospitalDeptName : (noData ? '' : preInfo.hospitalDeptName)}</td>
+            <td>医生:{baseObj ? baseObj.doctorName : (noData ? '' : preInfo.doctorName)}</td>
+            <td>门诊号:{baseObj ? baseObj.inquiryCode : (noData ? '' : preInfo.recordId)}</td>
+          </tr>
+        </table>
+      </div>
+  }
+}
+
+export default Information;

+ 17 - 0
src/components/Information/index.less

@@ -0,0 +1,17 @@
+.title {
+  clear: both;
+  font-size: 24px;
+  margin-bottom: 30px;
+  text-align:center;
+}
+.patInfo {
+  margin: 0px 0px 30px 0px;
+  td {
+    border: 1px solid #aaa;
+    padding: 8px 10px;
+    font-size: 14px;
+  }
+  tr td:first-child{
+    width: 31%;
+  }
+}

+ 27 - 109
src/components/PreviewBody/index.jsx

@@ -2,65 +2,11 @@ import React, { Component } from "react";
 import style from "./index.less";
 import { normalVal, filterDataArr, filterOtherDataArr,timestampToTime } from '@utils/tools';
 import Notify from '@commonComp/Notify';
+import Information from '../Information';
 import $ from "jquery";
 import arrow from '@common/images/icon_tri_blue.png';
 
-(function ($) {
-  var opt;
-
-  $.fn.jqprint = function (options) {
-    opt = $.extend({}, $.fn.jqprint.defaults, options);
-
-    var $element = (this instanceof $) ? this : $(this);
-
-    if (opt.operaSupport && $.browser.opera) {
-      var tab = window.open("", "jqPrint-preview");
-      tab.document.open();
-
-      var doc = tab.document;
-    }
-    else {
-      var $iframe = $("<iframe  />");
-
-      if (!opt.debug) { $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-300px", top: "-300px" }); }
-
-      $iframe.appendTo("body");
-      var doc = $iframe[0].contentWindow.document;
-    }
-
-    if (opt.importCSS) {
-      if ($("link[media=print]").length > 0) {
-        $("link[media=print]").each(function () {
-          doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' media='print' />");
-        });
-      }
-      else {
-        $("link").each(function () {
-          doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' />");
-        });
-      }
-    }
-
-    if (opt.printContainer) { doc.write($element.outer()); }
-    else { $element.each(function () { doc.write($(this).html()); }); }
-
-    doc.close();
-
-    (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).focus();
-    setTimeout(function () { (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).print(); if (tab) { tab.close(); } }, 1000);
-  }
-
-  $.fn.jqprint.defaults = {
-    debug: false,
-    importCSS: true,
-    printContainer: true,
-    operaSupport: true
-  };
-
-  $.fn.outer = function () {
-    return $($('<div></div>').html(this.clone())).html();
-  }
-})($);
+// import "@utils/jqprint";
 
 class PreviewBody extends Component {
   constructor(props) {
@@ -68,16 +14,12 @@ class PreviewBody extends Component {
     this.state = {
       dateTime: "",
     }
-    this.$content = React.createRef();
     this.getCurrentDate = this.getCurrentDate.bind(this);
     this.onPrint = this.onPrint.bind(this);
   }
   componentDidMount() {
     this.getCurrentDate();
   }
-  componentWillReceiveProps() {
-    $(this.$content.current)[0].scrollIntoView(true);
-  }
   onPrint() {
     $("#content").jqprint({
       debug: false,
@@ -99,16 +41,6 @@ class PreviewBody extends Component {
       this.onPrint();
       this.props.save(true)
     }
-    // if(filterDataArr(JSON.parse(jsonStr.chief)) == ''){
-    //   Notify.info('主诉不能为空');
-    //     return false;
-    // }else if(!jsonStr.diag || jsonStr.diag.trim().length < 1){
-    //     Notify.info('诊断不能为空');
-    //     return false;
-    // }else{
-    //     this.onPrint();
-    //     this.props.save(true)
-    // }
   }
   getCurrentDate() {
     let myDate = new Date();
@@ -148,41 +80,27 @@ class PreviewBody extends Component {
     const noData = JSON.stringify(preInfo) == '{}';
     return <div className={style['content']} style={{ width: flg ? '700' : '820' }}>
       <div className={style['contents']} id="content" style={{ margin: "0 auto", maxWidth: "600px" }}>
-        <div ref={this.$content} style={{ clear: 'both', fontSize: '24px', margin: '0px 0px 30px 0px', textAlign: 'center' }}>{preInfo.hospitalName}</div>
-        <table className={style['patInfo']}>
-          <tr>
-            <td>卡号:{baseObj ? baseObj.patientIdNo : noData ? '' : preInfo.patientIdNo}</td>
-            <td>姓名:{baseObj ? baseObj.patientName : noData ? '' : preInfo.patientName}</td>
-            <td>年龄:{baseObj ? baseObj.patientAge : noData ? '' : preInfo.patientAge}</td>
-            <td>性别:{baseObj ? baseObj.patientSex : noData ? '' : preInfo.patientSex}</td>
-          </tr>
-          <tr>
-            <td>就诊时间:{baseObj ? baseObj.inquiryDate : (noData ? '' : preInfo.systemTime.split(' ')[0])}</td>
-            <td>科室:{baseObj ? baseObj.hospitalDeptName : (noData ? '' : preInfo.hospitalDeptName)}</td>
-            <td>医生:{baseObj ? baseObj.doctorName : (noData ? '' : preInfo.doctorName)}</td>
-            <td>门诊号:{baseObj ? baseObj.inquiryCode : (noData ? '' : preInfo.recordId)}</td>
-          </tr>
-        </table>
+        <Information baseObj={baseObj} preInfo={preInfo}></Information>
         <table className={style['infos']}>
-          <tr>
-            <td>主诉:</td>
-            <td>
+          <tr className={style['patInfoFst']}>
+            <td className={style['patInfoSec']}>主诉:</td>
+            <td className={style['patInfoSec']}>
               {
                 filterDataArr(JSON.parse(dataStr.chief))
               }
             </td>
           </tr>
-          <tr>
-            <td>现病史:</td>
-            <td>
+          <tr className={style['patInfoFst']}>
+            <td className={style['patInfoSec']}>现病史:</td>
+            <td className={style['patInfoSec']}>
               {
                 filterDataArr(JSON.parse(dataStr.present))
               }
             </td>
           </tr>
-          <tr>
-            <td>其他史:</td>
-            <td>
+          <tr className={style['patInfoFst']}>
+            <td className={style['patInfoSec']}>其他史:</td>
+            <td className={style['patInfoSec']}>
               {
                 other_yjs.str1
               }
@@ -202,17 +120,17 @@ class PreviewBody extends Component {
               }
             </td>
           </tr>
-          <tr>
-            <td>查体:</td>
-            <td>
+          <tr className={style['patInfoFst']}>
+            <td className={style['patInfoSec']}>查体:</td>
+            <td className={style['patInfoSec']}>
               {
                 filterDataArr(JSON.parse(dataStr.vital))
               }
             </td>
           </tr>
-          <tr>
-            <td>化验:</td>
-            <td>
+          <tr className={style['patInfoFst']}>
+            <td className={style['patInfoSec']}>化验:</td>
+            <td className={style['patInfoSec']}>
               {
                 dataJson.lis.getExcelDataList && dataJson.lis.getExcelDataList.map((items) => {
                   return items.lisExcelRes && items.lisExcelRes.map((item) => {
@@ -263,9 +181,9 @@ class PreviewBody extends Component {
               }
             </td>
           </tr>
-          <tr>
-            <td>辅检:</td>
-            <td>
+          <tr className={style['patInfoFst']}>
+            <td className={style['patInfoSec']}>辅检:</td>
+            <td className={style['patInfoSec']}>
               {
                 dataStr.pacs && dataStr.pacs != '' && dataStr.pacs.split(';').map((item) => {
                   return <div style={{ fontSize: '14px',wordBreak:"break-all" }}>{item}</div>
@@ -273,9 +191,9 @@ class PreviewBody extends Component {
               }
             </td>
           </tr>
-          <tr>
-            <td>诊断:</td>
-            <td>
+          <tr className={style['patInfoFst']}>
+            <td className={style['patInfoSec']}>诊断:</td>
+            <td className={style['patInfoSec']}>
               {
                 dataStr.diag && dataStr.diag != '' && dataStr.diag.split(';').map((item) => {
                   return <div style={{ fontSize: '14px' }}>{item}</div>
@@ -283,9 +201,9 @@ class PreviewBody extends Component {
               }
             </td>
           </tr>
-          <tr>
-            <td>医嘱:</td>
-            <td style={{ fontSize: '14px', padding: '1px 0px 8px 0px', lineHeight: '20px' }}>
+          <tr className={style['patInfoFst']}>
+            <td className={style['patInfoSec']}>医嘱:</td>
+            <td className={style['patInfoSec']} style={{ fontSize: '14px', padding: '1px 0px 8px 0px', lineHeight: '20px' }}>
               {dataJson.advice.commontreatment && dataJson.advice.commontreatment.length > 0 && <p style={{ fontSize: '14px', marginBottom: '8px', marginTop: '8px' }}><span>一般治疗</span></p>}
               {
                 dataJson.advice.commontreatment && <div style={{ padding: '0px 0px 5px 0px',wordBreak:"break-all" }}>{dataJson.advice.commontreatment}</div>

+ 3 - 3
src/components/PreviewBody/index.less

@@ -16,15 +16,15 @@ table{
   width: 100%;
 }
 .infos{
-  &>tr{
+  .patInfoFst{
     vertical-align: top;
     border-bottom: 1px solid #e2e4e6;
   }
-  &>tr>td{
+  .patInfoFst .patInfoSec{
     padding: 9px 5px 8px 0px;
     line-height: 20px;
   }
-  &>tr>td:first-child {
+  &>tr>td:first-child {//打印样式需要改
     text-align: right;
     width: 70px;
     font-size: 14px;

+ 8 - 10
src/components/PrintPreview/index.jsx

@@ -33,16 +33,14 @@ class PrintPreview extends Component {
             <div className={style['shade']} onClick={onClose}></div>
             <div className={style['modal']}>
                 <div className={style['close']}>打印<img src={close} onClick={onClose} /></div>
-                {/* <div id="content"> */}
-                    <PreviewBody
-                        preInfo={preInfo}
-                        dataJson={dataJson}
-                        dataStr={dataStr}
-                        show={true}
-                        onClose={onClose}
-                        save={save}
-                    ></PreviewBody>
-                {/* </div> */}
+                  <PreviewBody
+                      preInfo={preInfo}
+                      dataJson={dataJson}
+                      dataStr={dataStr}
+                      show={true}
+                      onClose={onClose}
+                      save={save}
+                  ></PreviewBody>
             </div>
         </div>
     }

+ 5 - 2
src/components/ScaleTable/index.jsx

@@ -1,7 +1,7 @@
 import React from 'react';
 import style from './index.less';
 import mocks from '../../mock/chronicTable.js'
- 
+import Information from '../Information'
 /**
 *量表 具体信息页面
 *title:量表标题
@@ -24,7 +24,10 @@ class ScaleTable extends React.Component{
     const footContent = data && data[2].content; //表后文字
     const datas = content && JSON.parse(content);
 
-    return <div className={style['tableBox']}>
+    return <div className={style['tableBox']} id="printcontent">
+            <div className={style['printShow']}>
+              <Information></Information>
+            </div> 
             <h1>{title}</h1>
             <div dangerouslySetInnerHTML={{__html:preContent}} className={style['textlh']}></div>
             <table className={style['table']}>

+ 8 - 0
src/components/ScaleTable/index.less

@@ -44,4 +44,12 @@ strong{
   p{
     line-height: 22px;
   }
+}
+.printShow {
+  display: none;
+}
+@media print {
+  .printShow {
+    display: block;
+  }
 }

+ 1 - 1
src/containers/AssessResult.js

@@ -17,7 +17,7 @@ import store from '@store';
  *
  * ***/
 
-function mapStateToProps(state) {console.log(state)
+function mapStateToProps(state) {//console.log(state)
   const {assessResult} = state;
   return {
     data:assessResult.data,

+ 1 - 0
src/main.js

@@ -7,6 +7,7 @@ import store from './store';
 import {AppContainer} from 'react-hot-loader';
 import HomePage from './modules/HomePage';
 import $ from 'jquery';
+import "@utils/jqPrint";
 
 const render = (Component) => {
   //ie8 console兼容

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

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

+ 4 - 7
src/store/async-actions/homePage.js

@@ -39,16 +39,13 @@ export const getInitModules= (dispatch,getStore)=>{
   const param = {
     age:message.patientAge,
     sexType:message.sex,
-    // mouduleType:chronicId?2:(message.hospitalDeptId?1:0),//慢病2  科室1 其他0
-    // relationId:chronicId?chronicId:(message.hospitalDeptId?message.hospitalDeptId:0), //慢病id  科室id  其他0
-    mouduleType:2,
-    relationId:21773, //慢病id  科室id  其他0
+    mouduleType:chronicId?2:(message.hospitalDeptId?1:0),//慢病2  科室1 其他0
+    relationId:chronicId?chronicId:(message.hospitalDeptId?message.hospitalDeptId:0), //慢病id  科室id  其他0
+    // mouduleType:2,
+    // relationId:21773, //慢病id  科室id  其他0
   }
   // return json(api.getModules,{age:message.patientAge,sexType:message.sex}).then((res) => {
   return json(api.getModules,param).then((res) => {
-      if(allModules.length == 0){//模板为空才回读
-        dispatch(initHistoryDetails(message));      //历史病历回读
-      }
       if (res.data.code == '0') {
         const newObj = modulesParseJson(res.data.data);
         const initData = newObj.json;

+ 3 - 3
src/store/async-actions/patInfo.js

@@ -21,7 +21,6 @@ export const initPersonInfo = (dispatch, getState) => {
         const data = res.data;
         if (data.code == 0) {
             dispatch(getInfos(data.data));
-            //console.log(data.data)
             getPatientMessage(dispatch, getState);
         } else {
             console.log(res)
@@ -98,9 +97,10 @@ export const getPatientMessage = (dispatch, getState) => {
         type: CONFIRM_TYPE,
         confirmType:data1.modeValue
       });
-      dispatch(getInitModules);     //确保病人信息获取以后再获取模板等数据,否则参数为空
+      dispatch(getInitModules);       //确保病人信息获取以后再获取模板等数据,否则参数为空
       dispatch(getCommonList(5));     //获取常用化验标签列表
-      dispatch(getCommonList(6));     //获取常用辅检标签列表
+      dispatch(getCommonList(6));     //获取常用辅检标签列表if(allModules.length == 0){//模板为空才回读
+      dispatch(initHistoryDetails());      //历史病历回读
       // if(state.tabTemplate.items.length == 0){
       //   dispatch(initItemList(data1.modeValue));        //模板列表没有就获取模板列表用于保存时做数据对比是否保存过
       // }

+ 2 - 1
src/store/async-actions/pushMessage.js

@@ -21,7 +21,8 @@ export const billing = (mdata) => {
   const emrData = getEMRParams();
   const params = {
     age: emrData.age,
-    featureType: "4,5,6,7,22",
+    // featureType: "4,5,6,7,22",
+    featureType: "22",
     diag: emrData.dis,
     lis: emrData.lis,
     other: emrData.other,

+ 69 - 0
src/utils/jqprint.js

@@ -0,0 +1,69 @@
+import $ from 'jquery';
+
+(function ($) {
+  var opt;
+  $.fn.jqprint = function (options) {
+    opt = $.extend({}, $.fn.jqprint.defaults, options);
+    var $element = (this instanceof $) ? this : $(this);
+    if (opt.operaSupport && $.browser.opera) {
+      var tab = window.open("", "jqPrint-preview");
+      tab.document.open();
+      var doc = tab.document;
+    }else {
+      var $iframe = $("<iframe  />");
+      if (!opt.debug) { $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-300px", top: "-300px" }); }
+      $iframe.appendTo("body");
+      var doc = $iframe[0].contentWindow.document;
+    }
+
+    if (opt.importCSS) {
+      doc.write('<!DOCTYPE html>');
+
+      $("style").each(function () {//获取内联样式放到iframe中
+        doc.write('<style type="text/css" rel="stylesheet" media="print" >' + $(this)[0].textContent + '</style>');
+      });
+
+      if ($("link[media=print]").length > 0) {//外联样式获取
+        $("link[media=print]").each(function () {
+          doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' media='print' />");
+        });
+      }
+      else {
+        $("link").each(function () {
+          doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' />");
+        });
+      }
+    }
+
+    var canvasLis = $(this).find('canvas');//页面有canvas需要转换为图片
+    if (!canvasLis) {
+      return
+    } else {
+      $("img").remove('.canvasImg')//删除已添加的图片避免多张图片重叠
+      for (var k = 0; k < canvasLis.length; k++) {
+        var canvasSrc = canvasLis[k].toDataURL();
+        let canvasImg = "<img class='canvasImg' src='" + canvasSrc + "'>"
+        $(canvasLis[k]).parent().append(canvasImg)
+      }
+    }
+
+    if (opt.printContainer) { doc.write($element.outer()); }
+    else { $element.each(function () { doc.write($(this).html()); }); }
+
+    doc.close();
+
+    (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).focus();
+    setTimeout(function () { (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).print(); if (tab) { tab.close(); } }, 500);
+  }
+
+  $.fn.jqprint.defaults = {
+    debug: false,
+    importCSS: true,
+    printContainer: true,
+    operaSupport: true
+  };
+
+  $.fn.outer = function () {
+    return $($('<div></div>').html(this.clone())).html();
+  }
+})($);