12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import React,{Component} from 'react';
- import style from './index.less';
- import {Button,InlineTag,ItemBox,EditableSpan,Notify} from '@commonComp';
- import chooseType from '@containers/eleType.js';
- import SearchDrop from '@components/SearchDrop';
- class CheckBody extends Component{
- constructor(props){
- super(props);
- this.state={
- boxMark:'4',
- boxLeft:'0px',
- boxTop:'0px'
- };
- this.handleClick = this.handleClick.bind(this);
- this.handleSearchSelect = this.handleSearchSelect.bind(this);
- this.getData = this.getData.bind(this);
- //this.handleInput = this.handleInput.bind(this);
- }
- getLabels(){
- const {data,showArr,saveText,selecteds} = this.props;
- let arr = [],list=[];
- const {boxMark} = this.state;
- if(data){
- list = data;
- arr = list.map((it,i)=>{
- return chooseType({item:it,boxMark,i,showArr,saveText,selecteds});
- });
- }
- return arr;
- }
- handleClick(e){//让搜索框跟随鼠标点击移动
- //e.stopPropagation();
- const {fetchPushInfos,totalHide} = this.props;
- //fetchPushInfos&&fetchPushInfos();
- this.getData();
- if(totalHide){
- return ;
- }
- //若使用e.target,因为是onClick事件中,值可能是itembox的而不是span因此会有bug
- const ele = document.activeElement;
- const height = ele.offsetHeight;
- let boxTop = (+(ele.offsetTop)+height)+'px';
- let boxLeft = ele.offsetLeft + 'px';
- this.setState({
- boxLeft:boxLeft,
- boxTop:boxTop
- });
- }
- handleSearchSelect(obj){
- const {questionId,name} = obj;
- const {fetchModules,focusTextIndex,span,searchInEnd} = this.props;
- fetchModules&&fetchModules({id:questionId,index:focusTextIndex,name,span,searchInEnd});
- }
- getData(){
- //第一次聚焦查体时,主诉有数据则调接口,主诉无数据则显示提示;其他时间查体模板数据不调接口
- const {hasMain,saveText,data,isEmpty} = this.props;
- const hasData = saveText.join("")||data.length>0;
- if(!hasMain&&isEmpty){ //无主诉且本身无数据时,点击提示(空白页、清空)
- Notify.error("无法操作,请先输入主诉");
- return ;
- }
- //有主诉时且本身无数据,第一次点击获取数据,(不论获取成功与否)再点击不获取(直到刷新成空白页或清空)
- if(hasMain&&isEmpty!=false){
- this.props.getInit();
- }
- }
- render(){
- const {searchData,totalHide,data} = this.props;
- const {boxLeft,boxTop,boxMark} = this.state;
- return <div className={style['container']}>
- <ItemBox title='查体' handleClick={this.handleClick}>
- {this.getLabels()}
- {searchData && searchData.length>0?<SearchDrop data={searchData} show={!totalHide} left={boxLeft} top={boxTop} onSelect={this.handleSearchSelect}></SearchDrop>:''}
- </ItemBox>
- </div>
- }
- }
- export default CheckBody;
|