CheckBody.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {connect} from 'react-redux';
  2. import CheckBody from '@components/CheckBody';
  3. import {getModule,getInitData} from '@store/async-actions/fetchModules.js';
  4. import {HIDE,RESET,SETDROPSHOW,ISREAD,SEARCH_DROP_LOCATION,MODI_LOADING} from '@store/types/homePage.js';
  5. import {SELECTSEARCHDATA} from "@store/types/checkBody";
  6. import {filterDataArr} from '@utils/tools.js';
  7. function mapStateToProps(state){
  8. const {homePage,mainSuit,checkBody} = state;
  9. const hasMain = filterDataArr(mainSuit.saveText);//||mainSuit.data.length;
  10. return {
  11. data:checkBody.data,
  12. defaultShowAll:checkBody.showAll,
  13. isEmpty:checkBody.isEmpty,
  14. update:checkBody.update, //用于触发更新
  15. showArr:homePage.showDrop,
  16. totalHide:homePage.totalHide,
  17. saveText:checkBody.saveText,
  18. searchData:checkBody.searchData, //延迟搜索结果
  19. hasMain,//主诉选中的数据
  20. focusTextIndex:checkBody.focusIndex, //聚焦的自由文本标签index
  21. span:checkBody.span,
  22. searchInEnd:checkBody.searchInEnd, //是否在搜索末尾插入结果
  23. selecteds:checkBody.selecteds, //普通多选选中状态
  24. boxTop:state.homePage.boxTop,
  25. boxLeft:state.homePage.boxLeft,
  26. importLabel:checkBody.importLabel, //需高亮的标签id
  27. }
  28. }
  29. function mapDispatchToProps(dispatch){
  30. return {
  31. getInit(){
  32. //dispatch({type:MODI_LOADING,flag:true});
  33. dispatch(getInitData());
  34. },
  35. fetchModules(param){
  36. const {id,name,index,span,searchInEnd} = param;
  37. getModule(id).then((res)=>{
  38. if(res.data.code=='0'){
  39. dispatch({
  40. type:SELECTSEARCHDATA,
  41. index,
  42. name,
  43. data: res.data.data,
  44. span,
  45. isReplace:false,
  46. searchInEnd
  47. })
  48. dispatch({
  49. type:ISREAD
  50. })
  51. }
  52. });
  53. },
  54. getSearchLocation(top,left){
  55. dispatch({
  56. type:SEARCH_DROP_LOCATION,
  57. top:top,
  58. left:left,
  59. dis:0
  60. })
  61. }
  62. }
  63. }
  64. const CheckBodyCont = connect(mapStateToProps,mapDispatchToProps)(CheckBody);
  65. export default CheckBodyCont;