浏览代码

历史病例评估查看

zhouna 6 年之前
父节点
当前提交
ac4dccde9b

+ 93 - 0
src/components/AssessResult/AssessHis/index.jsx

@@ -0,0 +1,93 @@
+import React, { Component } from "react";
+import style from "./index.less";
+import { Radio} from '@commonComp';
+import arrow from '@common/images/icon_tri_blue.png';
+import loadingIcon from '@common/images/loading.gif';
+import ChooseItem from "../ChooseItem";
+import ScaleItem from "../ScaleItem";
+import ChartItem from "../ChartItem";
+
+class AssessResultHis extends Component {
+  constructor(props) {
+    super(props);
+    this.state={
+      chooseSelecteds:props.chooseSelecteds,     //大数据选择模块
+      chartTimeTypes:{},      //图表模块
+      wholeAssessItems:props.wholeIndexs,     //整体评估模块
+      wholeAssessText:props.wholeText||''     //整体评估补充说明
+    };
+    this.showAssessFn = this.showAssessFn.bind(this);
+    this.getAssessContent = this.getAssessContent.bind(this);
+  }
+  /*componentWillMount(){
+    //获取评估
+    this.props.getAssessHis(this.props.inquiryId);
+  }*/
+  /*componentWillReceiveProps(next){
+    const {inquiryId,getAssessHis} = this.props;
+    if(next.inquiryId!=inquiryId){
+      getAssessHis&&getAssessHis(next.inquiryId);
+    }
+  }*/
+  handleChartChange(i,selects){
+    const {chartTimeTypes} = this.state;
+    this.setState({
+      chartTimeTypes:Object.assign(chartTimeTypes,{[i]:selects})
+    });
+  }
+  showAssessFn(){
+    //获取历史评估数据
+    this.props.getAssessHis(this.props.inquiryId);
+  }
+  handoutTypes(obj,item,i){
+    const {indexTimeTypes,wholeAssess,wholeIndexs,chooseSelecteds} =obj;
+    const {getIndexData,inquiryDate,indexData} = this.props;console.log(indexData)
+    const name = item.regionName+":";
+    const list = item.data&&item.data.rows;
+    switch (+item.regionType){
+      case 0:     //数据来源与右侧手动添加
+        return <ScaleItem title={name} data={wholeAssess} indexs={wholeIndexs} disabled={true}></ScaleItem>;
+      case 1:     //数据来源于大数据
+        return <ChooseItem title={name} data={list} selecteds={chooseSelecteds&&chooseSelecteds[i]} disabled={true}></ChooseItem>;
+      case 10:    //数据来源于后台
+        return <ChartItem title={name}
+                          data={indexData||{}}
+                          timeTypes={indexTimeTypes}
+                          initFn={getIndexData}
+                          endDate={inquiryDate}
+                          handleChange={this.handleChartChange.bind(this,i)}></ChartItem>;
+      default:
+        return '';
+    }
+  }
+  getAssessContent(){
+    const { list,inquiryId } = this.props;
+    const obj = list&&list[inquiryId];
+    const data = obj&&obj.data;
+    if(data&&data.length>0){
+      return data.map((it,i)=>{
+        return this.handoutTypes(obj,it,i);
+      });
+    }else{
+      return data===null||(data&&data.length==0)?<p className={style['no-data']}>没有历史评估记录!</p>:'';
+    }
+  }
+  render() {
+    const { list,inquiryId,loading } = this.props;
+    const data = list&&list[inquiryId]&&list[inquiryId].data;
+    return <div className={style['assess-cont']}>
+      <div className={style['assess-result']}>
+        <p className={style['enter']}>管理和评估结果:<a onClick={this.showAssessFn}>查看结果<img src={arrow} /></a></p>
+      </div>
+      <div className={style['assess-box']}>
+        {loading?<p className={style['loading']}><img src={loadingIcon} alt='loading...'/></p>:''}
+        {/*{data?data.map((it,i)=>{
+          return this.handoutTypes(it,i);
+        }):data===null?<p className={style['no-data']}>没有历史评估记录!</p>:''}*/}
+        {this.getAssessContent()}
+      </div>
+    </div>;
+  }
+}
+
+export default AssessResultHis;

+ 32 - 0
src/components/AssessResult/AssessHis/index.less

@@ -0,0 +1,32 @@
+@import "~@less/variables.less";
+.assess-result{
+  border-top: 1px #e2e4e6 solid;
+  margin-top:50px;
+  .enter{
+    margin-top: 15px;
+  }
+  a{
+    color: @blue;
+    cursor: pointer;
+    img{
+      margin-left: 4px;
+    }
+  }
+}
+.assess-box{
+  margin: 20px 0 0 -15px;
+}
+.no-data{
+  text-align: center;
+  font-size: 20px;
+  color: @placeholder-color;
+  margin-top: 26px;
+  font-weight: bold;
+}
+.loading{
+  margin-top: 20px;
+  text-align: center;
+  img{
+    width: 30px;
+  }
+}

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

@@ -17,7 +17,8 @@ class ChartItem extends Component {
     this.getXAxisArr = this.getXAxisArr.bind(this);
   }
   getXAxisArr(type){
-    let now = new Date().getTime();
+    const endDate = this.props.endDate;
+    let now = endDate?new Date(endDate).getTime():new Date().getTime();
     let arr = [],temp=0;
     //近一周
     switch(type){
@@ -90,7 +91,7 @@ class ChartItem extends Component {
     return arr;
   }
   componentDidMount(){
-    const {initFn,data,pindex} = this.props;
+    const {initFn,pindex} = this.props;
     const type = config.chartDismen;
     const times = this.getXAxisArr(config.chartDismen);
     const startTime=times[0];
@@ -124,7 +125,7 @@ class Chart extends Component{
     this.timeSwitch = this.timeSwitch.bind(this);
   }
   drawChart(){
-    const {index,data,getXAxisArr,type} = this.props;
+    const {index,data,getXAxisArr,type,endDate} = this.props;
     const xAxis = getXAxisArr(type);
     const id = 'chart'+index;
     let series = [],names=[],inx=-1;
@@ -162,7 +163,11 @@ class Chart extends Component{
         trigger: 'axis'
       },
       legend: {
-        data:names
+        data:names,
+        bottom:210
+      },
+      grid:{
+        top:80
       },
       xAxis: {
         type: 'category',
@@ -182,7 +187,7 @@ class Chart extends Component{
           show:true,
           showMaxLabel:true,
           interval:interval[type],
-          rotate:45,
+          rotate:65,
           fontSize:10
         }
       },

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

@@ -30,7 +30,7 @@ class ChooseItem extends Component {
     handleChange&&handleChange(selecteds);
   }
   render() {
-    const {title,data,selecteds} = this.props;
+    const {title,data,selecteds,disabled} = this.props;
     return <div className={style['assess-item']}>
         <h2>{title}</h2>
         <div className={style['item-content']}>
@@ -44,6 +44,7 @@ class ChooseItem extends Component {
                       return <div className={style['choose-item']}>
                                 <Radio label={i.detailName}
                                        value={i.detailName}
+                                       disabled={disabled}
                                        isSelect={selecteds&&selecteds[it.name]==i.detailName}
                                        handleClick={this.handleRadio.bind(this,it.name,i.detailName)}></Radio>
                                 {i.state?<i>(智能推荐)</i>:''}
@@ -53,6 +54,7 @@ class ChooseItem extends Component {
                                 <CheckBtn id={i.detailName}
                                           value={i.detailName}
                                           label={i.detailName}
+                                          disabled={disabled}
                                           isSelect={selecteds[it.name]&&selecteds[it.name].includes(i.detailName)}
                                           handleClick={this.handleCheckbox.bind(this,it.name,i.detailName)}/>
                                 {i.state?<i>(智能推荐)</i>:''}

+ 6 - 2
src/components/AssessResult/ScaleItem/index.jsx

@@ -222,7 +222,7 @@ class ScaleItem extends Component {
     }
   }
   render() {
-    const {title,handleInp,scaleInfo} = this.props;
+    const {title,handleInp,scaleInfo,disabled} = this.props;
     const {scaleName,scaleId,parentId,showScale} = this.state;
     const footer = <div className={style['footer']}>
       <span className={style['print']} onClick={this.onPrint}><img src={printIcon} alt=""/>打印</span>
@@ -236,7 +236,11 @@ class ScaleItem extends Component {
             this.getItems()
           }
           <li>
-            <textarea className={style['edit-row']} ref={this.$area} name="supplement" rows="6" placeholder='评估描述' onBlur={(e)=>handleInp(e.target.value)}></textarea>
+            <textarea className={style['edit-row']}
+                      ref={this.$area}
+                      name="supplement"
+                      rows="6"
+                      placeholder='评估描述' onBlur={disabled?null:(e)=>handleInp(e.target.value)} disabled={disabled}></textarea>
           </li>
         </ul>
       </div>

+ 8 - 4
src/components/AssessResult/index.less

@@ -70,6 +70,7 @@
   }
   .cont{
     display: inline-block;
+    min-width: 302px;
     width: 49%;
     height: 250px;
     margin-bottom: 20px;
@@ -80,20 +81,23 @@
     }
   }
   .cont:nth-child(odd){
-    margin-right: 2%;
+    /*margin-right: 2%;*/
   }
   .time-range{
     position: absolute;
-    top: 26px;
+    bottom: 180px;
+    /*top: 26px;*/
     z-index: 2;
-    margin-left: 18px;
+    width: 100%;
+    text-align: center;
+    /*margin-left: 18px;*/
     .range{
       display: inline-block;
       border:1px #DFDFDF solid;
       border-radius: 10px;
       background: #fff;
       padding: 5px 10px;
-      margin-right: 15px;
+      margin-right: 10px;
       font-size: 12px;
       cursor: pointer;
       &.on{

+ 2 - 4
src/components/PreviewBody/index.jsx

@@ -6,8 +6,6 @@ import Information from '../Information';
 import $ from "jquery";
 import AssessResultHis from '@containers/AssessResultHis'
 
-// import "@utils/jqprint";
-
 class PreviewBody extends Component {
   constructor(props) {
     super(props)
@@ -79,7 +77,7 @@ class PreviewBody extends Component {
     const other_yjs = filterOtherDataArr(JSON.parse(dataStr.other),dataJson.other);
     const noData = JSON.stringify(preInfo) == '{}';
     return <div className={style['content']} style={{ width: flg ? '700' : '820' }}>
-      <div className={style['contents']} id="content" style={{ margin: "0 auto", maxWidth: "600px" }}>
+      <div className={style['contents']} id="content" style={{ margin: "0 auto", maxWidth: "620px" }}>
         <Information baseObj={baseObj} preInfo={preInfo}></Information>
         <table className={style['infos']}>
           <tr className={style['patInfoFst']}>
@@ -224,7 +222,7 @@ class PreviewBody extends Component {
           </tr>
         </table>
         <p style={{textAlign:'right',marginTop:'15px'}}>医生签名:<span style={{minWidth: '60px',padding: '0 5px 2px 5px',borderBottom: '1px solid #333',}}>{baseObj ? baseObj.doctorName : (noData ? '' : preInfo.doctorName)}</span></p>
-        {/*<AssessResultHis inquiryId={baseObj&&baseObj.inquiryCode}></AssessResultHis>*/}
+        <AssessResultHis inquiryId={baseObj&&baseObj.id} inquiryDate={baseObj&&baseObj.inquiryDate}></AssessResultHis>
       </div>
 
       <div onClick={() => { this.surePrint(dataStr) }} style={{

+ 121 - 0
src/containers/AssessResultHis.js

@@ -0,0 +1,121 @@
+import React from 'react';
+import {connect} from 'react-redux';
+import AssessResultHis from '@components/AssessResult/AssessHis';
+import {ISREAD} from '@store/types/homePage.js';
+import {billing} from '@store/async-actions/pushMessage';
+import {getAssessHis,getIndexData} from '@store/async-actions/fetchModules';
+import {SET_ASSESS_DATA,SET_INDEX_DATA,SET_INDEX_SUB_TYPE,REMOVE_ASSESS_ITEMS} from '@types/assessResult';
+import {SET_ASSESS_HISTORY_DATA,SET_ASSESS_HISTORY_LOADING} from '@types/assessResultHis';
+import store from '@store';
+
+/***
+ * 管理评估逻辑:
+ * 根据推送弹窗显示“智能推荐”,首次无选中项
+ * 评估内容项接口返回,其中整体评估为右侧操作加入
+ * 点确定等同于页面病例保存按钮(同时保存页面数据和评估结果)
+ * 点确定后再次打开,保留上次操作结果(页面清空,引用除外),
+ * 但推荐选项按最新推送显示
+ *
+ * ***/
+
+function mapStateToProps(state) {
+  const {assessResultHis,assessResult} = state;
+  return {
+    list:assessResultHis,    //已获取到的历史评估列表
+    indexData:assessResult.indexData,
+    //loading:assessResultHis.loading,
+    /*data:assessResultHis.data,
+    timeTypes:assessResultHis.indexTimeTypes,    //图表切换的维度
+    wholeAssessData:assessResultHis.wholeAssess,   //评估内容
+    wholeIndexs:assessResultHis.wholeIndexs,      //已加入评估记录的推送项
+    chooseSelecteds:assessResultHis.chooseSelecteds,    //已选中的选项
+    wholeAssessText:assessResultHis.wholeAssessText,     //整体评估补充说明*/
+  }
+}
+
+function mapDispatchToProps(dispatch) {
+  return {
+    getAssessHis(id){
+      dispatch({
+        type:SET_ASSESS_HISTORY_LOADING,
+        flag:true
+      });
+      dispatch(getAssessHis(id)).then((res)=>{
+        if(res.data.code=='0'){
+          const data = res.data.data[0]&&res.data.data[0].htmlContent;
+          dispatch({
+            type:SET_ASSESS_HISTORY_DATA,
+            id:id,
+            data:JSON.parse(data||null)
+          });
+        }
+        dispatch({
+          type:SET_ASSESS_HISTORY_LOADING,
+          flag:false
+        });
+      }).catch(error=>{
+        dispatch({
+          type:SET_ASSESS_HISTORY_LOADING,
+          flag:false
+        });
+        console.log(error);
+      });
+    },
+    getIndexData(param){
+      const state=store.getState();
+      const {range,rangeType,index} = param;
+      const indexData = state.assessResult.indexData;
+      const obj = indexData[range[0]+range[range.length-1]];
+
+      if(index!=undefined&&obj&&Object.keys(obj).length!=0){      //该维度已获取过数据
+        //console.log(obj,rangeType,index);
+        /*dispatch({
+          type:SET_INDEX_SUB_TYPE,
+          index,
+          rangeType
+        });*/
+        return ;
+      }
+      dispatch(getIndexData(range)).then((res)=>{
+        if(res.data.code=='0'){
+          dispatch({
+            type:SET_INDEX_DATA,
+            data:parseChartData(res.data.data),
+            range,
+            index,
+            rangeType
+          });
+        }
+      }).catch(error=>{
+        console.log(error);
+      });
+    },
+    /*removeAssessResult(pIndex,i){
+      dispatch({
+        type:REMOVE_ASSESS_ITEMS,
+        pIndex,
+        index:i
+      });
+    }*/
+  }
+}
+
+function parseChartData(indexData){
+  let arr=[],obj={},temp={};
+  let nameArr=[],nameObj={};  //暂弃
+  if(!indexData){
+    return [];
+  }
+  indexData.itemIndexData.map((it)=>{
+    temp=indexData.indexConfigData.find((i)=>{return it.itemName==i.indexUnique});
+    arr=obj[temp.orderNo]||[];
+    nameArr=nameObj[temp.orderNo]||[];
+    obj[temp.orderNo]=[...arr,it];
+    nameObj[temp.orderNo]=[...nameArr,it.itemName];
+  });
+  //nameObj,obj;
+  return obj;
+}
+const AssessResultHisContainer = connect(mapStateToProps, mapDispatchToProps)(AssessResultHis);
+
+export default AssessResultHisContainer;

+ 3 - 1
src/store/index.js

@@ -29,6 +29,7 @@ import getInfoByUuid from './reducers/getInfoByUuid';
 import treat from './reducers/treat';
 import currentIll from './reducers/currentIll';
 import assessResult from './reducers/assessResult';
+import assessResultHis from './reducers/assessResultHis';
 
 
 const composeEnhancers =
@@ -64,7 +65,8 @@ const rootReducer = combineReducers({
     getInfoByUuid,
 	checkBody,
     currentIll,
-  assessResult
+  assessResult,
+  assessResultHis
 });
 
 export default createStore(rootReducer, enhancer);

+ 15 - 0
src/store/reducers/assessResultHis.js

@@ -0,0 +1,15 @@
+import {SET_ASSESS_HISTORY_DATA,SET_ASSESS_HISTORY_LOADING} from '@types/assessResultHis';
+
+export default (state={},action)=>{
+  const res = Object.assign({},state);
+  switch (action.type){
+    case SET_ASSESS_HISTORY_DATA:
+      res[action.id] = action.data;
+      return res;
+    case SET_ASSESS_HISTORY_LOADING:
+      res.loading = action.flag;
+      return res;
+    default:
+      return res;
+  }
+}

+ 2 - 0
src/store/types/assessResultHis.js

@@ -0,0 +1,2 @@
+export const SET_ASSESS_HISTORY_DATA = 'SET_ASSESS_HISTORY_DATA';
+export const SET_ASSESS_HISTORY_LOADING = 'SET_ASSESS_HISTORY_LOADING';