OtherHistory.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import React from 'react';
  2. import {connect} from 'react-redux';
  3. import OtherHistory from "../components/OtherHistory";
  4. import {SETSELECTED,CLEARSELECTED,CONFIRMSELECTED,SELECTOTHERSEARCHDATA,SETDATA,SETTEXTMODEVALUE,OTHEREDICLEAR} from '@types/otherHistory';
  5. import {HIDE,RESET,ISREAD} from '@store/types/homePage.js';
  6. import {getModule} from '@store/async-actions/fetchModules.js';
  7. import {billing} from '@store/async-actions/pushMessage';
  8. import {fullfillText} from '@common/js/func';
  9. import {didPushParamChange} from '@utils/tools.js';
  10. function mapStateToProps(state){
  11. const {otherHistory,homePage,typeConfig,mainSuit} = state;
  12. const hasMain = mainSuit.saveText.join('');//||mainSuit.data.length;
  13. return {
  14. data: otherHistory.data,
  15. //initData:state.homePage.initData.otherHis,
  16. update:otherHistory.update, //用于触发更新
  17. showArr:homePage.showDrop,
  18. totalHide:homePage.totalHide,
  19. saveText:otherHistory.saveText,
  20. type: typeConfig.typeConfig,
  21. hasMain,//主诉是否有数据
  22. searchData:otherHistory.searchData, //延迟搜索结果
  23. focusTextIndex:otherHistory.focusIndex, //聚焦的自由文本标签index
  24. span:otherHistory.span,
  25. selecteds:otherHistory.selecteds, //普通多选选中状态
  26. editClear:otherHistory.editClear, //编辑状态
  27. isRead:state.homePage.isRead
  28. }
  29. }
  30. function mapDispatchToProps(dispatch,store){
  31. return {
  32. setInitData(){
  33. //先获取最近记录,没有的话显示模板
  34. dispatch((dispatch,getStore)=>{
  35. const initData = getStore().homePage.initData;
  36. const arr = JSON.parse(JSON.stringify(initData.otherHis));
  37. const arrSave = JSON.parse(JSON.stringify(initData.otherHisSave||null));
  38. const isHis = initData.otherIsHis;
  39. const listObj = isHis?{newArr:arr,saveText:arrSave||[]}:fullfillText(arr);
  40. dispatch({
  41. type:SETDATA,
  42. data:listObj.newArr,
  43. save:listObj.saveText
  44. });
  45. dispatch({
  46. type:ISREAD
  47. })
  48. });
  49. //右侧推送
  50. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  51. if(didPushParamChange()){ //操作后内容有变化才推送
  52. dispatch(billing);
  53. }
  54. },500);
  55. },
  56. fetchModules(param){
  57. const {id,name,index,span} = param;
  58. getModule(id).then((res)=>{
  59. if(res.data.code=='0'){
  60. dispatch({
  61. type:SELECTOTHERSEARCHDATA,
  62. index,
  63. name,
  64. data: res.data.data,
  65. span,
  66. isReplace:false
  67. });
  68. dispatch({
  69. type:ISREAD
  70. });
  71. }
  72. });
  73. },
  74. //右侧推送
  75. fetchPushInfos(){
  76. //调右侧推送
  77. dispatch(billing);
  78. },
  79. handleInput(obj){ //文本模式值保存
  80. dispatch({
  81. type:SETTEXTMODEVALUE,
  82. text:obj.text
  83. })
  84. },
  85. changeEditClear(bool){ //文本编辑模式
  86. dispatch({
  87. type:OTHEREDICLEAR,
  88. bool:bool
  89. })
  90. }
  91. }
  92. }
  93. const OtherHistoryCont = connect(mapStateToProps,mapDispatchToProps)(OtherHistory);
  94. export default OtherHistoryCont;