NumberUnitDrop.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import React from 'react';
  2. import {connect} from 'react-redux';
  3. import NumberUnitDrop from "@components/NumberUnitDrop";
  4. import {SETNUMBER,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
  5. import {SETNUMBER4,CHANGECHECKTEXTLABEL} from '@types/checkBody.js';
  6. import {SETDROPSHOW,CLICKCOUNT,HIDE,RESET,HIDEDROP,ISREAD} 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 {Notify} from '@commonComp';
  11. import {filterArr,didPushParamChange} from '@utils/tools.js';
  12. import {billing} from '@store/async-actions/pushMessage';
  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. if(!params.text.trim()){
  124. dispatch({
  125. type:ISREAD
  126. })
  127. }
  128. },
  129. handleDbclick(obj){
  130. dispatch({
  131. type:CLICKCOUNT,
  132. data:obj,
  133. clickType:'双击',
  134. num:1
  135. });
  136. },
  137. handleHide(){
  138. dispatch({
  139. type:HIDEDROP
  140. })
  141. },
  142. handleShow(params) {
  143. dispatch({
  144. type:CLICKCOUNT,
  145. data:params,
  146. clickType:'单击',
  147. num:1
  148. });
  149. dispatch({
  150. type:SETDROPSHOW,
  151. data:params
  152. });
  153. /*dispatch({
  154. type: RESET
  155. });*/
  156. },
  157. handleLabelChange(params){
  158. const {type} = params;
  159. switch (+type){
  160. case 1:
  161. mainSuitLabel(dispatch,params);
  162. break;
  163. case 2:
  164. currentLabel(dispatch,params);
  165. break;
  166. case 3:
  167. otherHisLabelEdit(dispatch,params);
  168. break;
  169. case 4:
  170. checkBodyLabelEdit(dispatch,params);
  171. break;
  172. default:
  173. }
  174. dispatch({
  175. type: ISREAD
  176. });
  177. }
  178. }
  179. }
  180. const NumberUnitDropCont = connect(mapStateToProps,mapDispatchToProps)(NumberUnitDrop);
  181. export default NumberUnitDropCont;