|
@@ -31,6 +31,7 @@ class NumberDrop extends Component{
|
|
|
this.handleNumFocus = this.handleNumFocus.bind(this);
|
|
|
this.handleKeyDowm = this.handleKeyDowm.bind(this);
|
|
|
this.beyondArea = this.beyondArea.bind(this);
|
|
|
+ this.emitBMIData = this.emitBMIData.bind(this);
|
|
|
}
|
|
|
select(text){ //选中键盘上数字事件
|
|
|
//placeholder修改后,第一次点击键盘触发blur后onClick不触发,原因未知,改为onMouseup可触发
|
|
@@ -64,11 +65,30 @@ class NumberDrop extends Component{
|
|
|
}
|
|
|
|
|
|
handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
|
|
|
+ //BMI相关数据上传
|
|
|
+ this.emitBMIData(text);
|
|
|
+ }
|
|
|
+ emitBMIData(text){
|
|
|
+ //手动修改BMI相关值时数据上传
|
|
|
+ const {setBMIParam,formulaCode,setBMI} = this.props;
|
|
|
+ if(formulaCode==="BMI_RES"){
|
|
|
+ setBMI&&setBMI(text);
|
|
|
+ }
|
|
|
+ if(text!==0&&(formulaCode==="BMI_SG"||formulaCode==="BMI_TZ")){
|
|
|
+ const map={
|
|
|
+ BMI_SG:'tall',
|
|
|
+ BMI_TZ:'weight'
|
|
|
+ };
|
|
|
+ setTimeout(function(){
|
|
|
+ setBMIParam&&setBMIParam(map[formulaCode],text);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
beyondArea(){
|
|
|
const {handleSelect,ikey,suffix,prefix,mainSaveText} = this.props;
|
|
|
Notify.info("输入数值不符合规范,请重新输入!");
|
|
|
handleSelect&&handleSelect({ikey,text:'',suffix,prefix,mainSaveText});
|
|
|
+ this.emitBMIData('');
|
|
|
this.setState({
|
|
|
placeholder:this.props.placeholder,
|
|
|
hasSelect:false
|
|
@@ -165,6 +185,7 @@ class NumberDrop extends Component{
|
|
|
let text = val===placeholder?'':val;
|
|
|
//e.target.innerText = ''; //避免出现重复输入值
|
|
|
handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
|
|
|
+ this.emitBMIData(text);
|
|
|
}
|
|
|
handleSpanInp(e){ //数字框输入事件
|
|
|
e.stopPropagation();
|
|
@@ -202,16 +223,27 @@ class NumberDrop extends Component{
|
|
|
})
|
|
|
}
|
|
|
componentWillReceiveProps(nextProps){
|
|
|
+ //BMI存值
|
|
|
+ const {formulaCode,bmi,suffix,prefix,ikey,handleSelect,mainSaveText,wrBmi} = this.props;
|
|
|
+ if(formulaCode==="BMI_RES"&&nextProps.bmi!==bmi){
|
|
|
+ handleSelect&&handleSelect({ikey,text:nextProps.bmi,suffix,prefix,mainSaveText});
|
|
|
+ }
|
|
|
+ //手动修改BMI时身高体重清空
|
|
|
+ if(wrBmi!==nextProps.wrBmi&&(formulaCode==="BMI_SG"||formulaCode==="BMI_TZ")){
|
|
|
+ handleSelect&&handleSelect({ikey,text:'',suffix,prefix,mainSaveText});
|
|
|
+ }
|
|
|
+
|
|
|
if((nextProps.placeholder == this.props.placeholder)&&(nextProps.value == this.props.value)){
|
|
|
return
|
|
|
}
|
|
|
this.setState({
|
|
|
placeholder:nextProps.placeholder,
|
|
|
value:nextProps.value
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
render(){
|
|
|
- const {prefix,suffix,show,value,handleHide,allClick} = this.props;
|
|
|
+ const {prefix,suffix,show,value,handleHide,allClick,bmi,formulaCode} = this.props;
|
|
|
+ const val = formulaCode==="BMI_RES"?(+bmi===Infinity||isNaN(bmi)?'':bmi):value;
|
|
|
const {placeholder,hasSelect} = this.state;
|
|
|
return <div className={this.getClasses()}
|
|
|
style={{position:'relative'}}
|
|
@@ -226,9 +258,10 @@ class NumberDrop extends Component{
|
|
|
onBlur={this.numInpBlur}
|
|
|
onInput={this.handleSpanInp}
|
|
|
className={this.getSpanClass()}
|
|
|
- > {value||placeholder}</span>
|
|
|
+ > {val||placeholder}</span>
|
|
|
<span>{suffix}</span>
|
|
|
<NumberPan handleSelect={this.select.bind(this)}
|
|
|
+ noString={formulaCode?true:false}
|
|
|
onClose={handleHide}
|
|
|
show={show}
|
|
|
toClear={!hasSelect}/>
|