瀏覽代碼

Squashed commit of the following:

commit f7c7a75edba7282049d51d0f9dae1ff3aeba9f7b
Author: liucf <liucf@zjlantone.com>
Date:   Fri Apr 26 11:42:05 2019 +0800

    解决量表计算时页面更新问题

commit 269d9cfbed90b980935e3f949a2e75246308519e
Author: liucf <liucf@zjlantone.com>
Date:   Fri Apr 26 09:57:50 2019 +0800

    合并远程分支

commit b0d8e931c7d945c53c5454e30e4a0f59e278f48b
Author: liucf <liucf@zjlantone.com>
Date:   Thu Apr 25 20:19:19 2019 +0800

    慢病诊断入口

commit a5cb935038e2e63699d1f2f250322b759635eb82
Author: liucf <liucf@zjlantone.com>
Date:   Thu Apr 25 16:50:03 2019 +0800

    分组小计结果处理

# Conflicts:
#	src/components/AssessResult/ScaleItem/index.jsx
#	src/components/AssessResult/index.less
#	src/components/ChronicInfo/index.jsx
#	src/components/ScaleTable/index.jsx
#	src/containers/ChronicInfo.js
#	src/containers/ScaleTable.js
#	src/store/async-actions/fetchModules.js
liucf 6 年之前
父節點
當前提交
2ab5c558af

+ 5 - 5
src/components/ChronicInfo/index.jsx

@@ -220,7 +220,7 @@ class ChronicInfo extends React.Component{
     
   }
   calcuFormula(it,j, v, i) { //计算公式计算
-    const { calcuFormula, data } = this.props
+    const { calcuFormula, data ,chronicPushItems} = this.props
     let allHasInfo = true
     for (let i = 0; i < it.content.details.length; i++) {
       if(it.content.details[i].controlType == 2) {  //输入框类型的有没有填值
@@ -247,9 +247,9 @@ class ChronicInfo extends React.Component{
         data: it,
         disId: v.id,
         pIndex: j,
-        ppIndex: i,
+        ppIndex: i
       }
-      calcuFormula(param)
+      calcuFormula({param,chronicPushItems})
     } else {  //不是所有值都填过了
       Notify.info('请填写计算公式内容')
     }
@@ -275,7 +275,7 @@ class ChronicInfo extends React.Component{
                           return <p>
                                 <span className={style["listName"]} onClick={this.showTable.bind(this,it.content,v.id,i)}>
                                   {'【'+it.content.name+'】'}
-                                  {formulaResult&&formulaResult[it.content.id]&&formulaResult[it.content.id].pIndex==i?<i>{'结果:'}{formulaResult[it.content.id].calcalculate&&formulaResult[it.content.id].calcalculate.result.text}</i>:''}
+                                  {formulaResult&&formulaResult[it.content.id]&&formulaResult[it.content.id].pIndex==i?<i>{'结果:'}{formulaResult[it.content.id].calcalculate&&formulaResult[it.content.id].calcalculate.result.value +' '+ formulaResult[it.content.id].calcalculate.result.text}</i>:''}
                                   
                                 </span>
                                 {indexs[i]&&indexs[i].includes(j)?<span className={style["addResult"]}>
@@ -459,7 +459,7 @@ class ChronicInfo extends React.Component{
                           <span>
                             {'【'+v.name+'】'}
                             {/*{formulaResult&&formulaResult[v.id]?<i>{'结果:'+formulaResult[v.id].text}</i>:''}*/}
-                            {formulaResult&&formulaResult[v.id]?<i>{'结果:'}{formulaResult[v.id].calcalculate&&formulaResult[v.id].calcalculate.result.text}</i>:''}
+                            {formulaResult&&formulaResult[v.id]?<i>{'结果:'}{formulaResult[v.id].calcalculate&&formulaResult[v.id].calcalculate.result.value+' '+ formulaResult[v.id].calcalculate.result.text}</i>:''}
                           </span>
                           </li>
                         })}

+ 1 - 1
src/components/ChronicInfo/index.less

@@ -209,7 +209,7 @@
       line-height: 24px;
       font-size: 14px;
       // margin-top: 15px;
-      height: 222px;
+      height: 325px;
       overflow-y: auto;
       padding: 10px 0 0 10px;
       li{

+ 35 - 9
src/components/ScaleTable/index.jsx

@@ -4,6 +4,7 @@ import mocks from '../../mock/chronicTable.js'
 import { Radio,CheckBtn ,Notify} from '@commonComp';
  import Information from '../Information';
  import {deepClone} from '@utils/tools.js';
+ import {getFormulaResult} from '@store/async-actions/fetchModules.js';
 /**
 *量表 具体信息页面
 *title:量表标题/scaleName
@@ -18,6 +19,7 @@ class ScaleTable extends React.Component{
       selecteds:{},  //当前页面的选中标识,保存后使用select标识
       valueData:{},
       start:false,   //点击计算
+      scaleResult1:null
     }
   }
   
@@ -146,10 +148,20 @@ class ScaleTable extends React.Component{
       pIndex:parentIndex
     } 
     // 替换表格内容
-    let allDatas = JSON.parse(JSON.stringify(scaleInfo[tableId])) ;
-     allDatas[1].content = JSON.stringify(valueData);
+    // let allDatas = JSON.parse(JSON.stringify(scaleInfo[tableId])) ;
+    //  allDatas[1].content = JSON.stringify(valueData);
     // 计算接口
-    getResult&&getResult({params,allDatas});
+    // getResult&&getResult({params,allDatas});
+
+    // 将计算结果存在state,防止页面跳动问题
+    const that = this;
+    getFormulaResult(params).then((res)=>{
+      if(+res.data.code==0){
+        that.setState({
+          scaleResult1:res.data.data
+        })
+      }
+    })
   }
   componentWillReceiveProps(nextProps){ 
     const {tableId} = this.props;
@@ -167,13 +179,27 @@ class ScaleTable extends React.Component{
         // valueData:scaleInfo[tableId].length?mocks.newData:JSON.parse(scaleInfo[tableId].content)
         valueData:JSON.parse(scaleInfo[tableId][1].content)
       })
+    }  
+  }
+  componentWillUnmount(){
+    // 储存计算结果和选择后的data
+    const {tableId,getResult,parentId,parentIndex,scaleInfo} = this.props; 
+    const {valueData,scaleResult1} = this.state; 
+    // 替换表格内容
+    let allDatas = JSON.parse(JSON.stringify(scaleInfo[tableId])) ;
+     allDatas[1].content = JSON.stringify(valueData);
+    const params = {
+      type:1,
+      data:scaleResult1,
+      id:tableId,
+      pIndex:parentIndex
     }
-    
+    getResult&&getResult({params,allDatas});
   }
   getContent(){ 
-    let {selecteds,valueData,start} = this.state;
+    let {selecteds,valueData,start,scaleResult1} = this.state;
     const {tableId,formulaResult} = this.props;
-    const scaleResult = formulaResult&&formulaResult[tableId]; //量表计算结果
+    const scaleResult = scaleResult1 || formulaResult&&formulaResult[tableId]; //量表计算结果
     // const datas = valueData&&valueData.group?valueData:mocks.newData;
     const datas = valueData&&valueData.group?valueData:'';
     let content =  datas&&datas.group&&datas.group.map((v,i)=>{
@@ -232,12 +258,12 @@ class ScaleTable extends React.Component{
   render(){
     const {title,scaleInfo,tableId,formulaResult} = this.props;
     const data = scaleInfo[tableId];
-    let {selecteds} = this.state;
+    let {selecteds,scaleResult1} = this.state;
     const content = data && data[1].content;//表格内容
     const preContent = data && data[0].content;//表前文字
     const footContent = data && data[2].content; //表后文字
     const datas = content && JSON.parse(content);
-    const scaleResult = formulaResult&&formulaResult[tableId]; //量表计算结果
+    const scaleResult = scaleResult1 || formulaResult&&formulaResult[tableId]; //量表计算结果
     return <div className={style['tableBox']} id="printcontent">
             <div className={style['printShow']}>
               <Information></Information>
@@ -248,7 +274,7 @@ class ScaleTable extends React.Component{
               {this.getContent()}
               {datas&&datas.noCalc==0?<div className={style['total']}>
                     <span>总分:</span>
-                    <span>{scaleResult&&scaleResult.calcalculate.result&&scaleResult.calcalculate.result.value||''}</span>
+                    <span>{scaleResult&&scaleResult.calcalculate.result&&scaleResult.calcalculate.result.value +' '+ scaleResult.calcalculate.result.text||''}</span>
                     <span className={style['totalBtn']} onClick={this.handleFormula.bind(this)}>得分</span>
                   </div>:''}
             </div>

+ 17 - 2
src/containers/ChronicInfo.js

@@ -9,7 +9,8 @@ import { getFormulaResult } from '@store/async-actions/fetchModules'
 
 function mapStateToProps(state){
   return{
-    chronicMagItem: state.diagnosticList.chronicMagItem,
+    chronicMagItem: state.diagnosticList.chronicMagItem,//慢病疾病
+    chronicPushItems: state.pushMessage.chronicPushItems, //慢病右侧推送
     tableList: state.pushMessage.tableList,
     showList: state.pushMessage.showList,
     showHide: state.pushMessage.showHide,
@@ -64,7 +65,21 @@ function mapDispatchToProps(dispatch){
     },
     // 计算公式计算
     calcuFormula(item) {
-      dispatch(getFormulaResult(item))
+      // dispatch(getFormulaResult(item))
+      const {param,chronicPushItems} = item;
+      getFormulaResult(param).then((res)=>{
+        if(+res.data.code==0){
+          const data = chronicPushItems;
+          data[param.ppIndex].details[param.pIndex].content.result =  res.data.data.result;
+          dispatch({
+            type: SET_CHRONIC_PUSHS,
+            data: JSON.parse(JSON.stringify(data))
+          })
+        }else{
+          console.log(res);
+        }
+      })
+
     },
     // 获取量表静态知识
     getInfomation(item){

+ 6 - 1
src/containers/ScaleTable.js

@@ -14,12 +14,17 @@ function mapDispatchToProps (dispatch){
   return {
     getResult(obj){//计算结果
       const {params,allDatas} = obj;
-      dispatch(getFormulaResult(params));
+      // dispatch(getFormulaResult(params));
       dispatch({
         type:SET_SCALE_INFO,
         data:allDatas,
         id:params.id //量表id
       })
+      dispatch({
+        type:SAVE_TABLE_RESULT,
+        id:params.id,  //量表id
+        data:Object.assign({},params.data,{pIndex:params.pIndex})
+      })
     }
   }
 }

+ 11 - 2
src/store/async-actions/fetchModules.js

@@ -266,7 +266,7 @@ export function getIndexData(range){
 }
 
 // 计算接口
-export const getFormulaResult = (item)=>{
+/*export const getFormulaResult = (item)=>{
   // type:1-量表 2-计算公式
   const type = item.type;
   let param = {
@@ -299,6 +299,15 @@ export const getFormulaResult = (item)=>{
       }
     })
   }
+}*/
+export const getFormulaResult = (item)=>{
+  // type:1-量表 2-计算公式
+  const type = item.type;
+  let param = {
+      type:type,
+      data:item.data
+    }
+  return json(api.getFormulaResult,param);
 }
 
 // 自动分发模板
@@ -317,4 +326,4 @@ export function autoFillModules (){
       isEmpty:false
     });
   }
-}
+}