|
@@ -22,9 +22,11 @@ class CommonSymptom extends Component{
|
|
|
hide:false,
|
|
|
conceptId:[]
|
|
|
}
|
|
|
+ this.div = React.createRef();
|
|
|
this.handleSelect = this.handleSelect.bind(this);
|
|
|
this.handleClear = this.handleClear.bind(this);
|
|
|
this.handleConfirm = this.handleConfirm.bind(this);
|
|
|
+ this.handleOuter = this.handleOuter.bind(this);
|
|
|
}
|
|
|
getClass(){
|
|
|
let isHide = this.props.show?'':style['hide'];
|
|
@@ -32,7 +34,7 @@ class CommonSymptom extends Component{
|
|
|
}
|
|
|
|
|
|
handleSelect(e,item){
|
|
|
- e.stopPropagation();
|
|
|
+ // e.stopPropagation();
|
|
|
let {select,ids,conceptId} = this.state;
|
|
|
const id = item.questionId||item.id; //缓存localStorage中的数据有id
|
|
|
const copid = item.conceptId
|
|
@@ -70,7 +72,7 @@ class CommonSymptom extends Component{
|
|
|
return '';
|
|
|
}
|
|
|
handleClear(e){
|
|
|
- e.stopPropagation();
|
|
|
+ // e.stopPropagation();
|
|
|
this.setState({
|
|
|
select:[],
|
|
|
ids:[],
|
|
@@ -78,32 +80,35 @@ class CommonSymptom extends Component{
|
|
|
})
|
|
|
}
|
|
|
handleConfirm(e){
|
|
|
- e.stopPropagation();
|
|
|
+ // e.stopPropagation();
|
|
|
const {onSelect} = this.props;
|
|
|
const {select,ids,conceptId} = this.state;
|
|
|
onSelect&&onSelect({select,ids,conceptId});
|
|
|
}
|
|
|
|
|
|
- componentDidMount(){
|
|
|
- $(document).click((e)=>{
|
|
|
- let itemBox = $('#mainSuit')[0];
|
|
|
- let divBox = $('#symptBox')[0];
|
|
|
- let listBox = $('#listBox')[0];
|
|
|
- let hisBox = $('#his')[0];
|
|
|
- let operBox = $('#oper')[0];
|
|
|
- if(e.target != itemBox && e.target.parentNode != divBox && e.target.parentNode != listBox && e.target.parentNode != hisBox && e.target.parentNode != operBox && e.target != divBox ){
|
|
|
- this.setState({
|
|
|
- hide:true,
|
|
|
- select:[],
|
|
|
- ids:[],
|
|
|
- conceptId:[]
|
|
|
- })
|
|
|
- }else{
|
|
|
- this.setState({
|
|
|
- hide:false
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ handleOuter(e){
|
|
|
+ e.stopPropagation();
|
|
|
+ let itemBox = $('#mainSuit')[0]; //主诉框
|
|
|
+ if(this.div.current.contains(e.target) || e.target == itemBox){
|
|
|
+ this.setState({
|
|
|
+ hide:false
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setState({
|
|
|
+ hide:true,
|
|
|
+ select:[],
|
|
|
+ ids:[],
|
|
|
+ conceptId:[]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ componentDidMount() {
|
|
|
+ window.addEventListener('click', this.handleOuter);
|
|
|
+ }
|
|
|
+
|
|
|
+ componentWillUnmount() {
|
|
|
+ window.removeEventListener('click', this.handleOuter);
|
|
|
}
|
|
|
|
|
|
render(){
|
|
@@ -111,9 +116,9 @@ class CommonSymptom extends Component{
|
|
|
const {hide} = this.state;
|
|
|
const mainSymp = storageLocal.get('mainSymp');
|
|
|
const mainHis = mainSymp?JSON.parse(mainSymp).reverse():[];
|
|
|
- return <div className={this.getClass()} contenteditable="false" id="symptBox" style={{'display':hide?'none':'block'}}>
|
|
|
- <ul className={style["listBox"]} id="listBox">
|
|
|
- {mainHis.length>0?<ul className={style["his"]} id="his">
|
|
|
+ return <div className={this.getClass()} contenteditable="false" style={{'display':hide?'none':'block'}} ref={this.div} onClick={this.handleOuter}>
|
|
|
+ <ul className={style["listBox"]}>
|
|
|
+ {mainHis.length>0?<ul className={style["his"]}>
|
|
|
<p>最近输入症状:</p>
|
|
|
{mainHis.map((it)=>{
|
|
|
return <li onClick={(e)=>this.handleSelect(e,it)} className={this.getStyle(it.conceptId)} title={it.name.length>5?it.name:''}>{it.name.length>5?it.name.slice(0,4)+'...':it.name}</li>
|
|
@@ -124,7 +129,7 @@ class CommonSymptom extends Component{
|
|
|
return <li onClick={(e)=>this.handleSelect(e,it)} className={this.getStyle(it.conceptId)} title={it.name.length>5?it.name:''}>{it.name.length>5?it.name.slice(0,4)+'...':it.name}</li>
|
|
|
})}
|
|
|
</ul>
|
|
|
- <div className={style['oper']} id="oper">
|
|
|
+ <div className={style['oper']}>
|
|
|
<span className={style['clear']} onClick={this.handleClear}>清空选项</span>
|
|
|
<span className={style['confirm']} onClick={this.handleConfirm}>确定</span>
|
|
|
</div>
|