Browse Source

BMI自动填回读处理

zhouna 5 năm trước cách đây
mục cha
commit
f6f66cb891
1 tập tin đã thay đổi với 18 bổ sung0 xóa
  1. 18 0
      src/components/MultSpread/index.jsx

+ 18 - 0
src/components/MultSpread/index.jsx

@@ -42,6 +42,7 @@ class MultSpread extends Component{
     this.setBMIParam = this.setBMIParam.bind(this);
     this.setBMI = this.setBMI.bind(this);
     this.isBMIUseable = this.isBMIUseable.bind(this);
+    this.setBMIstate = this.setBMIstate.bind(this);
   }
   getClass(){
     const {saveText,ikey,showAdd} = this.props;
@@ -113,6 +114,22 @@ class MultSpread extends Component{
       weight:0
     });
   }
+  setBMIstate(item){
+    //回读时bmi相关state赋值
+    const map={
+      BMI_SG:'tall',
+      BMI_TZ:'weight',
+      BMI_RES:'bmi',
+    };
+    const st = this.state;
+    const key = map[item.formulaCode];
+    //回读BMI相关项有值时,state赋值
+    if(key&&st[key]!==item.value){
+      this.setState({
+        [key]:item.value
+      });
+    }
+  }
   getLabels(){
     const {data,ikey,showArr,copyId,selecteds,boxMark} = this.props;
     const {wrBmi,bmi} = this.state;
@@ -169,6 +186,7 @@ class MultSpread extends Component{
         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;
+          this.setBMIstate(it);
           return <NumberDrop prefix={it.labelPrefix}
                              suffix={it.labelSuffix}
                              placeholder={it.name}