NumberDrop.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import React from 'react';
  2. import {connect} from 'react-redux';
  3. import NumberDrop from "@components/NumberDrop";
  4. import {SETNUMBER,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
  5. import {SETNUMBER4,CHANGECHECKTEXTLABEL} from '@types/checkBody.js';
  6. import {SETDROPSHOW,CLICKCOUNT,HIDE,RESET,HIDEDROP} from '@types/homePage.js';
  7. import {NUMBER_SELECT,CHANGE_LABELVAL} from '@store/types/mainSuit.js';
  8. import {getLabelIndex} from '@common/js/func.js';
  9. import {CURRENT_NUMBER,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
  10. import {billing} from '@store/async-actions/pushMessage';
  11. import {Notify} from '@commonComp';
  12. import {filterArr,didPushParamChange} from '@utils/tools.js';
  13. import config from '@config/index.js';
  14. function mapStateToProps(state){
  15. return {
  16. mainSaveText:state.mainSuit.saveText,
  17. }
  18. }
  19. //查体数字键盘选中
  20. function checkSelect(dispatch,params){
  21. dispatch({
  22. type:SETNUMBER4,
  23. params
  24. });
  25. }
  26. //其他史数字键盘选中
  27. function otherSelect(dispatch,params){
  28. dispatch({
  29. type:SETNUMBER,
  30. params
  31. });
  32. }
  33. //主诉
  34. function mainSelect(dispatch,params){
  35. dispatch({
  36. type:NUMBER_SELECT,
  37. params
  38. });
  39. }
  40. //现病史
  41. function currentSelect(dispatch,params){
  42. dispatch({
  43. type:CURRENT_NUMBER,
  44. params
  45. });
  46. }
  47. function handleModuleDiff(dispatch,params){
  48. const {mainSaveText} = params;
  49. const type = params.ikey.substr(0,1); //当前所在的项目
  50. switch (+type){
  51. case 1:
  52. let text = filterArr(mainSaveText);
  53. if(text.length >= config.limited){
  54. Notify.info(config.limitText);
  55. return
  56. }
  57. mainSelect(dispatch,params);
  58. break;
  59. case 2:
  60. currentSelect(dispatch,params);
  61. break;
  62. case 3:
  63. otherSelect(dispatch,params);
  64. break;
  65. case 4:
  66. checkSelect(dispatch,params);
  67. break;
  68. default:
  69. }
  70. }
  71. /**************************双击标签输入*********************************/
  72. // 主诉
  73. function mainSuitLabel(dispatch,params){
  74. const index = params.ikey;
  75. let ikey = getLabelIndex(index);
  76. const {changeVal,totalVal} = params;
  77. dispatch({
  78. type:CHANGE_LABELVAL,
  79. data:{changeVal:changeVal,ikey:ikey,totalVal}
  80. })
  81. }
  82. // 现病史
  83. function currentLabel(dispatch,params){
  84. const index = params.ikey;
  85. let ikey = getLabelIndex(index);
  86. dispatch({
  87. type:CURRENT_TEXT_LABEL,
  88. data:{changeVal:params.changeVal,ikey:ikey}
  89. })
  90. }
  91. //其他史
  92. function otherHisLabelEdit(dispatch,params){
  93. const index = params.ikey;
  94. const {changeVal,totalVal} = params;
  95. let ikey = getLabelIndex(index);
  96. dispatch({
  97. type:CHANGEOTHERTEXTLABEL,
  98. data:{changeVal:changeVal,ikey:ikey,totalVal}
  99. })
  100. }
  101. //查体
  102. function checkBodyLabelEdit(dispatch,params){
  103. const index = params.ikey;
  104. let ikey = getLabelIndex(index);
  105. const {changeVal,totalVal} = params;
  106. dispatch({
  107. type:CHANGECHECKTEXTLABEL,
  108. data:{changeVal:changeVal,ikey:ikey,totalVal}
  109. })
  110. }
  111. function mapDispatchToProps(dispatch,store){
  112. return {
  113. handleSelect(params){
  114. handleModuleDiff(dispatch,params);
  115. //右侧推送
  116. clearTimeout(timer);
  117. let timer = setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  118. if(didPushParamChange()){ //操作后内容有变化才推送
  119. dispatch(billing);
  120. clearTimeout(timer);
  121. }
  122. },config.delayPushTime);
  123. },
  124. handleDbclick(obj){
  125. dispatch({
  126. type:CLICKCOUNT,
  127. data:obj,
  128. clickType:'双击',
  129. num:1
  130. });
  131. },
  132. handleHide(){
  133. dispatch({
  134. type:HIDEDROP
  135. })
  136. },
  137. handleShow(params) {
  138. dispatch({
  139. type:CLICKCOUNT,
  140. data:params,
  141. clickType:'单击',
  142. num:1
  143. });
  144. dispatch({
  145. type:SETDROPSHOW,
  146. data:params
  147. });
  148. /*dispatch({
  149. type: RESET
  150. });*/
  151. },
  152. handleLabelChange(params){
  153. const {type} = params;
  154. switch (+type){
  155. case 1:
  156. mainSuitLabel(dispatch,params);
  157. break;
  158. case 2:
  159. currentLabel(dispatch,params);
  160. break;
  161. case 3:
  162. otherHisLabelEdit(dispatch,params);
  163. break;
  164. case 4:
  165. checkBodyLabelEdit(dispatch,params);
  166. break;
  167. default:
  168. }
  169. }
  170. }
  171. }
  172. const NumberDropCont = connect(mapStateToProps,mapDispatchToProps)(NumberDrop);
  173. export default NumberDropCont;