Multiple.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // import React from "react";
  2. import {connect} from "react-redux";
  3. import Multiple from "@components/Multiple";
  4. import {RESET,SETDROPSHOW,HIDEDROP,CLICKCOUNT,ISREAD} from '@store/types/homePage.js';
  5. import {CURRENT_MUL,CURRENT_TEXT_LABEL} from '@types/currentIll';
  6. import {MAINSUIT_MUL,CHANGE_LABELVAL} from '@types/mainSuit';
  7. import {OTHERHIS_MUL,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
  8. import {CHECKBODY_MUL,CHANGECHECKTEXTLABEL} from '@types/checkBody';
  9. import {getLabelIndex,fullfillText,getIds} from '@common/js/func.js';
  10. import {filterArr,filterDataArr} from '@utils/tools.js';
  11. import config from '@config/index.js';
  12. import {Notify} from '@commonComp';
  13. function handleMainSuit(dispatch,params){
  14. const {ikey,seleData,seleId,value,mainSaveText} = params;
  15. //字数限制
  16. let mainText = filterDataArr(mainSaveText);
  17. let lengths = value?mainText.length - value.length + seleData.length:mainText.length + seleData.length;
  18. if(lengths > config.limited){
  19. Notify.info(config.limitText);
  20. return
  21. }
  22. const index = getLabelIndex(ikey);
  23. dispatch({
  24. type:MAINSUIT_MUL,
  25. data:{seleData,seleId,ikey:index}
  26. })
  27. }
  28. function handleCurrent(dispatch,params){
  29. const {ikey,seleData,seleId} = params;
  30. const index = getLabelIndex(ikey);
  31. dispatch({
  32. type:CURRENT_MUL,
  33. data:{seleData,seleId,ikey:index,fullIkey:ikey}
  34. })
  35. }
  36. function handleOtherHis(dispatch,params){
  37. const {ikey,seleData,seleId} = params;
  38. const index = getLabelIndex(ikey);
  39. dispatch({
  40. type:OTHERHIS_MUL,
  41. data:{seleData,seleId,ikey:index,fullIkey:ikey}
  42. })
  43. }
  44. function handleCheckBody(dispatch,params){
  45. const {ikey,seleData,seleId} = params;
  46. const index = getLabelIndex(ikey);
  47. dispatch({
  48. type:CHECKBODY_MUL,
  49. data:{seleData,seleId,ikey:index,fullIkey:ikey}
  50. })
  51. }
  52. function handleDiff(dispatch,params){
  53. const {type} = params;
  54. switch(+type){
  55. case 1:
  56. handleMainSuit(dispatch,params);
  57. break;
  58. case 2:
  59. handleCurrent(dispatch,params);
  60. break;
  61. case 3:
  62. handleOtherHis(dispatch,params);
  63. break;
  64. case 4:
  65. handleCheckBody(dispatch,params);
  66. break;
  67. default:
  68. }
  69. }
  70. /*****************双击标签改变值**********************/
  71. function changeMainSuit(dispatch,obj){
  72. const {ikey,changeVal} = obj;
  73. const index = getLabelIndex(ikey);
  74. dispatch({
  75. type:CHANGE_LABELVAL,
  76. data:{changeVal,ikey:index}
  77. })
  78. }
  79. function changeCurrent(dispatch,obj){
  80. const {ikey,changeVal} = obj;
  81. const index = getLabelIndex(ikey);
  82. dispatch({
  83. type:CURRENT_TEXT_LABEL,
  84. data:{changeVal,ikey:index}
  85. })
  86. }
  87. //其他史
  88. function changeOtherHis(dispatch,obj){
  89. const {ikey,changeVal} = obj;
  90. const index = getLabelIndex(ikey);
  91. dispatch({
  92. type:CHANGEOTHERTEXTLABEL,
  93. data:{changeVal,ikey:index}
  94. })
  95. }
  96. //查体
  97. function changeCheckBody(dispatch,obj){
  98. const {ikey,changeVal} = obj;
  99. const index = getLabelIndex(ikey);
  100. dispatch({
  101. type:CHANGECHECKTEXTLABEL,
  102. data:{changeVal,ikey:index}
  103. })
  104. }
  105. function handleLabel(dispatch,obj){
  106. const {type} = obj;
  107. switch (+type) {
  108. case 1:
  109. changeMainSuit(dispatch,obj);
  110. break;
  111. case 2:
  112. changeCurrent(dispatch,obj);
  113. break;
  114. case 3:
  115. changeOtherHis(dispatch,obj);
  116. break;
  117. case 4:
  118. changeCheckBody(dispatch,obj);
  119. break;
  120. default:
  121. }
  122. }
  123. function mapStateToProps(state){
  124. return{
  125. mainSaveText:state.mainSuit.saveText,
  126. }
  127. }
  128. function mapDispatchToProps(dispatch){
  129. return{
  130. handleShow(obj){
  131. dispatch({
  132. type:CLICKCOUNT,
  133. data:obj,
  134. clickType:'单击',
  135. num:1
  136. });
  137. dispatch({
  138. type:SETDROPSHOW,
  139. data:obj
  140. });
  141. dispatch({
  142. type: RESET
  143. });
  144. },
  145. handleHide(){
  146. dispatch({
  147. type:HIDEDROP
  148. })
  149. },
  150. handleDbclick(obj){//双击统计
  151. dispatch({
  152. type:CLICKCOUNT,
  153. data:obj,
  154. clickType:'双击',
  155. num:1
  156. });
  157. },
  158. handleLabelChange(obj){//标签内输入
  159. handleLabel(dispatch,obj);
  160. },
  161. handleConfirm(params){
  162. handleDiff(dispatch,params);
  163. }
  164. }
  165. }
  166. const MultipleContainer = connect(mapStateToProps,mapDispatchToProps)(Multiple);
  167. export default MultipleContainer;