index.jsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 EmergencyProcedure from '@components/EmergencyProcedure';
  7. import {HIDEDROP,SETMINSCREEN,SETSYSTEMCONFIG} from '@store/types/homePage.js';
  8. import style from './index.less';
  9. import {getInitModules,getChronic,getSystemConfig} from '@store/async-actions/homePage.js';
  10. import { getUrlArgObject,parseNameVal } from "@utils/tools";
  11. import dataLis from '@components/EmergencyProcedure/emergency';
  12. import $ from 'jquery';
  13. import loading from '@common/images/loading.gif';
  14. class HomePage extends Component {
  15. constructor() {
  16. super();
  17. this.state={
  18. timer:null,
  19. dataEmergency:{},
  20. idx:''
  21. }
  22. this.setDataIdx = this.setDataIdx.bind(this)
  23. }
  24. componentDidMount(){
  25. const {setWindow,getChronicList,getConfig} = this.props;
  26. getConfig();
  27. getChronicList&&getChronicList();//获取慢病列表
  28. // 获取并监听窗口宽度,用于有横向滚动条时患者信息和打印预览跟随滚动
  29. let width = $(window).width();
  30. let height = $(window).height();
  31. setWindow && setWindow({width,height});
  32. $(window).resize(function(){
  33. let reWidth = $(window).width();
  34. let reHeight = $(window).height();
  35. setWindow && setWindow({width:reWidth,height:reHeight});
  36. })
  37. //光标没落到元素上继续backspace防止页面回退
  38. $(window).on("keydown",(e)=>{
  39. let ev = e || window.event;
  40. if(ev.keyCode==8){
  41. const elem = ev.srcElement || ev.target;
  42. const nodeN = elem.nodeName;
  43. if(nodeN != "SPAN" && nodeN != "DIV" && nodeN != "INPUT" && nodeN != "TEXTAREA"){
  44. return false;
  45. }
  46. }
  47. })
  48. }
  49. setDataIdx(index){
  50. this.setState({
  51. idx:index+''
  52. })
  53. }
  54. render() {
  55. const {flag,setPushEmergencyIdx,sysConfig} = this.props;
  56. return <div className={style['home-page']} onClick={this.props.hideAllDrop}>
  57. <BannerContainer />
  58. {/* <InfoTitle /> */}
  59. <BodyContainer></BodyContainer>
  60. {
  61. (setPushEmergencyIdx+'')&&(sysConfig.emergency_show==1)?<EmergencyProcedure data={dataLis[this.state.idx]||dataLis[setPushEmergencyIdx]} idx={this.state.idx||setPushEmergencyIdx} setDataIdx={this.setDataIdx}></EmergencyProcedure>:null
  62. }
  63. <div className={style['mask']} style={{display:flag?"block":"none"}}>
  64. <img src={loading} className={style['load']}/>
  65. </div>
  66. </div>;
  67. }
  68. }
  69. const mapStateToProps = function (state) {
  70. return {
  71. flag:state.homePage.loadingFlag,
  72. setPushEmergencyIdx: state.pushMessage.setPushEmergencyIdx || '',
  73. sysConfig:state.homePage.sysConfig
  74. }
  75. };
  76. const mapDispatchToProps = function (dispatch) {
  77. return {
  78. hideAllDrop(){
  79. dispatch({
  80. type:HIDEDROP
  81. });
  82. },
  83. /*getInit(){
  84. dispatch(getInitModules);
  85. }*/
  86. setWindow(obj){
  87. dispatch({
  88. type:SETMINSCREEN,
  89. obj:obj
  90. })
  91. },
  92. getChronicList(){
  93. dispatch(getChronic)
  94. },
  95. getConfig(){
  96. getSystemConfig().then((res)=>{
  97. if(res.data.code=='0'){
  98. dispatch({
  99. type:SETSYSTEMCONFIG,
  100. data: parseNameVal(res.data.data)
  101. })
  102. }else{
  103. }
  104. });
  105. }
  106. }
  107. };
  108. export default connect(mapStateToProps, mapDispatchToProps)(HomePage);