index.jsx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import React, { Component } from "react";
  2. import { connect } from "react-redux";
  3. import BannerContainer from '@containers/TypeConfigContainer';
  4. // 引入组件
  5. import BodyContainer from "@components/BodyContainer";
  6. import {HIDEDROP,SETMINSCREEN} from '@store/types/homePage.js';
  7. import style from './index.less';
  8. /*import {getInitModules} from '@store/async-actions/homePage.js';*/
  9. import { getUrlArgObject } from "@utils/tools";
  10. import $ from 'jquery';
  11. import loading from '@common/images/loading.gif';
  12. class HomePage extends Component {
  13. constructor() {
  14. super();
  15. this.state={
  16. timer:null
  17. }
  18. }
  19. componentDidMount(){
  20. const {setWindow} = this.props;
  21. /* clearTimeout(this.state.timer);
  22. const that = this;
  23. const timer = setTimeout(function(){//解决患者信息在获取模板之后的问题
  24. that.props.getInit();
  25. },200)
  26. this.setState({
  27. timer
  28. }) */
  29. // 获取并监听窗口宽度,用于有横向滚动条时患者信息和打印预览跟随滚动
  30. let width = $(window).width();
  31. let height = $(window).height();
  32. setWindow && setWindow({width,height});
  33. $(window).resize(function(){
  34. let reWidth = $(window).width();
  35. let reHeight = $(window).height();
  36. setWindow && setWindow({width:reWidth,height:reHeight});
  37. })
  38. //光标没落到span的时候继续backspace防止页面回退
  39. $(window).on("keydown",(e)=>{
  40. let ev = e || window.event;
  41. if(ev.keyCode==8){
  42. const elem = ev.srcElement || ev.target;
  43. const nodeN = elem.nodeName;
  44. if(nodeN != "SPAN"){
  45. return false;
  46. }
  47. }
  48. })
  49. }
  50. render() {
  51. const {flag} = this.props;
  52. return <div className={style['home-page']} onClick={this.props.hideAllDrop}>
  53. <BannerContainer />
  54. {/* <InfoTitle /> */}
  55. <BodyContainer></BodyContainer>
  56. <div className={style['mask']} style={{display:flag?"block":"none"}}>
  57. <img src={loading} className={style['load']}/>
  58. </div>
  59. </div>;
  60. }
  61. }
  62. const mapStateToProps = function (state) {
  63. return {
  64. flag:state.homePage.loadingFlag
  65. }
  66. };
  67. const mapDispatchToProps = function (dispatch) {
  68. return {
  69. hideAllDrop(){
  70. dispatch({
  71. type:HIDEDROP
  72. });
  73. },
  74. /*getInit(){
  75. dispatch(getInitModules);
  76. }*/
  77. setWindow(obj){
  78. dispatch({
  79. type:SETMINSCREEN,
  80. obj:obj
  81. })
  82. }
  83. }
  84. };
  85. export default connect(mapStateToProps, mapDispatchToProps)(HomePage);