瀏覽代碼

Merge branch 'dev/zhangxc1' into dev/byll

Luolei 6 年之前
父節點
當前提交
b81aef699b

+ 60 - 0
src/components/Advice/Textarea/index.jsx

@@ -0,0 +1,60 @@
+import React, { Component } from "react";
+import style from "./index.less";
+import config from '@config/index';
+import $ from 'jquery';
+
+class Textarea extends Component {
+  constructor(props) {
+    super(props);
+    this.state = {
+      timer:null,
+      val:'报告描述或意见'
+    };
+    this.textInput = React.createRef();
+    this.$dom = React.createRef();
+    this.$domW = React.createRef();
+    this.handleInput = this.handleInput.bind(this);
+  }
+  handleInput(e){
+    e.stopPropagation();
+    const {handleChangeAssistValue,idx,handlePush} = this.props;
+    const text = e.target.innerText || e.target.innerHTML;
+    const stimer = this.state.timer;
+    handleChangeAssistValue&&handleChangeAssistValue(text);
+   
+  }
+  shouldComponentUpdate(next){
+    if(JSON.stringify(next) == JSON.stringify(this.props)){
+      return false;
+    }
+    return true;
+  }
+  componentWillReceiveProps(next){
+    const isRead = this.props.isRead;
+    if(next.isRead != isRead||next.value!=this.props.value){      //value对比解决复诊不显示bug
+      this.$dom.current.innerText?(this.$dom.current.innerText = next.value||''):(this.$dom.current.innerHTML = next.value||'');
+    }
+  }
+  componentDidMount(){
+    const {value} = this.props;
+    if(value && value.trim()){
+      this.$dom.current.innerText?(this.$dom.current.innerText = value) : (this.$dom.current.innerHTML = value)
+    //   this.$dom.current.nextSibling.innerText?(this.$dom.current.nextSibling.innerText = ''):(this.$dom.current.nextSibling.innerHTML = '')
+    }
+  }
+ 
+  render() {
+    return (
+      <div>
+        <div 
+            style={{outline: 'none'}}
+            contenteditable={true}
+            ref={this.$dom}
+            onInput={this.handleInput}
+            onKeyUp={this.handleInput}
+        ></div>
+      </div>
+    );
+  }
+}
+export default Textarea;

+ 0 - 0
src/components/Advice/Textarea/index.less


+ 47 - 20
src/components/Advice/index.jsx

@@ -1,6 +1,7 @@
 import React,{Component} from 'react';
 import style from './index.less';
 import {ItemBox} from '@commonComp';
+import Textarea from './Textarea';
 
 class Advice extends Component{
   constructor(props){
@@ -9,11 +10,26 @@ class Advice extends Component{
     this.treatInput = React.createRef();
     this.assayRef = React.createRef();
     this.checkRef = React.createRef();
+    this.adviceInputRef = React.createRef();
     this.handleTreatInput = this.handleTreatInput.bind(this);
     this.handleAssayInput = this.handleAssayInput.bind(this);
     this.handleCheckInput = this.handleCheckInput.bind(this);
+    this.handleComTreatInput = this.handleComTreatInput.bind(this);
+    this.handleAdviceInput = this.handleAdviceInput.bind(this);
   }
 
+  shouldComponentUpdate(next){
+    if(JSON.stringify(next) == JSON.stringify(this.props)){
+      return false;
+    }
+    return true;
+  }
+  componentWillReceiveProps(next){
+    const isRead = this.props.isRead;
+    // if(next.isRead != isRead||next.value!=this.props.value){      //value对比解决复诊不显示bug
+    //   this.adviceInputRef.current.innerText?(this.adviceInputRef.current.innerText = next.value||''):(this.adviceInputRef.current.innerHTML = next.value||'');
+    // }
+  }
   handleTreatInput(e, index, ii) {
     const {advice} = this.props.pushMessage;
     const changeInput = e.target.value //改变的同类药的值
@@ -33,26 +49,30 @@ class Advice extends Component{
     const { setChangeAdviceCheck } = this.props;
     setChangeAdviceCheck && setChangeAdviceCheck(changeInput)
   }
+  handleComTreatInput(text) {
+    const { comTreatChange } = this.props;
+    comTreatChange && comTreatChange(text)
+
+  }
+  handleAdviceInput(e) {
+    const { adviceInputChange } = this.props;
+    const text = e.target.innerText;
+    console.log(text)
+    adviceInputChange && adviceInputChange(text)
+
+  }
+  componentDidMount(){
+  
+    this.adviceInputRef.current.innerText?(this.adviceInputRef.current.innerText = '') : (this.adviceInputRef.current.innerHTML = '')
+  //   this.$dom.current.nextSibling.innerText?(this.$dom.current.nextSibling.innerText = ''):(this.$dom.current.nextSibling.innerHTML = '')
+  
+}
 
   render(){
     const {advice} = this.props.pushMessage;
-    let billing = ''
+    const {isRead} = this.props
 
-    // advice.assay.forEach((item, index) => {
-    //   if(index === advice.assay.length - 1){
-    //     billing = billing + (index + 1) + ':' + item + ';'
-    //   }else{
-    //     billing = billing + (index + 1) + ':' + item + ','
-    //   }
-    // })
-
-    // advice.check.forEach((item, index) => {
-    //   if(index === advice.check.length - 1){
-    //     billing = billing + (index + 1) + ':' + item + ';'
-    //   }else{
-    //     billing = billing + (index + 1) + ':' + item + ','
-    //   }
-    // })
+    
 
     let scheme = advice.scheme && advice.scheme.map((item, index) => {
       return <p>{item.treatment.map((it,ii) =>{
@@ -70,15 +90,22 @@ class Advice extends Component{
 
     return  <div className={`${'mainsuit-box'} ${style['main-suit']}`}>
       <ItemBox title='医嘱' editable={false} border={true} marginTop="10px">
-        <div className={style['billing']}>
+        {/* <div className={style['billing']}>
           {advice.assay && advice.assay.length > 0 || advice.check && advice.check.length > 0 ? <h1>开单项目</h1> : ''}
             {advice.assay && <span className={style['treat-input']}> {advice.assay}</span>}
             {advice.check && <span className={style['treat-input']}> {advice.check}</span>}
-          {/* {billing} */}
-        </div>
-        <div className={style['scheme']}>
+        </div> */}
+        {advice.commontreatment && advice.commontreatment.length > 0 &&<div className={style['billing']}  >
+          {advice.commontreatment && advice.commontreatment.length > 0 && <h1>一般治疗</h1>}
+            {/* {advice.commontreatment && <div className={style['treat-input']}  onInput={this.handleComTreatInput}  contentEditable={true} style = {{outline: 'none'}}></div>} */}
+            {<Textarea value={advice.commontreatment} isRead={isRead} handleChangeAssistValue={this.handleComTreatInput} ></Textarea>}
+        </div>}
+        {advice.scheme && advice.scheme.length > 0 &&<div contentEditable='false' className={style['scheme']}>
           {advice.scheme && advice.scheme.length > 0  && <h1>治疗方案</h1>}
           {scheme}
+        </div>}
+        <div className={style['billing']} ref={this.adviceInputRef} contentEditable={true} style = {{outline: 'none'}} onInput={this.handleAdviceInput} > 
+              
         </div>
       </ItemBox>
     </div>

+ 3 - 3
src/components/Advice/index.less

@@ -9,13 +9,13 @@
 .billing {
   padding: 0px 10px;
   h1{
-    margin: 10px 0px;
+    margin: 5px 0px;
   }
 }
 .scheme {
-  padding: 10px;
+  padding: 0px 10px;
   h1{
-    margin: 10px 0px;
+    margin: 5px 0px;
   }
   p{
     line-height: 18px;

+ 3 - 2
src/components/DiagnosticList/index.jsx

@@ -62,7 +62,8 @@ class DiagnosticList extends Component {
             delItem: item,
         })
     }
-    showTreat(item) {
+    showTreat(item, index) {
+        item.treatIndex = index
         const  { showTreat, getTreatResult } = this.props;
         getTreatResult && getTreatResult(item);
         showTreat && showTreat();
@@ -92,7 +93,7 @@ class DiagnosticList extends Component {
                                     {item.type === 1 ? <span className={style['diag-first']}>初诊</span> :<span className={style['diag-second']}> 复诊</span>}
                                     <span className={style['treat']}
                                           style ={{ color: hasTreat ?'' : 'gray', border: hasTreat ?'1px solid #3B9ED0' : '1px solid gray'}}
-                                          onClick={() =>{hasTreat && this.showTreat(item)}}>
+                                          onClick={() =>{hasTreat && this.showTreat(item, index)}}>
                                           治疗方案
                                     </span>
                                     <img className={style['diag-del']} src={del_icon} onClick={()=>{this.handleDeleteItem(item)}}/>

+ 2 - 2
src/components/Treat/GeneralTreat/index.jsx

@@ -9,10 +9,10 @@ class GeneralTreat extends Component {
     render() {
         const { icon, titleStyle,titleBg, filter, title, generalTreat } = this.props
         return(
-            generalTreat && generalTreat.length > 0 && <div className={style['general-wrapper']}>
+            generalTreat.content && generalTreat.content.length > 0 && <div className={style['general-wrapper']}>
                 <div className={style['general-title-box']} style={titleStyle}></div>
                 <div className={style['general-title']} ><img className={style['general-icon']} src={icon}/>{title}</div>
-                <div className={style['general-item']} dangerouslySetInnerHTML={{__html: generalTreat}}>
+                <div className={style['general-item']} dangerouslySetInnerHTML={{__html: generalTreat.content}}>
                 </div>
 
             </div>

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

@@ -27,7 +27,7 @@ class Treat extends Component {
         Notify.info('该功能即将上线,敬请期待。', 2000)
     }
     handleDetermine() {
-        const { title, treatment } = this.props
+        const { title, treatment, advice } = this.props
         const { addScheme } = this.props
         addScheme && addScheme(title, treatment);
         this.hideTreat()

+ 19 - 4
src/containers/AdviceContainer.js

@@ -1,10 +1,13 @@
 import React from 'react';
 import {connect} from 'react-redux';
 import Advice from '../components/Advice'
-import { SET_CHANGE_ADVICE_TREATMENT, SET_CHANGE_ADVICE_ASSAY, SET_CHANGE_ADVICE_CHECK } from '@store/types/pushMessage';
+import { SET_CHANGE_ADVICE_TREATMENT, SET_CHANGE_ADVICE_ASSAY, SET_CHANGE_ADVICE_CHECK, SET_COMMONTREATMENT ,SET_ADVICE_INPUT} from '@store/types/pushMessage';
 
-function mapStateToProps({pushMessage}) {
-    return ({pushMessage})
+function mapStateToProps(state) {
+    return ({
+        pushMessage: state.pushMessage,
+        isRead:state.homePage.isRead,
+    })
 }
 
 function mapDispatchToProps(dispatch) {
@@ -28,7 +31,19 @@ function mapDispatchToProps(dispatch) {
                 type: SET_CHANGE_ADVICE_CHECK,
                 changeInput:changeInput
             })
-        }
+        },
+        comTreatChange: (text) => {
+            dispatch({
+                type: SET_COMMONTREATMENT,
+                commontreatment: text,
+            })
+        },
+        adviceInputChange: (text) => {
+            dispatch({
+                type: SET_ADVICE_INPUT,
+                adviceInput: text,
+            })
+        },
     }
 }
 

+ 3 - 1
src/containers/Treat.js

@@ -2,7 +2,7 @@ import React from 'react';
 import { connect } from 'react-redux';
 import Treat from '@components/Treat';
 import { SELECT_DRUG, SET_OTHER_DRUG, SET_DRUG_INFO, CLEAR_DRUG_INFO,HIDE_TREAT, CLEAR_TREAT, SHOW_DRUG_INFO, HIDE_DRUG_INFO } from '@store/types/treat.js';
-import { getInstroduce, getRecommendBasic, getInstroduceMore } from '@store/async-actions/treat';
+import { getInstroduce, getRecommendBasic, getInstroduceMore, commonTreatAddToAdvice } from '@store/async-actions/treat';
 import { ADD_SCHEME } from '@store/types/pushMessage.js'
 import { showDrugInfo } from '../store/actions/treat';
 
@@ -18,6 +18,7 @@ function mapStateToProps(state){
         showDrug: treat.showDrugInfo,
         treatItem: treat.treatItem,
         drugInfoList: treat.drugInfoList,   //药品说明书列表(查询多个药品说明书)
+
     }
 }
  
@@ -71,6 +72,7 @@ function mapDispatchToProps(dispatch) {
                 title: title,
                 treatment: treatment
             })
+            dispatch(commonTreatAddToAdvice())
         },
         //查询多条药品说明数据(添加数据用)
         setDrugInfoMore:(drugIdList) => {

+ 13 - 0
src/store/actions/pushMessage.js

@@ -229,4 +229,17 @@ export const hideTipsDetails = (state, action) => {
 	const res = Object.assign({}, state);
 	res.showTipsDetails = false;
 	return res;
+}
+
+//一般治疗添加到医嘱
+export const setCommontreatment = (state, action) => {
+	const res = JSON.parse(JSON.stringify(state));
+	res.advice.commontreatment = action.commontreatment;
+	return res;
+}
+
+export const setAdviceInput = (state, action) => {
+	const res = JSON.parse(JSON.stringify(state));
+	res.advice.adviceInput = action.adviceInput;
+	return res;
 }

+ 6 - 0
src/store/actions/treat.js

@@ -99,3 +99,9 @@ export const setDrugInfoList = (state, action) => {
     return res
 }
 
+//是否第一次主诊断
+export const isFirstMainDiag = (state, action) => {
+    const res = Object.assign({}, state);
+    res.isFirstMainDiag = false;
+    return res;
+}

+ 20 - 1
src/store/async-actions/treat.js

@@ -1,7 +1,8 @@
 import { json } from "@utils/ajax";
 import { SET_TREAT } from '@store/types/diagnosticList';
 import { ADD_DIAGNOSTIC, GET_DIAGNOSTIC_STR} from '@store/types/diagnosticList';
-import { SET_DRUG_INFO, SET_TREATMENT, SET_TREAT_INFO, SET_RECOMMEND_BASIC, SET_DRUG_INFO_LIST } from '@store/types/treat';
+import { SET_COMMONTREATMENT } from '@store/types/pushMessage'
+import { SET_DRUG_INFO, SET_TREATMENT, SET_TREAT_INFO, SET_RECOMMEND_BASIC, SET_DRUG_INFO_LIST, IS_FIRST_MAIN_DIAG } from '@store/types/treat';
 import {storageLocal,getEMRParams} from '@utils/tools';
 import { isAddMainSuit } from '@store/async-actions/diagnosticList';
 
@@ -288,6 +289,24 @@ export const  getInstroduceMore = (drugIdList) =>{
     }
 }
 
+//一般治疗添加到医嘱
+export const commonTreatAddToAdvice = () => {
+    return (dispatch, getState) => {
+        const state = getState();
+        if(state.treat.treatItem.treatIndex === 0 && state.treat.isFirstMainDiag) {
+            dispatch({
+                type: IS_FIRST_MAIN_DIAG
+            })
+            dispatch({
+                type: SET_COMMONTREATMENT,
+                commontreatment: state.treat.treatItem.treat.commonTreatment.text
+            })
+        } else {
+            return
+        }
+    }
+}
+
 //其他推荐推荐依据不用展示
 // export const getRecommendBasic = (item)=>{
     

+ 8 - 2
src/store/reducers/pushMessage.js

@@ -1,5 +1,5 @@
-import {CHANGE_ASSAY, CHANGE_CHECK, BILLING_ADVICE, ADD_SCHEME, SET_TIPS,  SET_TIPS_DETAILS, SET_CHANGE_ADVICE_TREATMENT, SET_CHANGE_ADVICE_ASSAY, SET_CHANGE_ADVICE_CHECK, ADD_BILLING,CLEAR_ALL_PUSH_MESSAGE,SHOW_TIPS_DETAILS, HIDE_TIPS_DETAILS } from '../types/pushMessage';
-import {changeAssay, changeCheck, setAdvice, addScheme, setTips, setTipsDetails, setChangeAdviceTreatment, setChangeAdviceAssay, setChangeAdviceCheck, addBilling, clearAllPushMessage, showTipsDetails, hideTipsDetails } from '../actions/pushMessage';
+import {CHANGE_ASSAY, CHANGE_CHECK, BILLING_ADVICE, ADD_SCHEME, SET_TIPS,  SET_TIPS_DETAILS, SET_CHANGE_ADVICE_TREATMENT, SET_CHANGE_ADVICE_ASSAY, SET_CHANGE_ADVICE_CHECK, ADD_BILLING,CLEAR_ALL_PUSH_MESSAGE,SHOW_TIPS_DETAILS, HIDE_TIPS_DETAILS, SET_COMMONTREATMENT, IS_FIRST_MAIN_DIAG, SET_ADVICE_INPUT } from '../types/pushMessage';
+import {changeAssay, changeCheck, setAdvice, addScheme, setTips, setTipsDetails, setChangeAdviceTreatment, setChangeAdviceAssay, setChangeAdviceCheck, addBilling, clearAllPushMessage, showTipsDetails, hideTipsDetails, setCommontreatment, isFirstMainDiag, setAdviceInput } from '../actions/pushMessage';
 
 const initState = {
   vigilant: [],
@@ -46,6 +46,12 @@ export default function(state = initState, action) {
       return showTipsDetails(state, action);
     case HIDE_TIPS_DETAILS:
       return hideTipsDetails(state, action);
+    case SET_COMMONTREATMENT:
+      return setCommontreatment(state, action);
+    case IS_FIRST_MAIN_DIAG:
+      return isFirstMainDiag(state, action);
+    case SET_ADVICE_INPUT:
+      return setAdviceInput(state, action)
     default:
       return state;
   }

+ 6 - 3
src/store/reducers/treat.js

@@ -1,8 +1,9 @@
-import { SELECT_DRUG, SET_TREAT_INFO, SET_OTHER_DRUG, SET_DRUG_INFO, CLEAR_DRUG_INFO,SHOW_TREAT, HIDE_TREAT, CLEAR_TREAT, SHOW_DRUG_INFO, HIDE_DRUG_INFO, SET_GENERAL_TREAT, SET_TREATMENT, SET_SURGERY_TREAT, SET_RECOMMEND_BASIC, SET_DRUG_INFO_LIST } from '../types/treat'
-import { selectDrug, setTreatInfo, setOtherDrug, setDrugInfo, clearDrugInfo, showTreat, hideTreat, clearTreat, showDrugInfo, hideDrugInfo, setTreatment, setGeneralTreat, setSurgeryTreat, setRecommendBasic, setDrugInfoList } from '../actions/treat'
+import { SELECT_DRUG, SET_TREAT_INFO, SET_OTHER_DRUG, SET_DRUG_INFO, CLEAR_DRUG_INFO,SHOW_TREAT, HIDE_TREAT, CLEAR_TREAT, SHOW_DRUG_INFO, HIDE_DRUG_INFO, SET_GENERAL_TREAT, SET_TREATMENT, SET_SURGERY_TREAT, SET_RECOMMEND_BASIC, SET_DRUG_INFO_LIST,IS_FIRST_MAIN_DIAG } from '../types/treat'
+import { selectDrug, setTreatInfo, setOtherDrug, setDrugInfo, clearDrugInfo, showTreat, hideTreat, clearTreat, showDrugInfo, hideDrugInfo, setTreatment, setGeneralTreat, setSurgeryTreat, setRecommendBasic, setDrugInfoList, isFirstMainDiag } from '../actions/treat'
 const initState = {
     show: false, //治疗方案显示隐藏
     showDrugInfo: false, //药品信息显示隐藏
+    isFirstMainDiag: true, //是否为第一次主诊断开单
     generalTreat: '',
     surgeryTreat: '',
     treatment: [],
@@ -196,7 +197,9 @@ export default function(state=initState, action){
         case CLEAR_DRUG_INFO:
             return clearDrugInfo(state, action);
         case SET_DRUG_INFO_LIST:
-        return setDrugInfoList(state, action);
+            return setDrugInfoList(state, action);
+        case IS_FIRST_MAIN_DIAG: 
+            return isFirstMainDiag(state, action)
         default:
             return state
     }

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

@@ -13,5 +13,7 @@ export const SET_CHANGE_ADVICE_CHECK = 'SET_CHANGE_ADVICE_CHECK';   //改变医
 export const CLEAR_ALL_PUSH_MESSAGE = 'CLEAR_ALL_PUSH_MESSAGE';   //清除所有推送信息
 export const SHOW_TIPS_DETAILS = 'SHOW_TIPS_DETAILS'; //显示提示详情页
 export const HIDE_TIPS_DETAILS = 'HIDE_TIPS_DETAILS'; //显示提示详情页
+export const SET_COMMONTREATMENT = 'SET_COMMONTREATMENT'    //设置常见治疗
+export const SET_ADVICE_INPUT = 'SET_ADVICE_INPUT'  //设置医嘱自由输入内容
 
 

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

@@ -13,3 +13,5 @@ export const SET_TREATMENT = 'SET_TREATMENT' //设置治疗方案
 export const SET_RECOMMEND_BASIC = 'SET_RECOMMEND_BASIC'//设置其他推荐推荐依据
 export const SET_TREAT_INFO = 'SET_TREAT_INFO' //设置治疗方案信息(name,id等)
 export const SET_DRUG_INFO_LIST = 'SET_DRUG_INFO_LIST' //查询多个药品说明书(添加数据时查看药品说明用)
+export const IS_FIRST_MAIN_DIAG = 'IS_FIRST_MAIN_DIAG' //是否为主诊断第一次开单
+