瀏覽代碼

打印,固定参数调试

Luolei 6 年之前
父節點
當前提交
02a858e415

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

@@ -2,6 +2,7 @@ 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:标题
@@ -14,19 +15,106 @@ 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)
+    super(props);
+    this.onPrint = this.onPrint.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) 
+    $(domWrap).jqprint({
+      debug: false,
+      importCSS: true,
+      printContainer: true,
+      operaSupport: false,
+    });
+    // window.document.body.innerHTML=prnhtml;  
+    // window.print()
+    // console.log(prnhtml)
   }
+
   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']}>
+    return ReactDom.createPortal(<div className={style['container']} id="contents">
       <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']}>
+        <div className={style['close']}  onClick={this.onPrint}>
           {icon?<img src={icon} />:''}
           {title}
           <img src={close} onClick={onclose} className={style['closeIcon']} />
@@ -34,6 +122,7 @@ class ComplexModal extends Component {
         <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);
   }
 }

+ 1 - 1
src/components/AddAssistCheck/index.jsx

@@ -55,7 +55,7 @@ class AddAssistCheck extends React.Component {
     $(document).click((event) => {
       let _con = $('#searchWrapAssist');   // 设置目标区域
       let _cons = $('#datePick');   // 设置目标区域
-      if (searchWrapAssist != event.target && !_con.is(event.target) && _con.has(event.target).length === 0) { // Mark 1
+      if (_con && searchWrapAssist != event.target && !_con.is(event.target) && _con.has(event.target).length === 0) { // Mark 1
         this.setState({ show: false });
       }
       if (!_cons.is(event.target) && _cons.has(event.target).length === 0) { // Mark 1

+ 10 - 1
src/components/ChronicInfo/index.jsx

@@ -14,6 +14,7 @@ import checkIcon from '@common/images/check.png';
 import {ComplexModal,ConfirmModal} from '@commonComp';
 import AssessResult from '@containers/AssessResult';
 import ScaleTable from '../ScaleTable';
+import $ from 'jquery';
 
 /***
 慢病右侧推送模块规则:
@@ -22,6 +23,7 @@ import ScaleTable from '../ScaleTable';
 明细--量表-计算公式-核心指标
 controlType:0-radio  1-checkbox  2-text  3-dropdownlist
 **/
+
 class ChronicInfo extends React.Component{
   constructor(props){
     super(props);
@@ -35,6 +37,8 @@ class ChronicInfo extends React.Component{
       formulaId:null, //计算公式
       optionId:null  //可能结果
     };
+    this.$content = React.createRef();
+
     this.showInfo = this.showInfo.bind(this);
     this.closeInfo = this.closeInfo.bind(this);
     this.showOption = this.showOption.bind(this);
@@ -46,6 +50,11 @@ class ChronicInfo extends React.Component{
     this.showFormula = this.showFormula.bind(this); //打开计算公式
     this.closeFormula = this.closeFormula.bind(this); //关闭计算公式
   }
+
+  componentWillReceiveProps() {
+    $(this.$content.current)[0].scrollIntoView(true);
+  }
+  
   showTableList(id){//量表
     const {getTableList,questionId} = this.props;
     // getTableList(questionId&&questionId.id);
@@ -114,7 +123,7 @@ class ChronicInfo extends React.Component{
     const {showInfo,showOption,infoId,formulaId,optionId} = this.state;
     let list = data&&data.map((v,i)=>{
                     return <div className={style["list"]}>
-                      <p>
+                      <p ref={this.$content}>
                         <span>{'患者可能有'+v.name}</span>
                         <img src={infoPic} className={style["infoPic"]} onClick={this.showInfo.bind(this,v.id)}/>

+ 2 - 17
src/components/PushItems/index.jsx

@@ -13,7 +13,7 @@ import store from "@store";
 import { getWindowInnerHeight } from "@common/js/func";
 import {addLabel} from '@store/actions/inspect';
 import {addAssistLabel} from '@store/actions/assistCheck';
-import {windowEventHandler} from '@utils/tools'
+import {windowEventHandler,getCurrentDate} from '@utils/tools'
 import {ConfirmModal} from '@commonComp';
 import ChronicInfo from '@containers/ChronicInfo';//慢病推送模块
 
@@ -50,27 +50,12 @@ class PushItems extends Component {
       showAssess:!this.state.showAssess
     });
   }
-  getCurrentDate(){
-    let myDate = new Date();
-    let year = myDate.getFullYear();       //获取完整的年份(4位,1970-????)
-    let mon = myDate.getMonth()-0+1;       //获取当前月份(0-11,0代表1月)
-    let day = myDate.getDate();            //获取当前日(1-31)
-    let date = year+'-'+(mon<10?'0'+mon:mon)+'-'+(day<10?'0'+day:day);
-    return date;
-  }
 
   billing() {
     const { assay, check } = this.props.pushMessage;
     const checkedAssay = assay.filter(item => item.checked);
     const checkedCheck = check.filter(item => item.checked);
     this.props.billing(checkedAssay, checkedCheck);
-    // if(checkedAssay.length > 0 || checkedCheck.length > 0) {
-    //   const Height = $(".src-components-BodyContainer-2SgEx").height();
-    //   const adviceHeight = $(".src-common-components-ItemBox-1Bpz3").height();
-    //   const winHeight = window.innerHeight;
-    //   const scrollTop = Height;
-    //   $('#addScrollEvent').scrollTop(100000)
-    // }
     let obj = {   //添加化验
       details: [],
       name: '',
@@ -81,7 +66,7 @@ class PushItems extends Component {
       name: '',
       questionId: '',
       showType: 1,
-      time:this.getCurrentDate(),
+      time:getCurrentDate(),
       value:''
     }
     if(checkedAssay.length > 0){

+ 1 - 1
src/containers/AssistCheck.js

@@ -8,7 +8,7 @@ import { getSearchList,getInstroduce } from '@store/async-actions/assistCheck';
 import {ISREAD} from '@store/types/homePage.js';
 import {billing} from '@store/async-actions/pushMessage';
 
-function mapStateToProps(state) {console.log(state)
+function mapStateToProps(state) {//console.log(state)
     return {
         list:state.assistCheck.list,
         assistLabel:state.assistCheck.assistLabel,

+ 6 - 3
src/store/async-actions/homePage.js

@@ -8,7 +8,7 @@ import {fullfillText} from '@common/js/func';
 import {formatContinueDots} from '@utils/tools';
 import {getOtherHisRecord,getInitData} from '@store/async-actions/fetchModules.js';
 import {initHistoryDetails} from '@store/async-actions/patInfo';
-import {storageLocal} from '@utils/tools';
+import {storageLocal,inspectAndAssist} from '@utils/tools';
 
 const api = {
   getModules:'/moduleInfo/getAll',
@@ -37,8 +37,10 @@ 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: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) => {
@@ -55,6 +57,7 @@ export const getInitModules= (dispatch,getStore)=>{
           type: SETALLMODULES,
           data: res.data.data,
         });
+        inspectAndAssist()
         dispatch({
           type: SETINITDATA,
           data: initData

+ 66 - 3
src/utils/tools.js

@@ -3,8 +3,8 @@ import {CLEAR_MAIN_SUIT} from '@store/types/mainSuit';
 import {CLEAR_CURRENT_ILL} from '@store/types/currentIll';
 import {CLEAROTHERHISTORY} from '@store/types/otherHistory';
 import {CLEARCHECKBODY} from '@store/types/checkBody';
-import {clearAssistData} from '@store/actions/assistCheck';
-import {clearAllLabel} from '@store/actions/inspect';
+import {clearAssistData,addAssistLabel} from '@store/actions/assistCheck';
+import {clearAllLabel,addLabel} from '@store/actions/inspect';
 import {CLEAR_ALL_DIAG} from '@store/types/diagnosticList';
 import {CLEAR_ALL_PUSH_MESSAGE, SET_TIPS} from '@store/types/pushMessage';
 import {ISREAD, SETREADDITEMS} from "../store/types/homePage";
@@ -814,6 +814,67 @@ function dragBox(domWrap,domDrag){
 // function handleMove(event,mouseX){
 //     console.log(event)
 // }
+function getCurrentDate(){
+  let myDate = new Date();
+  let year = myDate.getFullYear();       //获取完整的年份(4位,1970-????)
+  let mon = myDate.getMonth()-0+1;       //获取当前月份(0-11,0代表1月)
+  let day = myDate.getDate();            //获取当前日(1-31)
+  let date = year+'-'+(mon<10?'0'+mon:mon)+'-'+(day<10?'0'+day:day);
+  return date;
+}
+function inspectAndAssist(){
+  let obj = {   //添加化验
+    details: [],
+    name: '',
+    questionId: '',
+    showType: 1,
+  }
+  let obj1 = {  //添加辅检
+    name: '',
+    questionId: '',
+    showType: 1,
+    time:getCurrentDate(),
+    value:''
+  }
+  const state = store.getState();
+  let tmpAll = state.homePage.allModules;
+  let tmpInspected = state.inspect.labelList;
+  let tmpAssisted = state.assistCheck.assistLabel;
+  let tmpInspect = [],tmpAssist = [],assayArr = [],tmpDetail=[],checkArr = [];
+
+  for(let i = 0;i < tmpAll.length;i++){
+    let tmpItem = tmpAll[i];
+    if(tmpItem.type == 5){
+      tmpInspect = tmpItem.moduleDetailDTOList || []
+    }else if(tmpItem.type == 6){
+      tmpAssist = tmpItem.moduleDetailDTOList || []
+    }
+  }
+  for(let i = 0;i < tmpInspect.length;i++){
+    let tmpObj = JSON.parse(JSON.stringify(obj));
+    if (tmpInspect[i].controlType == 0) {
+      tmpDetail = tmpInspect[i].questionMapping
+    }else if(tmpInspect[i].controlType == 1 || tmpInspect[i].controlType == 6){
+      tmpDetail.push(tmpInspect[i])
+    }
+    tmpObj.questionId = tmpInspect[i].id
+    tmpObj.name = tmpInspect[i].name
+    tmpObj.details = tmpDetail
+    assayArr.push(tmpObj)
+  }
+  for(let i = 0;i < tmpAssist.length;i++){
+    let tmpObj = JSON.parse(JSON.stringify(obj1));
+    tmpObj.questionId = tmpAssist[i].id
+    tmpObj.name = tmpAssist[i].name
+    checkArr.push(tmpObj)
+  }
+  if(assayArr.length>0 && tmpInspected.length == 0){//化验
+    store.dispatch(addLabel(assayArr))
+  }
+  if(checkArr.length > 0 && tmpAssisted.length == 0){//辅检
+    store.dispatch(addAssistLabel(checkArr))
+  }
+}
 module.exports = {
     checkType: Type.checkType,
     regexp,
@@ -844,5 +905,7 @@ module.exports = {
     timestampToTime,
     getPageLength,
     dragBox,
-    formatContinueDots
+    formatContinueDots,
+    inspectAndAssist,
+    getCurrentDate
 };