OperationContainer.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import React from "react";
  2. import {connect} from "react-redux";
  3. import Operation from "../components/Operation";
  4. import {
  5. SHOW_PRINT_PREVIEW,
  6. CLOSE_PRINT_PREVIEW,
  7. SHOW_PREVIEW,
  8. CLOSE_PREVIEW,
  9. DIAG_SHOW
  10. } from "../store/types/print";
  11. import {saveMessage,clearMessages} from "../store/async-actions/print";
  12. import {saveTemplateDetail} from '@store/async-actions/tabTemplate';
  13. import {saveClickNum,getInitModules} from '@store/async-actions/homePage';
  14. import {getOtherHisRecord} from '@store/async-actions/fetchModules';
  15. import {RECOVER_TAG_MAIN} from '@store/types/mainSuit';
  16. import {RECOVER_TAG_CURRENT} from '@store/types/currentIll';
  17. import {RECOVER_TAG_OTHER} from '@store/types/otherHistory';
  18. import {RECOVER_TAG_CHECK} from '@store/types/checkBody';
  19. import {Notify} from '@commonComp';
  20. import {didPushParamChange} from '@utils/tools.js';
  21. import {billing} from '@store/async-actions/pushMessage';
  22. import {ISREAD} from '@store/types/homePage';
  23. // function mapStateToProps({print}) {
  24. function mapStateToProps(state) {
  25. const {print,homePage} = state;
  26. return ({
  27. print,
  28. winWidth:homePage.windowWidth,
  29. chronicMagItem: state.diagnosticList.chronicMagItem,//慢病疾病
  30. chronicDesease:state.mainSuit.chronicDesease,//主诉存的慢病
  31. });
  32. }
  33. function mapDispatchToProps(dispatch) {
  34. return {
  35. showPrintPreview: () => {
  36. dispatch({
  37. type: SHOW_PRINT_PREVIEW
  38. });
  39. },
  40. closePrintPreview: () => {
  41. dispatch({
  42. type: CLOSE_PRINT_PREVIEW
  43. });
  44. },
  45. showPreview: () => {
  46. dispatch({
  47. type: SHOW_PREVIEW
  48. });
  49. },
  50. closePreview: () => {
  51. dispatch({
  52. type: CLOSE_PREVIEW
  53. });
  54. },
  55. save: () => {
  56. dispatch(saveClickNum);
  57. dispatch(() => saveMessage())
  58. },
  59. clear: (flag) => {
  60. clearMessages();
  61. dispatch(getOtherHisRecord()); //清除后重新获取其他史记录
  62. // 清除时如果是慢病模板则重新获取模板
  63. if(flag){
  64. dispatch(getInitModules);
  65. }
  66. },
  67. saveDataAll(val,sex){
  68. dispatch(saveTemplateDetail(val,sex))
  69. },
  70. diagShowTmp(bool){
  71. dispatch({
  72. type: DIAG_SHOW,
  73. data:bool
  74. });
  75. },
  76. cancelDelTag(){
  77. const maps = {
  78. '1':RECOVER_TAG_MAIN,
  79. '2':RECOVER_TAG_CURRENT,
  80. '3':RECOVER_TAG_OTHER,
  81. '4':RECOVER_TAG_CHECK
  82. };
  83. const deledTags = localStorage.getItem('deletedTags')?JSON.parse(localStorage.getItem('deletedTags')):[];
  84. const deledSelects = localStorage.getItem('deletedSelects')?JSON.parse(localStorage.getItem('deletedSelects')):[];
  85. if(deledTags.length===0){
  86. Notify.info('暂无标签可还原');
  87. return ;
  88. }
  89. const arr = deledTags[0].delIndex.split("-");
  90. dispatch({
  91. type:maps[arr[0]],
  92. data:deledTags[0],
  93. select:deledSelects[0],
  94. index:arr[1]
  95. });
  96. dispatch({
  97. type:ISREAD
  98. });
  99. //右侧推送
  100. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  101. if(didPushParamChange()){ //操作后内容有变化才推送
  102. dispatch(billing());
  103. }
  104. },200);
  105. }
  106. };
  107. }
  108. const OperationComtainer = connect(
  109. mapStateToProps,
  110. mapDispatchToProps
  111. )(Operation);
  112. export default OperationComtainer;