index.jsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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} = this.props;//console.log(focusTextIndex)
  49. fetchModules&&fetchModules({id:questionId,index:focusTextIndex,name,span});
  50. }
  51. getData(){
  52. //第一次聚焦查体时,主诉有数据则调接口,主诉无数据则显示提示;其他时间查体模板数据不调接口
  53. const {hasMain,saveText,data,fetchPushInfos} = this.props;
  54. const hasData = saveText.join("")||data.length>0;
  55. if(hasData){
  56. return ;
  57. }
  58. if(hasMain){
  59. this.props.getInit();
  60. }else{
  61. Notify.error("无法操作,请先输入主诉");
  62. }
  63. }
  64. handleInput(e){ //主诉未填无法输入
  65. if(!this.props.hasMain){
  66. e.target.innerText='';
  67. }
  68. }
  69. render(){
  70. const {searchData,totalHide,data} = this.props;
  71. const {boxLeft,boxTop,boxMark} = this.state;
  72. return <div className={style['container']}>
  73. <ItemBox title='查体' editable={!data.length} handleClick={this.handleClick} onchange={this.handleInput}>
  74. {this.getLabels()}
  75. {searchData && searchData.length>0?<SearchDrop data={searchData} show={!totalHide} left={boxLeft} top={boxTop} onSelect={this.handleSearchSelect}></SearchDrop>:''}
  76. </ItemBox>
  77. </div>
  78. }
  79. }
  80. export default CheckBody;