index.jsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import React, { Component } from "react";
  2. import PatInfoContainer from '@containers/PatInfoContainer.js';
  3. import style from "./index.less";
  4. import { connect } from 'react-redux';
  5. import historyCase from '@common/images/history.png';
  6. import health from '@common/images/health.png'
  7. import store from '@store';
  8. import { showHistory } from '@store/actions/historyTemplates';
  9. import { initItemList,setInitHistory } from '@store/async-actions/historyTemplates';
  10. import HistoryCases from '@containers/HistoryCases';
  11. import $ from 'jquery';
  12. import Notify from '@commonComp/Notify';
  13. import {MODI_LOADING} from '@store/types/homePage.js';
  14. class InfoTitle extends Component {
  15. constructor(props){
  16. super(props);
  17. this.state={
  18. le:''
  19. }
  20. this.showHistoryBox = this.showHistoryBox.bind(this)
  21. }
  22. showHistoryBox(){
  23. const {showLoading,hideLoading}=this.props;
  24. showLoading();
  25. // store.dispatch(initItemList());
  26. // store.dispatch(showHistory(true))
  27. initItemList().then((res)=>{
  28. const result = res.data;
  29. if(result.code==0 && result.data){
  30. hideLoading();
  31. store.dispatch(setInitHistory(result.data));
  32. store.dispatch(showHistory(true));
  33. }else{
  34. hideLoading();
  35. Notify.info("暂无历史病历");
  36. }
  37. })
  38. }
  39. componentWillReceiveProps(next){
  40. const that = this;
  41. if(next.winWidth <= 1024){
  42. $(window).scroll(function(){
  43. let scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft;
  44. let left = -(scrollLeft - 10) +'px';
  45. that.setState({
  46. le:left
  47. })
  48. })
  49. }
  50. }
  51. render() {
  52. const {disVisible,copyVisible,winWidth} = this.props;
  53. const {le} = this.state;
  54. return <div className={style['title-wrapper']} style={{zIndex:disVisible||copyVisible?40:204,left:le}}>
  55. <PatInfoContainer sizeFlag={winWidth <= 1065?true:false}/>
  56. <div className={style["operations"]} onClick={this.showHistoryBox}>
  57. <span><img src={historyCase} />&nbsp;历史病历</span>
  58. </div>
  59. <div className={style["health"]} >
  60. <span><img src={health} />&nbsp;健康档案</span>
  61. </div>
  62. <HistoryCases></HistoryCases>
  63. </div>;
  64. }
  65. }
  66. function mapStateToProps(state) {
  67. return {
  68. disVisible: state.copyRight.disVisible,
  69. copyVisible:state.copyRight.copyVisible,
  70. winWidth:state.homePage.windowWidth
  71. }
  72. }
  73. function mapDispatchToProps(dispatch){
  74. return{
  75. showLoading(){
  76. dispatch({type:MODI_LOADING,flag:true});
  77. },
  78. hideLoading(){
  79. dispatch({type:MODI_LOADING,flag:false});
  80. }
  81. }
  82. }
  83. const InfoTitleCont = connect(
  84. mapStateToProps,
  85. mapDispatchToProps
  86. )(InfoTitle);
  87. export default InfoTitleCont;