|
@@ -39,7 +39,7 @@ class NumberDrop extends Component{
|
|
|
this.handleNumFocus = this.handleNumFocus.bind(this);
|
|
|
this.handleBlur = this.handleBlur.bind(this);
|
|
|
this.changeToEdit = this.changeToEdit.bind(this);
|
|
|
- this.handleKeyDowm = this.handleKeyDowm.bind(this);
|
|
|
+ //this.handleKeyDowm = this.handleKeyDowm.bind(this);
|
|
|
this.beyondArea = this.beyondArea.bind(this);
|
|
|
}
|
|
|
select(text){ //选中键盘上数字事件
|
|
@@ -54,14 +54,14 @@ class NumberDrop extends Component{
|
|
|
}else{
|
|
|
//console.log(text,isNaN(+text),max<+text)
|
|
|
if(needCompare){
|
|
|
- if(!isNaN(+text)&&max<+text){ //数值过大
|
|
|
+ if(text!=''&&(isNaN(+text)||max<+text)){ //数值过大
|
|
|
this.beyondArea();
|
|
|
return;
|
|
|
}
|
|
|
const that = this;
|
|
|
- timer = setTimeout(function(){
|
|
|
+ timer = setTimeout(function(){ //数值过小
|
|
|
clearTimeout(that.state.sltTimer);
|
|
|
- if(!that.props.show&&!isNaN(+text)&&min>+text){
|
|
|
+ if(text!=''&&(isNaN(+text)||min>+text)){
|
|
|
that.beyondArea();
|
|
|
return;
|
|
|
}
|
|
@@ -77,7 +77,7 @@ class NumberDrop extends Component{
|
|
|
}
|
|
|
beyondArea(){
|
|
|
const {handleSelect,ikey,suffix,prefix,mainSaveText} = this.props;
|
|
|
- Notify.info("输入数值不在合理值范围内,请重新输入!");
|
|
|
+ Notify.info("输入数值不符合规范,请重新输入!");
|
|
|
handleSelect&&handleSelect({ikey,text:'',suffix,prefix,mainSaveText});
|
|
|
this.setState({
|
|
|
placeholder:this.props.placeholder,
|
|
@@ -140,7 +140,7 @@ class NumberDrop extends Component{
|
|
|
}
|
|
|
//输入超出合理范围提示且清空
|
|
|
const txt = e.target.innerText.replace(/^\s*/,'');
|
|
|
- if(max!=undefined&&!isNaN(+txt)&&(min>+txt||max<+txt)){
|
|
|
+ if(txt!=''&&(isNaN(+txt)||(max!=undefined&&(min>+txt||max<+txt)))){
|
|
|
this.beyondArea();
|
|
|
return;
|
|
|
}
|
|
@@ -151,24 +151,18 @@ class NumberDrop extends Component{
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- /*this.setState({
|
|
|
- hasSelect:false
|
|
|
- });*/
|
|
|
const val = e.target.innerText.replace(/^\s*/,'');
|
|
|
const {placeholder} = this.state;
|
|
|
let text = val===placeholder?'':val.replace(/[\u4e00-\u9fa5]/g,'');
|
|
|
- e.target.innerText = ''; //避免出现重复输入值
|
|
|
+ //e.target.innerText = ''; //避免出现重复输入值
|
|
|
handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
|
|
|
}
|
|
|
handleSpanInp(e){ //数字框输入事件
|
|
|
e.stopPropagation();
|
|
|
const {handleHide} = this.props;
|
|
|
- /*this.setState({ //再键盘点击数字要清空
|
|
|
- hasSelect:false
|
|
|
- });*/
|
|
|
handleHide&&handleHide();
|
|
|
}
|
|
|
- handleKeyDowm(e){
|
|
|
+ /*handleKeyDowm(e){
|
|
|
handleEnter();
|
|
|
//只能输入数字
|
|
|
const key = e.key;
|
|
@@ -178,7 +172,7 @@ class NumberDrop extends Component{
|
|
|
e.preventDefault();
|
|
|
return false;
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
getClasses(){ //整个标签是否有值的状态
|
|
|
const {hideTag,placeholder,value} = this.props;
|
|
|
const $span = this.$span.current;
|
|
@@ -248,7 +242,7 @@ class NumberDrop extends Component{
|
|
|
onBlur={this.numInpBlur}
|
|
|
onInput={this.handleSpanInp}
|
|
|
className={this.getSpanClass()}
|
|
|
- onkeydown={this.handleKeyDowm}> {value||placeholder}</span>
|
|
|
+ > {value||placeholder}</span>
|
|
|
<span ref = {this.$suf}> {suffix}</span>
|
|
|
<NumberPan handleSelect={(text)=>this.select(text)}
|
|
|
onClose={handleHide}
|