RadioDrop.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import React from 'react';
  2. import {connect} from 'react-redux';
  3. import RadioDrop from "@components/RadioDrop";
  4. import {SETRADIO,CLEARSELECTED,CONFIRMSELECTED,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
  5. import {SETSELECTED4,CHANGECHECKTEXTLABEL} from '@types/checkBody';
  6. import {SETDROPSHOW,HIDE,RESET,HIDEDROP,CLICKCOUNT,ISREAD} from '@types/homePage.js';
  7. import {RADIO_SELECT,CHANGE_LABELVAL} from '@store/types/mainSuit.js';
  8. import {CURRENT_RADIO,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
  9. import {Notify} from '@commonComp';
  10. import {filterArr,didPushParamChange} from '@utils/tools.js';
  11. import {billing} from '@store/async-actions/pushMessage';
  12. import {getLabelIndex,fullfillText} from '@common/js/func.js';
  13. import config from '@config/index.js';
  14. function mapStateToProps(state){
  15. return {
  16. mainSaveText:state.mainSuit.saveText,
  17. }
  18. }
  19. // 主诉选中事件
  20. function mainSelect(dispatch,params){
  21. const {id,ikey,text} = params;
  22. dispatch({
  23. type:RADIO_SELECT,
  24. id,
  25. ikey,
  26. text:text||''
  27. });
  28. }
  29. // 现病史选中事件
  30. function currentSelect(dispatch,params){
  31. const {id,ikey,text} = params;
  32. dispatch({
  33. type:CURRENT_RADIO,
  34. id,
  35. ikey,
  36. text:text||''
  37. });
  38. }
  39. //其他史选中事件
  40. function otherSelect(dispatch,params){
  41. const {id,ikey,text} = params;
  42. dispatch({
  43. type:SETRADIO,
  44. id,
  45. ikey,
  46. text:text||''
  47. });
  48. }
  49. //查体单选下拉选中事件
  50. function checkSelect(dispatch,params){
  51. const {id,ikey,text} = params;
  52. dispatch({
  53. type:SETSELECTED4,
  54. id,
  55. ikey,
  56. text:text||''
  57. });
  58. }
  59. //在不同模块(主诉、现病史等)下拉选中调用不同事件
  60. function handleModuleDiff(dispatch,store,params){
  61. const {mainSaveText} = params;
  62. const type = params.ikey.substr(0,1); //当前所在的项目
  63. switch (+type){
  64. case 1:
  65. let text = filterArr(mainSaveText);
  66. if(text.length >= config.limited){
  67. Notify.info(config.limitText);
  68. return
  69. }
  70. mainSelect(dispatch,params);
  71. break;
  72. case 2:
  73. currentSelect(dispatch,params);
  74. break;
  75. case 3:
  76. otherSelect(dispatch,params);
  77. break;
  78. case 4:
  79. checkSelect(dispatch,params);
  80. break;
  81. default:
  82. }
  83. }
  84. /**************标签双击输入action types**************/
  85. const dbEditActions = {
  86. 1:CHANGE_LABELVAL,
  87. 2:CURRENT_TEXT_LABEL,
  88. 3:CHANGEOTHERTEXTLABEL,
  89. 4:CHANGECHECKTEXTLABEL
  90. };
  91. function mapDispatchToProps(dispatch,store){
  92. return {
  93. handleSelect(params) {
  94. handleModuleDiff(dispatch, store, params);
  95. //单选选中隐藏弹窗
  96. dispatch({
  97. type: HIDEDROP
  98. });
  99. //右侧推送
  100. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  101. if(didPushParamChange()){ //操作后内容有变化才推送
  102. dispatch(billing);
  103. }
  104. },500);
  105. },
  106. handleDbclick(obj){//双击统计
  107. dispatch({
  108. type:CLICKCOUNT,
  109. data:obj,
  110. clickType:'双击',
  111. num:1
  112. });
  113. },
  114. handleLabelEdit(params){
  115. const {type} = params;
  116. const index = params.ikey;
  117. let ikey = getLabelIndex(index);
  118. dispatch({
  119. type:dbEditActions[+type],
  120. data:{changeVal:params.changeVal,ikey:ikey}
  121. });
  122. dispatch(billing);
  123. dispatch({
  124. type:ISREAD
  125. })
  126. },
  127. handleShow(obj) {
  128. dispatch({
  129. type:CLICKCOUNT,
  130. data:obj,
  131. clickType:'单击',
  132. num:1
  133. });
  134. dispatch({
  135. type:SETDROPSHOW,
  136. data:obj
  137. });
  138. dispatch({
  139. type: RESET
  140. });
  141. }
  142. }
  143. }
  144. const RadioDropCont = connect(mapStateToProps,mapDispatchToProps)(RadioDrop);
  145. export default RadioDropCont;