CurrentIll.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import CurrentIll from '@components/CurrentIll';
  4. import {INSERT_PROCESS,SET_CURRENT_DATA,SETTEXTMODEVALUE,SET_LABEL_MODULE,SELECT_SEARCHDATA,CLEAR_CURRENT_EDIT} from '@store/types/currentIll';
  5. import {SET_CURRENT_ILL} from '@store/types/fillInfo'
  6. import {pushMessage} from '../store/async-actions/pushContainer';
  7. import {getModules} from '../store/async-actions/fetchModules.js';
  8. import {SETDROPSHOW} from '@types/homePage.js';
  9. import {HIDE,RESET,CLICKCOUNT,ISREAD} from '@store/types/homePage.js';
  10. import {billing} from '@store/async-actions/pushMessage';
  11. import {getModule} from '@store/async-actions/fetchModules.js';
  12. import {didPushParamChange} from '@utils/tools.js';
  13. function mapStateToProps(state) {
  14. const {homePage} = state;
  15. return {
  16. data:state.currentIll.data,//主诉模板
  17. emptyData:state.currentIll.emptyData,//空模板
  18. searchData:state.currentIll.searchDatas,//搜索结果
  19. focusIndex:state.currentIll.focusIndex,
  20. processModule:state.currentIll.processModule,//病程变化模板
  21. processModuleName:state.currentIll.processModuleName,//病程变化模板名称
  22. showArr:homePage.showDrop,
  23. span:state.currentIll.span,
  24. update:state.currentIll.update,//用于更新
  25. mainText:state.mainSuit.saveText,//主诉选中的数据
  26. mainData:state.mainSuit.data,//主诉使用的模板
  27. moduleNum:state.mainSuit.moduleNum,//主诉使用的模板
  28. type: state.typeConfig.typeConfig,
  29. mainIds:state.mainSuit.mainIds,//主诉症状选中的id(去重用)
  30. mainSymptIds:state.mainSuit.mainSymptIds,//主诉症状选中的id(移植用)
  31. fillInfo: state.fillInfo,
  32. showArr:homePage.showDrop,
  33. totalHide: homePage.totalHide,
  34. saveText:state.currentIll.saveText,
  35. selecteds:state.currentIll.selecteds, //普通多选选中状态
  36. editClear:state.currentIll.editClear,
  37. symptomIds:state.currentIll.symptomIds,//症状id,去重用
  38. isRead:state.homePage.isRead,
  39. fuzhen:state.diagnosticList.mainSuitStr,//诊断第一个复诊值
  40. }
  41. }
  42. function mapDispatchToProps(dispatch) {
  43. return {
  44. insertProcess(obj){//点击病程变化
  45. // 埋点dispatch
  46. dispatch({
  47. type:CLICKCOUNT,
  48. data:{id:obj.id},
  49. clickType:'单击',
  50. num:1
  51. });
  52. dispatch({
  53. type:INSERT_PROCESS,
  54. });
  55. dispatch({
  56. type:ISREAD
  57. })
  58. },
  59. async setData(info){//设置现病史使用模板
  60. let idsArr = info.mainIds;
  61. let ids = idsArr.join(",");
  62. let labelModule = await getModules(ids);
  63. if(labelModule.data.code==0){//根据id获取标签模板
  64. dispatch({
  65. type:SET_LABEL_MODULE,
  66. data:labelModule.data.data
  67. })
  68. }
  69. dispatch({
  70. type:SET_CURRENT_DATA,
  71. info
  72. })
  73. //右侧推送
  74. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  75. if(didPushParamChange()){ //操作后内容有变化才推送
  76. dispatch(billing);
  77. }
  78. },500);
  79. },
  80. setCurrentIll: value => {
  81. dispatch({type: SET_CURRENT_ILL, value})
  82. },
  83. pushMessage: (data) => {
  84. dispatch(() => pushMessage(data))
  85. },
  86. //文本模式下推送
  87. fetchPushInfos(){
  88. //调右侧推送
  89. dispatch(billing);
  90. },
  91. handleInput(obj){ //文本模式值保存
  92. dispatch({
  93. type:SETTEXTMODEVALUE,
  94. text:obj.text
  95. })
  96. },
  97. fetchModules(param){
  98. const {id,name,index,span} = param;
  99. getModule(id).then((res)=>{
  100. if(res.data.code=='0'){
  101. dispatch({
  102. type:SELECT_SEARCHDATA,
  103. index,
  104. name,
  105. data: res.data.data,
  106. span,
  107. isReplace:false
  108. })
  109. }
  110. });
  111. },
  112. changeEditIll(bool){
  113. dispatch({
  114. type:CLEAR_CURRENT_EDIT,
  115. editClear:bool
  116. })
  117. }
  118. }
  119. }
  120. const CurrentIllContainer = connect(
  121. mapStateToProps,
  122. mapDispatchToProps
  123. )(CurrentIll);
  124. export default CurrentIllContainer;