Browse Source

数字组件合理值范围bug修改

zhouna 6 years ago
parent
commit
264ebfb352

+ 2 - 2
src/components/MultSpread/index.jsx

@@ -98,8 +98,8 @@ class MultSpread extends Component{
                             id={it.id}
                             ikey={inx} hideTag={true}></InlineTag>;
         case +it.controlType===7:
-          const min = it.minValue!=null&&it.minValue!=undefined?it.minValue-1:undefined;
-          const max = it.maxValue!=null&&it.maxValue!=undefined?+it.maxValue+1:undefined;
+          const min = it.minValue;//!=null&&it.minValue!=undefined?it.minValue-1:undefined;
+          const max = it.maxValue;//!=null&&it.maxValue!=undefined?+it.maxValue+1:undefined;
           return <NumberDrop prefix={it.labelPrefix}
                              suffix={it.labelSuffix}
                              placeholder={it.name}

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

@@ -56,7 +56,7 @@ class NumberDrop extends Component{
         const that = this;
         const isFine = this.validSymbols(text,min,max);      //有~或/时是否合理
         const hasSymbol = /[\/|\~]/g.test(text);           //是否有~或/
-        const singleFine = !isNaN(+text)&&min<text&&text<max;   //无~或/时是否合理
+        const singleFine = !isNaN(+text)&&parseFloat(min)<=parseFloat(text)&&parseFloat(text)<=parseFloat(max);   //无~或/时是否合理
         timer = setTimeout(function(){
           clearTimeout(that.state.sltTimer);
           if(text!=''&&(!hasSymbol&&!singleFine)||(hasSymbol&&!isFine)){
@@ -139,7 +139,7 @@ class NumberDrop extends Component{
     if(index1!=-1&&index1==txt.lastIndexOf('~')&&index1!=txt.length-1){   //有且只有一个~,且不在最后
       arr1 = txt.split('~');
       //~的范围在合理范围内为合理值
-      if(!isNaN(+arr1[0])&&!isNaN(+arr1[1])&&((!needCompare)||(needCompare&&min<arr1[0]&&arr1[0]<max&&min<arr1[1]&&arr1[1]<max))){
+      if(!isNaN(+arr1[0])&&!isNaN(+arr1[1])&&((!needCompare)||(needCompare&&parseFloat(min)<=parseFloat(arr1[0])&&parseFloat(arr1[0])<=parseFloat(max)&&parseFloat(min)<=parseFloat(arr1[1])&&parseFloat(arr1[1])<=parseFloat(max)))){
         return true
       }
       return false;
@@ -147,7 +147,7 @@ class NumberDrop extends Component{
     if(index2!=-1&&index2==txt.lastIndexOf('/')&&index2!=txt.length-1){   //有且只有一个~,且不在最后
       arr2 = txt.split('/');
       // /两边的数字分别在合理范围内为合理值
-      if(!isNaN(+arr2[0])&&!isNaN(+arr2[1])&&((!needCompare)||(needCompare&&min<arr2[0]&&arr2[0]<max&&min<arr2[1]&&arr2[1]<max))){
+      if(!isNaN(+arr2[0])&&!isNaN(+arr2[1])&&((!needCompare)||(needCompare&&parseFloat(min)<=parseFloat(arr2[0])&&parseFloat(arr2[0])<=parseFloat(max)&&parseFloat(min)<=parseFloat(arr2[1])&&parseFloat(arr2[1])<=parseFloat(max)))){
         return true
       }
       return false;
@@ -166,7 +166,7 @@ class NumberDrop extends Component{
       const txt = e.target.innerText.trim();
       const isFine = this.validSymbols(txt,min,max);      //有~或/时是否合理
       const hasSymbol = /[\/|\~]/g.test(txt);           //是否有~或/
-      const singleFine = (!isNaN(+txt)&&!needCompare)||(!isNaN(+txt)&&needCompare&&min<txt&&txt<max);   //无~或/时是否合理
+      const singleFine = (!isNaN(+txt)&&!needCompare)||(!isNaN(+txt)&&needCompare&&parseFloat(min)<=parseFloat(txt)&&parseFloat(txt)<=parseFloat(max));   //无~或/时是否合理
       if(txt!=''&&(!hasSymbol&&!singleFine)||(hasSymbol&&!isFine)){
         this.beyondArea();
         return;

+ 2 - 2
src/containers/eleType.js

@@ -72,8 +72,8 @@ export function singleRadio(params){
                         id={data.id}
                         ikey={showInx}></InlineTag>;
     case 7:
-      const min = data.minValue!=null&&data.minValue!=undefined?data.minValue-1:undefined;
-      const max = data.maxValue!=null&&data.maxValue!=undefined?+data.maxValue+1:undefined;
+      const min = data.minValue;//!=null&&data.minValue!=undefined?data.minValue-1:undefined;
+      const max = data.maxValue;//!=null&&data.maxValue!=undefined?+data.maxValue+1:undefined;
       return <NumberDrop prefix={data.labelPrefix}
                          suffix={data.labelSuffix}
                          min={min}