index.jsx 3.2 KB

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