index.jsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React,{Component} from 'react';
  2. import style from './index.less';
  3. /***
  4. * author:zn@2018-11-13
  5. * 电子病历项内容框
  6. * 接收参数:
  7. * boxHeight:框高度
  8. * boxWidth:框宽度
  9. * title:框名称(如主诉、现病史)
  10. * editable:是否可编辑
  11. * children:框内内容
  12. * border:边框样式,
  13. * style
  14. *
  15. * ***/
  16. class ItemBox extends Component {
  17. constructor(props){
  18. super(props);
  19. this.handleClick = this.handleClick.bind(this);
  20. }
  21. getBoxStyle(){
  22. const {boxHeight,boxWidth,boxLineHeight,marginTop,backgroundColor} = this.props;
  23. return {width:boxWidth?boxWidth:undefined,height:boxHeight?boxHeight:undefined,lineHeight:boxLineHeight?boxLineHeight:'22px',marginTop:marginTop,backgroundColor:backgroundColor?backgroundColor:''};
  24. }
  25. handleClick(e){
  26. const {handleClick} = this.props;
  27. handleClick && handleClick(e);//为了获取鼠标位置,显示搜索结果框;
  28. }
  29. render(){
  30. const {title,children,editable,className,handleFocus,onchange,fuzhen,border,handleBlur,titleTop,backgroundColor} = this.props;
  31. // console.log(title,editable)
  32. return <div className={style["box"]+" "+"clearfix"} >
  33. <div className={style["title"] + ' ' + className} style={{marginTop:titleTop?'22px':''}}>{title}</div>
  34. <div className={`${style["content"]} ${border?style["border"]:''} ${backgroundColor?style["noBorder"]:''}`} contentEditable={editable} style={this.getBoxStyle()} onFocus={handleFocus} onInput={onchange} onClick={(e)=>{this.handleClick(e);}} onBlur={handleBlur}>
  35. {fuzhen?children||fuzhen:children}
  36. </div>
  37. </div>
  38. }
  39. }
  40. export default ItemBox;