소스 검색

数字合理值判断,/~未处理

zhouna 6 년 전
부모
커밋
a7604cf05e
2개의 변경된 파일10개의 추가작업 그리고 10개의 파일을 삭제
  1. 9 9
      src/components/NumberDrop/index.jsx
  2. 1 1
      src/utils/tools.js

+ 9 - 9
src/components/NumberDrop/index.jsx

@@ -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(text!=''&&!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(text!=''&&!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&&txt!=''&&!isNaN(+txt)&&(min>+txt||max<+txt)){
+    if(txt!=''&&(isNaN(+txt)||(max!=undefined&&(min>+txt||max<+txt)))){
       this.beyondArea();
       return;
     }
@@ -162,7 +162,7 @@ class NumberDrop extends Component{
     const {handleHide} = this.props;
     handleHide&&handleHide();
   }
-  handleKeyDowm(e){
+  /*handleKeyDowm(e){
     handleEnter();
     //只能输入数字
     const key = e.key;
@@ -172,7 +172,7 @@ class NumberDrop extends Component{
       e.preventDefault();
       return false;
     }
-  }
+  }*/
   getClasses(){         //整个标签是否有值的状态
     const {hideTag,placeholder,value} = this.props;
     const $span = this.$span.current;
@@ -242,7 +242,7 @@ class NumberDrop extends Component{
             onBlur={this.numInpBlur}
             onInput={this.handleSpanInp}
             className={this.getSpanClass()}
-            onkeydown={this.handleKeyDowm}>&nbsp;{value||placeholder}</span>
+            >&nbsp;{value||placeholder}</span>
       <span ref = {this.$suf}>&nbsp;{suffix}</span>
       <NumberPan handleSelect={(text)=>this.select(text)}
                  onClose={handleHide}

+ 1 - 1
src/utils/tools.js

@@ -587,7 +587,7 @@ function trimDots(str){
 //标签间连续标点只保留一个,保留前面一个
 function formatContinueDots(data){
   let arr=data.filter((it,i)=>{
-    if(i==0||it.name&&(it.name.match(config.punctuationReg)||data[i-1].name.match(config.punctuationReg))){
+    if(i==0||(it.name&&(it.name.match(config.punctuationReg))||(data[i-1].name&&data[i-1].name.match(config.punctuationReg)))){
       return it;
     }
   });