Ver código fonte

量表加入病例按钮修改到弹窗中

zhouna 6 anos atrás
pai
commit
2884280640

+ 1 - 1
src/common/components/Footer/index.jsx

@@ -14,7 +14,7 @@ const Footer = (props) => {
   const {footText,print,handlePrint,handleConfirm} = props;
   return <div className={style['footer']}>
     {print?<span className={style['print']} onClick={handlePrint}><img src={printIcon} alt=""/>打印</span>:''}
-        <span className={style['okBtn']} onClick={handleConfirm}>{footText}</span>
+    {handleConfirm?<span className={style['okBtn']} onClick={handleConfirm}>{footText}</span>:''}
   </div>;
 }
 

+ 2 - 1
src/common/components/Footer/index.less

@@ -18,7 +18,8 @@
       }
       .okBtn{
         .btnCom;
-        width: 80px;
+        /*width: 80px;*/
+        padding: 0 10px;
         height: 34px;
         line-height: 32px;
         border: 1px solid #3B9ED0;

+ 21 - 7
src/components/AssessResult/ScaleItem/index.jsx

@@ -65,7 +65,7 @@ class ScaleItem extends Component {
   handleShowScale(item){
     const {showScaleFn,closeAssess} = this.props;
     //closeAssess&&closeAssess();    //关闭评估弹窗
-    showScaleFn&&showScaleFn(item);
+    showScaleFn&&showScaleFn(item,true);
   }
   handleRadio(item,parent){
     let {result} = this.props;
@@ -171,7 +171,7 @@ class ScaleItem extends Component {
       let it=its;
       if(indexs[i]&&indexs[i].includes(j)){
         if(its.type==1){     //量表
-          let scaleRes=formulaResult&&formulaResult[it.content.id]&&formulaResult[it.content.id].calcalculate;
+          let scaleRes=formulaResult&&formulaResult[it.content.conceptId]&&formulaResult[it.content.conceptId].calcalculate;
           temp =<span className={style['scale']}
                       onClick={()=>this.handleShowScale(it.content)}>
                         {scaleRes&&scaleRes.result?(' 【'+it.content.name+'】 结果:'+scaleRes.result.value+" "+(scaleRes.result.text||'')):'【'+it.content.name+'】'}
@@ -269,7 +269,7 @@ class ScaleItem extends Component {
                     </MiniToast>
                   </div>;
         }
-        const passId = item.details[j].type==1?item.details[j].content.id:undefined;
+        const passId = item.details[j].type==1?item.details[j].content.conceptId:undefined;
         const li = disabled?<li>
             <span>{item.name}:</span>
             <div className={style['row']}>{temp}</div>
@@ -291,10 +291,24 @@ class ScaleItem extends Component {
       return this.getDetailItems(it,i);
     });
   }
+  getScaleContent(data){
+    const item = data&&data.find((it)=>{
+      return it.type==1;
+    });
+    if(!item){
+      return null;
+    }
+    const content = JSON.parse(item.content||null);
+    return {id:item.conceptId,content,name:content.scaleName};
+  }
   getScales(){
     const {scaleItems,disabled,formulaResult} = this.props;
-    let li='',temp='';
-    const arr = scaleItems&&scaleItems.map((it,i)=>{
+    let li='',temp='',arr=[],it={};
+    if(!scaleItems){
+      return '';
+    }
+    for( let i in scaleItems){
+      it = this.getScaleContent(scaleItems[i]);
       if(!it) return '';
       let scaleRes=formulaResult&&formulaResult[it.id]&&formulaResult[it.id].calcalculate;
       temp =<span className={style['scale']} onClick={()=>this.handleShowScale(it)}>
@@ -306,12 +320,12 @@ class ScaleItem extends Component {
       </li>:<li>
         <span>相关量表:</span>
         <div className={style['row']}>{temp}</div>
-        <div className={style["recommend"]} onClick={()=>this.props.handleRemove(true,i,it.id)}>
+        <div className={style["recommend"]} onClick={()=>this.props.handleRemove(true,it.id)}>
           <img className={style["deleteIcon"]} src={deleteIcon} />
         </div>
       </li>;
       return li;
-    });
+    };
     return arr;
   }
   handleInput(e){

+ 1 - 1
src/components/AssessResult/index.jsx

@@ -55,7 +55,7 @@ class AssessResult extends Component {
       ids.splice(idIndex,1);
     }
     if(isList){         //删除全部量表中的项目
-      const items = [...this.state.wholeScaleItems];
+      const items = Object.assign({},this.state.wholeScaleItems);
       items[i]=null;
       this.setState({
         wholeScaleItems: items,

+ 20 - 42
src/components/ChronicInfo/index.jsx

@@ -43,7 +43,8 @@ class ChronicInfo extends React.Component{
       isCalculated:false,     //是否刚计算过,关闭时值与结果对应
       calcuValues:deepClone(props.calcuValues),       //计算公式填的值
       hasEnterImg: false, //是否移入info
-      currentIndex: -1 //当前index
+      currentIndex: -1, //当前index
+      scaleParam:{},    //加入病例需要的参数
     };
 
     this.$content = React.createRef();
@@ -53,14 +54,11 @@ class ChronicInfo extends React.Component{
     this.closeOption = this.closeOption.bind(this);
     this.showTable = this.showTable.bind(this);//显示量表弹窗
     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.handleAddAssessItem = this.handleAddAssessItem.bind(this);   //加入病例记录
     this.onPrint = this.onPrint.bind(this);
     this.handleForRadio = this.handleForRadio.bind(this);
     this.handleSaveCalcu = this.handleSaveCalcu.bind(this);     //保存评估修改的计算和可能结果
-    //this.getAddBtnState = this.getAddBtnState.bind(this);
     this.slideToggle = this.slideToggle.bind(this);
   }
 
@@ -74,22 +72,6 @@ class ChronicInfo extends React.Component{
       operaSupport: false,
     });
   }
-  
-  showTableList(name){//量表按钮
-    const {getTableList} = this.props;
-    if(name){
-      getTableList(name);
-    }
-  }
-  close(){//关闭量表列表
-    const {hideList} = this.props;
-    hideList&&hideList({name:'showList',value:false});
-  }
-  handleListClick(item){//量表列表单项点击
-    this.showTable(item,null);
-    //this.close()
-  }
-
   showInfo(item){
     // 静态知识显示在提示信息里(4-18)
     const {getInfomation} = this.props;
@@ -127,7 +109,7 @@ class ChronicInfo extends React.Component{
       });
     }
   }
-  showTable(it){
+  showTable(it,v,i,j){
     const {scaleInfo} = this.props;
     // 密西根糖尿病周围神经病评分(MDNS), id:40744
     const item = {
@@ -143,11 +125,19 @@ class ChronicInfo extends React.Component{
 
     this.setState({
       formulaId:null, //关闭计算公式和可能结果弹窗
-      optionId:null
+      optionId:null,
+      scaleParam:{
+        v,i,j
+      }
     })
   }
   closeTable(){
+    const {scaleParam} = this.state;
+    const {showHide} = this.props;
     this.props.hideList({name:'showTable',value:false});
+    if(!showHide.isPop){
+      this.handleAddAssessItem(scaleParam.v,scaleParam.i,scaleParam.j);
+    }
   }
   showFormula(id){//计算公式
     this.setState({
@@ -173,7 +163,11 @@ class ChronicInfo extends React.Component{
     });
   }
   handleAddAssessItem(v,pIndex,i){
-    const {addAssessItem} = this.props;
+    const {addAssessItem,showHide,addScaleItems,scaleInfo} = this.props;
+    if(!v){
+      addScaleItems(scaleInfo[showHide.id],showHide.id);
+      return ;
+    }
     addAssessItem(v,pIndex,i);
   }
   addFormula(it,v,pIndex,i){
@@ -368,12 +362,9 @@ class ChronicInfo extends React.Component{
                         if(it.type==1){
                           return <p>
                                 <span className={style["listName"]}>
-                                  <i onClick={this.showTable.bind(this,it.content,v.conceptId,i)}>{'【'+it.content.name+'】'}</i>
+                                  <i onClick={this.showTable.bind(this,it.content,v,i,j)}>{'【'+it.content.name+'】'}</i>
                                   {formulaResult&&formulaResult[it.content.conceptId]?<i>{'结果:'}{formulaResult[it.content.conceptId].calcalculate&&formulaResult[it.content.conceptId].calcalculate.result.value +' '+ formulaResult[it.content.conceptId].calcalculate.result.text}</i>:''}
                                 </span>
-                                {/*{
-                                  this.getAddBtnState(formulaResult&&formulaResult[it.content.conceptId],v,i,j)
-                                }*/}
                               </p>
                         }else if(it.type==2){
                           const cres = calcuResult&&calcuResult[v.conceptId]||it.content.result;
@@ -385,9 +376,6 @@ class ChronicInfo extends React.Component{
                               <i className={style["blue"]} onClick={this.showFormula.bind(this,v.conceptId)}>{result?result:'请选择'}</i>
                               <img src={level1} />
                             </span>
-                            {/*{
-                              this.getAddBtnState(result,v,i,j)
-                            }*/}
                             {formulaId&&formulaId==v.conceptId&&<MiniToast title={it.content.name}
                                 icon={allTableIcon}
                                 confirmText='加入病例记录'
@@ -452,12 +440,6 @@ class ChronicInfo extends React.Component{
                               <i onClick={this.showOption.bind(this,v.conceptId)} className={style["blue"]}>{possible[v.conceptId]?possible[v.conceptId]:'请选择'}</i>
                               <img src={level1} />
                             </span>
-                            {/*{
-                              this.getAddBtnState(possible[v.conceptId],v,i,j)
-                            }*/}
-                            {
-                              console.log(this.props)
-                            }
                             <MiniToast title='结果选择'
                                 icon={checkIcon}
                                 confirmText='加入病例记录'
@@ -504,11 +486,11 @@ class ChronicInfo extends React.Component{
     toggleSlide&&toggleSlide(!slideUp);
   }
   render(){
+    const {chronicMagItem,chronicDesease,showHide,slideUp} = this.props;
     const scaleFooter = <Footer print={true}
-                                footText="确定"
+                                footText={showHide.isPop?"确定":"加入病例记录"}
                                 handlePrint={this.onPrint}
                                 handleConfirm={this.closeTable}/>;
-    const {chronicMagItem,tableList,chronicDesease,formulaResult,showHide,slideUp} = this.props;
     return <div className={style["tips"]} style={{marginBottom:'15px'}}>
               <div className={`${style["tips-title"]} ${style["chronic"]}`}>
                 <div className={style["tips-name"]}>
@@ -519,10 +501,6 @@ class ChronicInfo extends React.Component{
                 <div className={style['toggle-btn']}>
                   <img src={slideUp?down:up} alt="展开/收起" onClick={this.slideToggle}/>
                 </div>
-                {/*<div className={style["tips-btn"]} style={{display:chronicMagItem&&chronicMagItem.name||chronicDesease&&chronicDesease.name?'block':'none'}}>
-                  <span className={style["tipsDetails"]} onClick={() => this.showTableList(chronicDesease&&chronicDesease.name||chronicMagItem&&chronicMagItem.name)}>量表
-                  </span>
-                </div>*/}
               </div>
               <div className={style["content"]} ref={this.$content}>
                   {this.getDetail()}

+ 10 - 2
src/components/ScaleSearch/index.jsx

@@ -24,10 +24,18 @@ class ScaleSearch extends Component {
     }
     return '';
   }
+  showScale(item){
+    const {scaleInfo,getScale,showScaleFn} = this.props;
+    if(scaleInfo&&scaleInfo[item.id]){
+      showScaleFn&&showScaleFn(item);
+    }else{
+      getScale(item);
+    }
+  }
   getSearchList() {
-    const { searchResult,getScale } = this.props;
+    const { searchResult } = this.props;
     return searchResult && searchResult.map((item) => {
-      return <li key={item.conceptId} onClick={()=>getScale({id:item.conceptId,name:item.name})}>
+      return <li key={item.conceptId} onClick={this.showScale.bind(this,{id:item.conceptId,name:item.name})}>
         <span className={style['scale-name']}>{item.name}</span>
         {this.getResult(item.conceptId)}
         <button>查看</button>

+ 2 - 1
src/containers/AssessResult.js

@@ -100,11 +100,12 @@ function mapDispatchToProps(dispatch) {
         data:deepClone(data)
       })
     },
-    showScaleFn(item){
+    showScaleFn(item,isPop){
       dispatch({
         type:SHOW_TABLE_LIST,
         name:'showTable',
         value:true,
+        isPop,
         item:Object.assign({},item)
       });
     },

+ 2 - 2
src/containers/ChronicInfo.js

@@ -69,11 +69,11 @@ function mapDispatchToProps(dispatch){
         id:it.type==1?it.content.id:undefined,      //只有量表需要记录id,去重用
       })
     },
-    addScaleItems(obj,i){
+    addScaleItems(obj,id){
       dispatch({
         type:ADD_WHOLE_SCALE_ITEMS,
         data:obj,
-        index:i
+        id
       })
     },
     //保存管理评估

+ 14 - 2
src/containers/ScaleSearchContainer.js

@@ -3,11 +3,14 @@ import { connect } from 'react-redux';
 import { getSearchList } from '@store/async-actions/ScaleSearch';
 import ScaleSearch from '@components/ScaleSearch';
 import {getScaleInfo} from '../store/async-actions/pushMessage';
+import {SHOW_TABLE_LIST} from '@store/types/pushMessage';
 
 function mapStateToProps(state) {
+    const {pushMessage} = state;
     return{
         searchResult: state.scaleSearch.searchResult,
-        formulaResult: state.pushMessage.formulaResult,//Á¿±íÄÚÈÝ
+        formulaResult: pushMessage.formulaResult,//��������
+        scaleInfo: pushMessage.scaleInfo,//�表内容
     }
 }
 
@@ -18,7 +21,16 @@ function mapDispatchToProps(dispatch) {
         },
         getScale(name) {
             dispatch(getScaleInfo(name))
-        }
+        },
+        showScaleFn(item,isPop){
+          dispatch({
+            type:SHOW_TABLE_LIST,
+            name:'showTable',
+            value:true,
+            isPop,
+            item:Object.assign({},item)
+          });
+        },
     }
 }
 const ScaleSearchContainer = connect(

+ 4 - 4
src/store/reducers/assessResult.js

@@ -17,7 +17,7 @@ const init = {
   },    //可能结果
   calcuResult:{},       //计算公式结果
   calcuValues:{},       //计算公式填的值
-  wholeScaleItems:[],   //全部量表中添加的整体评估项
+  wholeScaleItems:{},   //全部量表中添加的整体评估项
   addedScaleIds:[]
 };
 export default (state=init,action)=>{
@@ -60,7 +60,7 @@ export default (state=init,action)=>{
       res.wholeIndexs = action.wholeAssessItems||{};
       res.addedScaleIds = action.addedScaleIds||[];
       res.wholeResults = action.wholeResults||{};
-      res.wholeScaleItems = action.wholeScaleItems||[];
+      res.wholeScaleItems = action.wholeScaleItems||{};
       res.wholeAssessText = action.wholeAssessText||{};
       res.chooseSelecteds = action.chooseSelecteds||{};
       res.calcuResult = action.calcuResult||{};
@@ -74,8 +74,8 @@ export default (state=init,action)=>{
       res.update1 = Math.random();   //对象更新,与其他字段名不同因为绑定在pushItems,避免不必要的渲染
       return res;
     case ADD_WHOLE_SCALE_ITEMS:
-      res.wholeScaleItems[action.index] = action.data;
-      res.addedScaleIds.push(action.data.id);
+      res.wholeScaleItems[action.id] = action.data;
+      res.addedScaleIds.push(action.id);
       res.update1 = Math.random();
       return res;
     case REMOVE_ASSESS_ITEMS:

+ 1 - 1
src/store/reducers/pushMessage.js

@@ -65,7 +65,7 @@ export default function(state = initState, action) {
       res.tableList = action.data;
       return res;
     case SHOW_TABLE_LIST://显示、隐藏量表列表
-      res.showHide = Object.assign({},res.showHide,{[action.name]:action.value},action.item);
+      res.showHide = Object.assign({},res.showHide,{[action.name]:action.value,isPop:action.isPop},action.item);
       return res;
     case SET_CHRONIC_PUSHS:
       res.chronicPushItems = action.data;