Browse Source

评估保存框架

zhouna 6 năm trước cách đây
mục cha
commit
c51fd76d25

+ 10 - 9
src/components/AssessResult/ChartItem/index.jsx

@@ -71,7 +71,7 @@ class ChartItem extends Component {
     }
   }
   rangChange(type,index){
-    const {initFn} = this.props;
+    const {initFn,handleChange} = this.props;
     const times = this.getXAxisArr(type);
     const range = [times[0],times[times.length-1]];
     const temp=this.state.timeDismen;
@@ -79,6 +79,7 @@ class ChartItem extends Component {
       timeDismen:Object.assign(temp,{[index]:type})
     });
     initFn&&initFn({range,rangeType:type,index});
+    handleChange(Object.assign(temp,{[index]:type}));
   }
   getContainers(){
     const timeTypes = this.state.timeDismen;
@@ -113,7 +114,7 @@ class Chart extends Component{
     super(props);
     this.state={
       chartObj:null,
-      timeRange:'year',
+      //timeRange:'year',
       week:props.getXAxisArr('week'),
       month:props.getXAxisArr('month'),
       sixMonth:props.getXAxisArr('sixMonth'),
@@ -208,9 +209,9 @@ class Chart extends Component{
   }
   timeSwitch(type){
     const {handleRangeChange,index} = this.props;
-    this.setState({
+    /*this.setState({
       timeRange:type
-    });
+    });*/
     handleRangeChange&&handleRangeChange(type,index);
     //
     const that=this;
@@ -223,13 +224,13 @@ class Chart extends Component{
     this.drawChart();
   }
   render(){
-    const {timeRange} = this.state;
+    const {type} = this.props;
     return <div className={style['cont']}>
               <div className={style['time-range']}>
-                <span className={timeRange=='year'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("year")}>近一年</span>
-                <span className={timeRange=='sixMonth'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("sixMonth")}>近六个月</span>
-                <span className={timeRange=='month'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("month")}>近一个月</span>
-                <span className={timeRange=='week'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("week")}>近一周</span>
+                <span className={type=='year'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("year")}>近一年</span>
+                <span className={type=='sixMonth'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("sixMonth")}>近六个月</span>
+                <span className={type=='month'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("month")}>近一个月</span>
+                <span className={type=='week'?style['range']+" "+style['on']:style['range']} onClick={()=>this.timeSwitch("week")}>近一周</span>
               </div>
               <div className={style["chart-box"]} id={'chart'+this.props.index}></div>
             </div>;

+ 9 - 4
src/components/AssessResult/index.jsx

@@ -23,13 +23,18 @@ class AssessResult extends Component {
   }
   handleChooseChange(i,selects){
     const {chooseSelecteds} = this.state;
+    const {handleChange} = this.props;
     this.setState({
       chooseSelecteds: Object.assign(chooseSelecteds,{[i]:selects})
     });
-    console.log(this.state.chooseSelecteds)
+    /*for(let x in selects){
+      handleChange(x,selects[x]);
+    }*/
+    handleChange(i,selects);
   }
-  handleChartChange(){
-
+  handleChartChange(i,selects){
+    const {handleChange}=this.props;
+    handleChange(i,selects);
   }
   handoutTypes(item,i){
     const {getIndexData,indexData,timeTypes} =this.props;
@@ -43,7 +48,7 @@ class AssessResult extends Component {
       case 1:     //数据来源于大数据
         return <ChooseItem title={name} data={list} handleChange={this.handleChooseChange.bind(this,i)}></ChooseItem>;
       case 10:    //数据来源于后台
-        return <ChartItem title={name} data={chartData||{}} timeTypes={timeTypes} initFn={getIndexData} handleChange={this.handleChartChange}></ChartItem>;
+        return <ChartItem title={name} data={chartData||{}} timeTypes={timeTypes} initFn={getIndexData} handleChange={this.handleChartChange.bind(this,i)}></ChartItem>;
       default:
         return '';
     }

+ 19 - 7
src/components/ChronicInfo/index.jsx

@@ -33,7 +33,8 @@ class ChronicInfo extends React.Component{
       showAssess:false,      //评估弹窗
       infoId:null,  //静态知识
       formulaId:null, //计算公式
-      optionId:null  //可能结果
+      optionId:null,  //可能结果,
+      assessInfos:{},    //评估内容
     };
     this.showInfo = this.showInfo.bind(this);
     this.closeInfo = this.closeInfo.bind(this);
@@ -45,6 +46,8 @@ class ChronicInfo extends React.Component{
     this.close = this.close.bind(this); //关闭量表列表
     this.showFormula = this.showFormula.bind(this); //打开计算公式
     this.closeFormula = this.closeFormula.bind(this); //关闭计算公式
+    this.addAssessItem = this.addAssessItem.bind(this);   //加入病例记录
+    this.handleAssessChange = this.handleAssessChange.bind(this);
   }
   showTableList(id){//量表
     const {getTableList,questionId} = this.props;
@@ -108,7 +111,17 @@ class ChronicInfo extends React.Component{
       formulaId:null
     })
   }
+  addAssessItem(){    //加入整体评估
 
+  }
+  handleAssessChange(i,infos){     //整体评估操作内容变动
+    console.log(i,infos)
+    let obj = this.state.assessInfos;
+    obj[i]=infos;
+    this.setState({
+      assessInfos:obj
+    })
+  }
   getDetail(){
     const {data} = this.props;
     const {showInfo,showOption,infoId,formulaId,optionId} = this.state;
@@ -133,7 +146,7 @@ class ChronicInfo extends React.Component{
                         if(it.type==1){
                           return <p>
                                 <span className={style["listName"]} onClick={this.showTable.bind(this,it.content)}>{'【'+it.content.name+'】'}</span>
-                                <span className={style["listResult"]}>
+                                <span className={style["listResult"]} onClick={this.addAssessItem}>
                                   <img src={add} />
                                   加入病历记录
                                 </span>
@@ -225,14 +238,13 @@ class ChronicInfo extends React.Component{
                   })
     return list;
   }
-
   render(){
+    const {chronicMagItem,showList,tableList,scaleInfo,data,saveAssessInfos} = this.props;
+    const {showInfo,showOption,showTable,showAssess,assessInfos} = this.state;
     const footer = <div className={style['footer']}>
       <span className={style['print']}><img src={printIcon} alt=""/>打印</span>
-      <span className={style['okBtn']}>确定</span>
+      <span className={style['okBtn']} onClick={()=>saveAssessInfos(assessInfos)}>确定</span>
     </div>;
-    const {chronicMagItem,showList,tableList,scaleInfo,data} = this.props;
-    const {showInfo,showOption,showTable,showAssess} = this.state;
     return <div className={style["tips"]} style={{marginBottom:'15px'}}>
               <div className={`${style["tips-title"]} ${style["chronic"]}`}>
                 <div className={style["tips-name"]}>
@@ -282,7 +294,7 @@ class ChronicInfo extends React.Component{
                       top={20}
                       bottom={20}
                       width={820}>
-                <AssessResult></AssessResult>
+                <AssessResult handleChange={this.handleAssessChange}></AssessResult>
               </ComplexModal>:''}
       </div>
   }

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

@@ -71,6 +71,7 @@
         }
         .listResult{
           float: right;
+          cursor: pointer;
           display: inline-block;
           width: 99px;
           height: 26px;

+ 3 - 2
src/containers/AssessResult.js

@@ -49,7 +49,8 @@ function mapDispatchToProps(dispatch) {
       const {range,rangeType,index} = param;
       const indexData = state.assessResult.indexData;
       const obj = indexData[range[0]+range[range.length-1]];
-      if(obj&&Object.keys(obj).length!=0){      //该维度已获取过数据
+
+      if(index!=undefined&&obj&&Object.keys(obj).length!=0){      //该维度已获取过数据
         //console.log(obj,rangeType,index);
         /*dispatch({
           type:SET_INDEX_SUB_TYPE,
@@ -71,7 +72,7 @@ function mapDispatchToProps(dispatch) {
       }).catch(error=>{
         console.log(error);
       });
-    }
+    },
   }
 }
 

+ 4 - 0
src/containers/ChronicInfo.js

@@ -24,6 +24,10 @@ function mapDispatchToProps(dispatch){
     },
     getScaleInfo(item){
       dispatch(getScaleInfo(item))
+    },
+    //保存管理评估
+    saveAssessInfos(obj){
+      console.log(222,obj);
     }
   }
 }

+ 1 - 0
src/store/reducers/assessResult.js

@@ -37,6 +37,7 @@ export default (state=init,action)=>{
       res.saveData = action.data;
       res.saveIndexData = action.indexData;
       return res;
+    //case CLEAR_ASSESS_DATA:
     default:
       return res;
   }

+ 2 - 1
src/utils/tools.js

@@ -586,7 +586,8 @@ function trimDots(str){
 
 //标签间连续标点只保留一个,保留前面一个
 function formatContinueDots(data){
-  let arr=data.filter((it,i)=>{
+  let arr=[];
+  arr=data&&data.filter((it,i)=>{
     if(i==0||(it.name&&(it.name.match(config.punctuationReg))||(data[i-1].name&&data[i-1].name.match(config.punctuationReg)))){
       return it;
     }