Bladeren bron

计算公式无结果时保存填的值1394

zhouna 6 jaren geleden
bovenliggende
commit
155d6cce21
1 gewijzigde bestanden met toevoegingen van 18 en 13 verwijderingen
  1. 18 13
      src/components/ChronicInfo/index.jsx

+ 18 - 13
src/components/ChronicInfo/index.jsx

@@ -50,7 +50,7 @@ class ChronicInfo extends React.Component{
     this.closeTable = this.closeTable.bind(this);//关闭量表弹窗
     this.close = this.close.bind(this); //关闭量表列表
     this.showFormula = this.showFormula.bind(this); //打开计算公式
-    this.closeFormula = this.closeFormula.bind(this); //关闭计算公式
+    //this.closeFormula = this.closeFormula.bind(this); //关闭计算公式
     this.handleAddAssessItem = this.handleAddAssessItem.bind(this);   //加入病例记录
     this.onPrint = this.onPrint.bind(this);
     this.handleForRadio = this.handleForRadio.bind(this);
@@ -147,17 +147,22 @@ class ChronicInfo extends React.Component{
       optionId:null  //关闭可能结果
     })
   }
-  closeFormula(){
-    if(this.state.isCalculated){
-      this.setState({
-        formulaId:null,
-      });
-    }else{
-      this.setState({
-        formulaId:null,
-        calcuValues:deepClone(this.props.calcuValues)
-      });
+  closeFormula(it){
+    const {formulaId,isCalculated} =this.state;
+    if(!isCalculated){
+      //没有计算结果时,保存输入的值
+      const {calcuResult,calcuValues} = this.props;
+      const cres = calcuResult&&calcuResult[formulaId]||it.content.result;
+      const result = cres&&cres[1]&&cres[1].text;
+      if(result){
+        this.setState({
+          calcuValues:deepClone(calcuValues)
+        });
+      }
     }
+    this.setState({
+      formulaId:null,
+    });
   }
   handleAddAssessItem(v,pIndex,i){
     const {addAssessItem} = this.props;
@@ -327,8 +332,8 @@ class ChronicInfo extends React.Component{
                                 icon={allTableIcon}
                                 confirmText='关闭'
                                 show={formulaId&&formulaId==v.id?true:false}
-                                close={this.closeFormula}
-                                confirm={this.closeFormula}
+                                close={this.closeFormula.bind(this,it)}
+                                confirm={this.closeFormula.bind(this,it)}
                                 footer="true">
                                 <table>
                                 {details.map((item,idd)=>{