CurrentIll.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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,SAVE_CURR_FREE} from '@store/types/currentIll';
  5. import {pushMessage} from '../store/async-actions/pushContainer';
  6. import {getModules} from '../store/async-actions/fetchModules.js';
  7. import {SETDROPSHOW} from '@types/homePage.js';
  8. import {HIDE,RESET,CLICKCOUNT,ISREAD,SEARCH_DROP_LOCATION} from '@store/types/homePage.js';
  9. import {billing} from '@store/async-actions/pushMessage';
  10. import {getModule} from '@store/async-actions/fetchModules.js';
  11. import {didPushParamChange} from '@utils/tools.js';
  12. import {Notify} from '@commonComp';
  13. function mapStateToProps(state) {
  14. const {homePage,currentIll,mainSuit,diagnosticList} = state;
  15. return {
  16. data:currentIll.data,//主诉模板
  17. emptyData:currentIll.emptyData,//空模板
  18. searchData:currentIll.searchDatas,//搜索结果
  19. focusIndex:currentIll.focusIndex,
  20. processModule:currentIll.processModule,//病程变化模板
  21. showArr:homePage.showDrop,
  22. span:currentIll.span,
  23. update:currentIll.update,//用于更新
  24. mainText:mainSuit.saveText,//主诉选中的数据
  25. mainData:mainSuit.data,//主诉使用的模板
  26. symptomFeature:mainSuit.symptomFeature,//主诉分词数据
  27. moduleNum:mainSuit.moduleNum,//主诉使用的模板
  28. type: state.typeConfig.typeConfig,
  29. mainIds:mainSuit.mainIds,//主诉症状选中的id(去重用)
  30. mainTailIds:mainSuit.mainTailIds,//主诉症状选中的id(去重用)
  31. totalHide: homePage.totalHide,
  32. saveText:currentIll.saveText,
  33. selecteds:currentIll.selecteds, //普通多选选中状态
  34. editClear:currentIll.editClear,
  35. symptomIds:currentIll.symptomIds,//症状id,去重用
  36. isRead:homePage.isRead,
  37. fuzhen:diagnosticList.mainSuitStr,//诊断第一个复诊值
  38. boxTop:homePage.boxTop,
  39. boxLeft:homePage.boxLeft,
  40. allModules:homePage.allModules,
  41. // isChronic:!!diagnosticList.chronicMagItem,
  42. isChronic:mainSuit.chronicDesease?mainSuit.chronicDesease:diagnosticList.chronicMagItem,
  43. }
  44. }
  45. function mapDispatchToProps(dispatch) {
  46. return {
  47. insertProcess(obj,allModules){//点击病程变化
  48. // 埋点dispatch
  49. dispatch({
  50. type:CLICKCOUNT,
  51. data:{id:obj.id},
  52. clickType:'单击',
  53. num:1
  54. });
  55. // 判断是否有子模板数据
  56. const sonId = obj.relationModule;//子模板id
  57. let sonArr = allModules.filter((item)=>{return item.id==sonId})
  58. if(sonArr.length==0){//未匹配到子模板
  59. Notify.info("未找到相关内容");
  60. return
  61. }
  62. dispatch({
  63. type:INSERT_PROCESS,
  64. // id:obj.relationModule,
  65. // allModules:allModules
  66. addSmoduleData:JSON.parse(JSON.stringify(sonArr[0].moduleDetailDTOList))
  67. });
  68. dispatch({
  69. type:ISREAD
  70. })
  71. },
  72. async setData(info){//设置现病史使用模板
  73. // let idsArr = info.mainIds;
  74. let idsArr = info.mainTailIds.filter((it,i)=>{return it});
  75. // let ids = idsArr.join(",");
  76. let labelModule = await getModules(idsArr);
  77. if(labelModule.data.code==0){//根据id获取标签模板
  78. dispatch({
  79. type:SET_LABEL_MODULE,
  80. data:labelModule.data.data
  81. })
  82. }
  83. dispatch({
  84. type:SET_CURRENT_DATA,
  85. info
  86. })
  87. //右侧推送
  88. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  89. if(didPushParamChange()){ //操作后内容有变化才推送
  90. dispatch(billing());
  91. }
  92. },500);
  93. },
  94. pushMessage: (data) => {
  95. dispatch(() => pushMessage(data))
  96. },
  97. //文本模式下推送
  98. fetchPushInfos(){
  99. //调右侧推送
  100. if(didPushParamChange()) {
  101. dispatch(billing());
  102. }
  103. },
  104. handleInput(obj){ //文本模式值保存
  105. dispatch({
  106. type:SETTEXTMODEVALUE,
  107. text:obj.text
  108. })
  109. },
  110. fetchModules(param){
  111. const {id,name,index,span,conceptId} = param;
  112. getModule(id).then((res)=>{
  113. if(res.data.code=='0'){
  114. dispatch({
  115. type:SELECT_SEARCHDATA,
  116. index,
  117. name,
  118. data: res.data.data,
  119. span,
  120. isReplace:false,
  121. conceptId
  122. })
  123. dispatch({
  124. type:ISREAD
  125. })
  126. }
  127. });
  128. //右侧推送
  129. setTimeout(function(){
  130. dispatch(billing());
  131. },200);
  132. },
  133. changeEditIll(bool){
  134. dispatch({
  135. type:CLEAR_CURRENT_EDIT,
  136. editClear:bool
  137. })
  138. },
  139. getSearchLocation(top,left){
  140. dispatch({
  141. type:SEARCH_DROP_LOCATION,
  142. top:top,
  143. left:left,
  144. dis:0
  145. })
  146. },
  147. freeText(item){//自由输入
  148. dispatch({
  149. type: SAVE_CURR_FREE,
  150. data:item
  151. })
  152. //右侧推送
  153. setTimeout(function(){
  154. if(didPushParamChange()){
  155. dispatch(billing());
  156. }
  157. },500);
  158. }
  159. }
  160. }
  161. const CurrentIllContainer = connect(
  162. mapStateToProps,
  163. mapDispatchToProps
  164. )(CurrentIll);
  165. export default CurrentIllContainer;