OperationContainer.js 4.1 KB

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