index.jsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import React,{Component} from 'react';
  2. import style from './index.less';
  3. import {Button,InlineTag,ItemBox,EditableSpan,Notify} from '@commonComp';
  4. import chooseType from '@containers/eleType.js';
  5. import SearchDrop from '@components/SearchDrop';
  6. class CheckBody extends Component{
  7. constructor(props){
  8. super(props);
  9. this.state={
  10. boxMark:'4',
  11. boxLeft:'0px',
  12. boxTop:'0px'
  13. };
  14. this.handleClick = this.handleClick.bind(this);
  15. this.handleSearchSelect = this.handleSearchSelect.bind(this);
  16. this.getData = this.getData.bind(this);
  17. //this.handleInput = this.handleInput.bind(this);
  18. }
  19. getLabels(){
  20. const {data,showArr,saveText,selecteds} = this.props;
  21. let arr = [],list=[];
  22. const {boxMark} = this.state;
  23. if(data){
  24. list = data;
  25. arr = list.map((it,i)=>{
  26. return chooseType({item:it,boxMark,i,showArr,saveText,selecteds});
  27. });
  28. }
  29. return arr;
  30. }
  31. handleClick(e){//让搜索框跟随鼠标点击移动
  32. //e.stopPropagation();
  33. const {fetchPushInfos,totalHide} = this.props;
  34. //fetchPushInfos&&fetchPushInfos();
  35. this.getData();
  36. if(totalHide){
  37. return ;
  38. }
  39. let boxLeft = e.pageX -102 + 'px';
  40. let boxTop = (+e.target.offsetTop+22)+'px';
  41. this.setState({
  42. boxLeft:boxLeft,
  43. boxTop:boxTop
  44. });
  45. }
  46. handleSearchSelect(obj){
  47. const {questionId,name} = obj;
  48. const {fetchModules,focusTextIndex,span,searchInEnd} = this.props;
  49. fetchModules&&fetchModules({id:questionId,index:focusTextIndex,name,span,searchInEnd});
  50. }
  51. getData(){
  52. //第一次聚焦查体时,主诉有数据则调接口,主诉无数据则显示提示;其他时间查体模板数据不调接口
  53. const {hasMain,saveText,data,isEmpty} = this.props;
  54. const hasData = saveText.join("")||data.length>0;
  55. if(!hasMain&&isEmpty){ //无主诉且本身无数据时,点击提示(空白页、清空)
  56. Notify.error("无法操作,请先输入主诉");
  57. return ;
  58. }
  59. //有主诉时且本身无数据,第一次点击获取数据,(不论获取成功与否)再点击不获取(直到刷新成空白页或清空)
  60. if(hasMain&&isEmpty){
  61. this.props.getInit();
  62. }
  63. }
  64. render(){
  65. const {searchData,totalHide,data} = this.props;
  66. const {boxLeft,boxTop,boxMark} = this.state;
  67. return <div className={style['container']}>
  68. <ItemBox title='查体' handleClick={this.handleClick}>
  69. {this.getLabels()}
  70. {searchData && searchData.length>0?<SearchDrop data={searchData} show={!totalHide} left={boxLeft} top={boxTop} onSelect={this.handleSearchSelect}></SearchDrop>:''}
  71. </ItemBox>
  72. </div>
  73. }
  74. }
  75. export default CheckBody;