Browse Source

Merge branch 'optimize' into optimize-zxc

zhangxc 6 years ago
parent
commit
fe942ebee0

+ 40 - 51
src/common/components/InlineTag/index.jsx

@@ -10,8 +10,6 @@ import {handleEnter} from '@utils/tools.js';
  * value:输入的值
  * placeholder
  * suffix:后缀文字
- * canEditable: 切换父元素框(主诉同级框)的可编辑属性,
- *              PS:父元素框可编辑时子元素onBlur无法触发,因为此时focus的元素为父元素框
  *
  ***/
 class InlineTag extends Component {
@@ -19,9 +17,12 @@ class InlineTag extends Component {
     super(props);
     this.$box = React.createRef();
     this.$span = React.createRef();
+    this.$pre = React.createRef();
+    this.$suf = React.createRef();
     this.state = {
       editable:false,
-      value:props.value||''
+      value:props.value||'',
+      placeholder:props.placeholder||''
     };
     this.changeToEdit = this.changeToEdit.bind(this);
     this.changeToClick = this.changeToClick.bind(this);
@@ -29,7 +30,6 @@ class InlineTag extends Component {
     this.handleInput = this.handleInput.bind(this);
     this.handleFocus = this.handleFocus.bind(this);
     this.handleFixClick = this.handleFixClick.bind(this);
-    this.handleBoxInput = this.handleBoxInput.bind(this);
   }
   changeToEdit(e){
     const {handledbClick,id} = this.props;
@@ -44,45 +44,34 @@ class InlineTag extends Component {
     //埋点记录
     handledbClick&&handledbClick({id});
   }
-  handleBoxInput(e){
-    const {handleInput,ikey,prefix,suffix} = this.props;
-    const total = e.target.innerText;
-    const text = this.$span.current.innerText;
-    if(!total){
-      handleInput&&handleInput({text:total,ikey});
-    }
-  }
-  changeToClick(event){
-    event.returnValue = true;
-    const {canEditable} = this.props;
-    canEditable&&canEditable();
+  changeToClick(e){
+    e.stopPropagation();
+    const {saveEditText,ikey} = this.props;
     this.setState({
       editable:false
     });
+    saveEditText&&saveEditText({
+      changeVal:this.$span.current.innerText,
+      totalVal:this.$box.current.innerText,
+      prefix:this.$pre.current.innerText,
+      suffix:this.$suf.current.innerText,
+      ikey
+    });
   }
   handleInput(e){       //输入时保存临时值,在修改灰显为黑色时判断用
     e.stopPropagation();
-    const {handleInput,ikey,prefix,suffix} = this.props;
-    const text = e.target.innerText || e.target.innerHTML;
-    // 内容全部删除时,要把空值存到store,否则会遗留最后一个字且为灰色无法删除
-    if(!text){
-      this.$span.current.innerText?(this.$span.current.innerText=''):(this.$span.current.innerHTML='');      //修改生成文字变成输入的2倍bug
-      handleInput&&handleInput({text:text,ikey,prefix,suffix});
-      this.setState({
-        value:" "
-      });
-      return
-    }
-    this.setState({
-      value:text
-    });
-   // e.target.innerText = text;  
   }
   handleBlur(e){         //鼠标离开是保存值到store中
     e.stopPropagation(); //不阻止会触发外层div的失焦事件
-    const {value} = this.state;
-    const {handleInput,ikey,prefix,suffix} = this.props;
-    this.$span.current.innerText?(this.$span.current.innerText=''):(this.$span.current.innerHTML='');      //修改生成文字变成输入的2倍bug
+    const value = e.target.innerText;
+    const {handleInput,ikey,prefix,suffix,placeholder} = this.props;
+    if(!value.trim()){
+      this.setState({
+        placeholder:placeholder,
+        value:''
+      });
+    }
+    //this.$span.current.innerText?(this.$span.current.innerText=''):(this.$span.current.innerHTML='');      //修改生成文字变成输入的2倍bug
     handleInput&&handleInput({text:value.trim(),ikey,prefix,suffix});
     this.setState({
       value:value.trim()
@@ -92,20 +81,22 @@ class InlineTag extends Component {
     e.stopPropagation();
     const text = e.target.innerText || e.target.innerHTML;
     const {placeholder} = this.props;
-    if(text==placeholder){
-      e.target.innerText?(e.target.innerText = ''):(e.target.innerHTML='');
+    if(text.trim()==placeholder){
+      this.setState({
+        placeholder:''
+      });
     }
   }
   getStyle(){
-    const {value} = this.state;
-    const {hideTag} = this.props;
+    const {hideTag,placeholder} = this.props;
+    const value = this.$span.current&&this.$span.current.innerText.trim();
     if(hideTag){
       if(value){
         return classNames(style['selected-no-tag']);
       }
       return style['no-tag'];
     }
-    if(!value){
+    if(!value||value.trim()==placeholder){
       return classNames(style['gray']);
     }
     return style['selected-tag'];
@@ -133,27 +124,25 @@ class InlineTag extends Component {
     this.$span.current.style.minWidth=spanWidth;
   }
   render(){
-    const {placeholder,value,prefix,suffix} = this.props;
-    const {editable} = this.state;
-    const inp = this.state.value;
+    const {prefix,suffix} = this.props;
+    const {editable,placeholder,value} = this.state;
     return <div className={this.getStyle()}
                  onDoubleClick={this.changeToEdit}
-                  onClick={!editable?this.handleFixClick:''}
-                 onkeydown={handleEnter}
+                 /*onClick={!editable?this.handleFixClick:''}*/
+                 onKeyDown={handleEnter}
                  onBlur={this.changeToClick} 
                  ref={this.$box} 
-                 contentEditable={editable}
-                 onInput={this.handleBoxInput}>
-                {prefix}
+                 contentEditable={editable}>
+                <span ref={this.$pre}>&nbsp;{prefix}</span>
                 <span className={style['free-in']}
                       contentEditable={true}
                       onBlur={this.handleBlur}
                       onInput={this.handleInput}
                       onFocus={this.handleFocus}
-                      onClick={e=>e.stopPropagation()}
-                      onkeydown={handleEnter}
-                      ref={this.$span}>{value||(inp?'':placeholder)}</span>
-                {suffix}
+                      /*onClick={e=>e.stopPropagation()}*/
+                      onKeyDown={handleEnter}
+                      ref={this.$span}>&nbsp;{value||placeholder}</span>
+                <span ref={this.$suf}>&nbsp;{suffix}</span>
             </div>;
     }
 }

+ 3 - 4
src/components/ChronicInfo/index.jsx

@@ -521,13 +521,12 @@ class ChronicInfo extends React.Component{
     if(data&&data.length>0){
       return <div className={style["tips"]} style={{marginBottom:'15px'}}>
         <div className={`${style["tips-title"]} ${style["chronic"]}`}>
-          <div className={style["tips-name"]}>
+          <div className={style["tips-name"]} onClick={this.slideToggle}>
             <img src={chronicPic} />
-            <h2>{chronicMagItem&&chronicMagItem.name||chronicDesease&&chronicDesease.name||'病情提示'}</h2>
-            <span className={style["redTips"]}>(页面信息有更新可能影响评估结果)</span>
+            <h2>{chronicMagItem&&chronicMagItem.name||chronicDesease&&chronicDesease.name||'病情提示'}<span className={style["redTips"]}>(页面信息有更新可能影响评估结果)</span></h2>
           </div>
           <div className={style['toggle-btn']}>
-            <img src={slideUp?down:up} alt="展开/收起" onClick={this.slideToggle}/>
+            <img src={slideUp?down:up} alt="展开/收起"/>
           </div>
         </div>
         <div className={style["content"]} ref={this.$content}>

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

@@ -8,6 +8,8 @@
     padding: 8px 15px;
     background: #EAF7FA;
     font-weight: bold;
+    white-space: nowrap;
+    cursor: pointer;
     background: rgba(242,150,91,0.1);
     .tips-name{
       width: 238px;

+ 8 - 7
src/components/PushItems/index.jsx

@@ -186,25 +186,26 @@ class PushItems extends Component {
             )}
             {/* 不展示确诊 */}
             {/* {determine && determine.length>0 && <PushDiag titleBg='#FAEBEC' icon={possibleImg} title='确诊' diagList={determine} maxShowNum={28}/>} */}
-            {possible && possible.length > 0 && (
+            {doubt && doubt.length > 0 && (
               <PushDiag
                 titleBg="#FAEBEC"
-                icon={possibleImg}
+                icon={doubtImg}
                 title="可能诊断"
-                diagList={possible}
+                diagList={doubt}
                 maxShowNum={24}
               />
             )}
-            {doubt && doubt.length > 0 && (
+            {possible && possible.length > 0 && (
               <PushDiag
                 titleBg="#FAEBEC"
-                icon={doubtImg}
+                icon={possibleImg}
                 title="初步诊断"
-                diagList={doubt}
+                diagList={possible}
                 maxShowNum={24}
               />
             )}
             
+            
             {likely && likely.length > 0 && (
               <PushDiag
                 titleBg="#FAEBEC"
@@ -224,7 +225,7 @@ class PushItems extends Component {
                   <div className={style["doubt"]}>
                     <h1>
                       <img src={doubtImg} />
-                      疑似诊断
+                      可能诊断
                     </h1>
                     <div className={style["no-push"]}>无</div>
                   </div>

+ 12 - 1
src/components/RadioInpDrop/index.jsx

@@ -161,7 +161,7 @@ class RadioInpDrop extends Component{
       }else{
         lengths = mainText.length + val.length;
       }
-      console.log("val:",val,"preVal:",preText,"mainText:",mainText,"lengths:",lengths,this.state.texts)
+      //console.log("val:",val,"preVal:",preText,"mainText:",mainText,"lengths:",lengths,this.state.texts)
       if(lengths >= config.limited){
         Notify.info(config.limitText);
         this.setState({
@@ -225,6 +225,7 @@ class RadioInpDrop extends Component{
 class InputComp extends Component{
   constructor(props){
     super(props);
+    this.$inp = React.createRef();
     this.handleBlur = this.handleBlur.bind(this);
   }
   handleBlur(e){
@@ -234,9 +235,19 @@ class InputComp extends Component{
     e.target.innerText = '';
     handleInp(index,text);
   }
+  componentWillReceiveProps(next){
+    if(next.over&&!this.props.over){
+      const inp = this.$inp.current;
+      const value = this.props.value;
+      setTimeout(function(){
+        inp.innerText = value;
+      })
+    }
+  }
   render(){
     const {editable,value} = this.props;
     return editable?<span contentEditable={true}
+                          ref={this.$inp}
                  className={style['inner-inp']}
                  onClick={(e)=>{e.stopPropagation()}}
                  onFocus={(e)=>{e.stopPropagation()}}

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

@@ -430,7 +430,7 @@ class ListItems extends Component{
     const domNode = document.getElementById('root');
     return ReactDom.createPortal(
       <div className={style["drop-list"]} style={this.getStyle()} contentEditable="false" onClick={(e)=>{e.stopPropagation();}}>
-        <p className={style['orderTips']}>按{order?'从左到右列':'点选'}顺序成文</p>
+        <p className={style['orderTips']}>按{order?'从左到右从上到下':'点击'}顺序成文</p>
         {this.getLabels()}
         <div className="oper">
           <span className={style['clear']} onClick={handleClear}>清空选项</span>

+ 1 - 1
src/containers/CurrentIll.js

@@ -9,7 +9,7 @@ import {HIDE,RESET,CLICKCOUNT,ISREAD,SEARCH_DROP_LOCATION} from '@store/types/ho
 import {billing} from '@store/async-actions/pushMessage';
 import {getModule} from '@store/async-actions/fetchModules.js';
 import {didPushParamChange} from '@utils/tools.js';
-
+import {Notify} from '@commonComp';
 
 function mapStateToProps(state) {
   const {homePage,currentIll,mainSuit,diagnosticList} = state;

+ 20 - 1
src/containers/InlineTag.js

@@ -2,11 +2,14 @@ import React from 'react';
 import {connect} from 'react-redux';
 import {SETRADIO,CLEARSELECTED,CONFIRMSELECTED,SETOTHERINPUT} from '@types/otherHistory';
 import {SETMAININPUT} from '@types/mainSuit';
-import {SETCURRENTINPUT} from '@types/currentIll';
+import {SETCURRENTINPUT,CURRENT_TEXT_LABEL} from '@types/currentIll';
 import {SETCHECKINPUT} from "@types/checkBody";
 import InlineTag from "../common/components/InlineTag";
 import {getLabelIndex} from '@utils/tools.js';
 import {CLICKCOUNT} from '@types/homePage.js';
+import {CHANGEOTHERTEXTLABEL} from "../store/types/otherHistory";
+import {CHANGECHECKTEXTLABEL} from "../store/types/checkBody";
+import {CHANGE_LABELVAL} from "../store/types/mainSuit";
 
 function mapStateToProps(state){
   return {}
@@ -19,6 +22,13 @@ const tagInpActions = {
   4:SETCHECKINPUT
 };
 
+const inpEditActions = {
+  1:CHANGE_LABELVAL,
+  2:CURRENT_TEXT_LABEL,
+  3:CHANGEOTHERTEXTLABEL,
+  4:CHANGECHECKTEXTLABEL
+};
+
 function mapDispatchToProps(dispatch,store){
   return {
     handleInput(params) {
@@ -42,6 +52,15 @@ function mapDispatchToProps(dispatch,store){
         clickType:'双击',
         num:1
       });
+    },
+    saveEditText(obj){
+      const i = getLabelIndex(obj.ikey);
+      const type = obj.ikey.substr(0,1);
+      obj.ikey = i;
+      dispatch({
+        type:inpEditActions[type],
+        data:obj
+      })
     }
   }
 }

+ 1 - 1
src/containers/PushItemsContainer.js

@@ -6,7 +6,7 @@ import { ADD_DIAGNOSTIC, GET_DIAGNOSTIC_STR } from '@store/types/diagnosticList'
 import {billing, getAllConceptDetail} from '../store/async-actions/pushMessage';
 import { isAddMainSuit } from '@store/async-actions/diagnosticList';
 
-function mapStateToProps(state) {console.log(state)
+function mapStateToProps(state) {//console.log(state)
   const {pushMessage,diagnosticList} = state;
         return {
         pushMessage: pushMessage,

+ 7 - 3
src/store/actions/currentIll.js

@@ -571,9 +571,13 @@ export const changeLabelVal = (state,action)=>{
   let labText = totalVal?totalVal:newVal;
   let item = res.data[index];
   const next = res.data[+index+1];
-  const nextVal = next.value||next.name;
-  //标签后是不是标点符号标签,是的话删除本标签时一起删除
-  let nextIsDot = +next.tagType===8&&!nextVal.match(config.punctuationReg);
+  let nextVal='',nextIsDot=false;
+  if(next){
+    nextVal = next.value||next.name;
+    //标签后是不是标点符号标签,是的话删除本标签时一起删除
+    nextIsDot = +next.tagType===8&&!nextVal.match(config.punctuationReg);
+  }
+
   if(labText.trim()){
     if(item){
       item.value = newVal;

+ 1 - 1
src/store/async-actions/fetchModules.js

@@ -148,7 +148,7 @@ export function pregetCheckbodyData(flag){     //flag=true获取到数据后立
     const emrData = getEMRParams();
     const param = {
       age: emrData.age,
-      featureType: "1,4,7",
+      featureType: "1,4,41,7",
       diag: emrData.dis,
       lis: emrData.lis,
       other: emrData.other,

+ 1 - 1
src/store/async-actions/pushMessage.js

@@ -25,7 +25,7 @@ export const billing = (mdata,boxMark) => {
   const emrData = getEMRParams();
   const params = {
     age: emrData.age,
-    featureType: getCheck?"4,5,6,7":"5,6,7",
+    featureType: getCheck?"4,41,5,6,7":"4,5,6,7",    //41只返回查体模板,4只返回查体高亮
     // featureType: "22",
     diag: emrData.dis,
     lis: emrData.lis,

+ 40 - 11
src/store/reducers/wrapModalBody.js

@@ -60,36 +60,65 @@ export default (state = initWrapModal, action) => {
 
       return newState;
   }
-  if (action.type == SELECT_WARING) {
+  if (action.type == SELECT_WARING) {//选中异常值
       const newState = Object.assign({}, state);
       let listWrap = JSON.parse(JSON.stringify(newState.hospitalInspectObj))
+      let listWrapLen = listWrap&&listWrap.lisExcelWrapper.length
       let tmpGroup = JSON.parse(JSON.stringify(newState.selectGroupList))
       let tmpCheckedLis = JSON.parse(JSON.stringify(newState.checkedList))
-      let warArr = [],checked = [],numS=0
+      let warArr = [],checked = [],numS=0,selectNum=0;
+      // console.log(action,listWrap,tmpCheckedLis)
       for(let m =0;m < listWrap.lisExcelWrapper.length;m++){
+        let tmpName = listWrap.lisExcelWrapper[m].itemName
+        let tmpType = listWrap.lisExcelWrapper[m].type
         for(let n = 0;n < tmpCheckedLis.length;n++){
-          if(listWrap.lisExcelWrapper[m].type == 0 && listWrap.lisExcelWrapper[m].itemName == tmpCheckedLis[n]){
+          if(tmpType == 0 && tmpName == tmpCheckedLis[n]){//已选的正常的选项要保留
             warArr.push(listWrap.lisExcelWrapper[m])
-            checked.push(listWrap.lisExcelWrapper[m].itemName)
+            checked.push(tmpName)
           }
         }
-        if(listWrap.lisExcelWrapper[m].type != 0){
-          warArr.push(listWrap.lisExcelWrapper[m])
-          checked.push(listWrap.lisExcelWrapper[m].itemName)
+        if(tmpType != 0 && (tmpCheckedLis.filter(item=>item == tmpName)).length == 0){
+          ++selectNum
+        }
+      }
+      // console.log(selectNum)
+      for(let m =0;m < listWrap.lisExcelWrapper.length;m++){
+        let tmpName = listWrap.lisExcelWrapper[m].itemName
+        let tmpType = listWrap.lisExcelWrapper[m].type
+        if(selectNum>0){
+          if(listWrap.lisExcelWrapper[m].type != 0){//没有选中的选项要加上,有一个异常未选中就选中
+            warArr.push(listWrap.lisExcelWrapper[m])
+            checked.push(tmpName)
+          }
+        }else{//全部的选中就去掉所有异常选中的
+          for(let n = 0;n < tmpCheckedLis.length;n++){
+            if(tmpType == 0 && tmpName == tmpCheckedLis[n]){//已选的正常的选项要保留
+              checked=[]
+              warArr=[]
+              warArr.push(listWrap.lisExcelWrapper[m])
+              checked.push(tmpName)
+            }
+          }
         }
       }
       for(let i = 0;i < tmpGroup.length;i++){
         if(tmpGroup[i].groupName == listWrap.groupName){//右侧有选中相同组的明细
-          tmpGroup[i].lisExcelWrapper = warArr
+          if(warArr.length == 0){
+            tmpGroup.splice(i,1)
+          }else{
+            tmpGroup[i].lisExcelWrapper = warArr
+          }
         }else{//右侧没有选中相同组的明细
           ++numS
         }
       }
       if(numS == tmpGroup.length){//直接添加到右侧
-        listWrap.lisExcelWrapper = warArr
-        tmpGroup.push(listWrap)
+        if(warArr.length > 0){
+          listWrap.lisExcelWrapper = warArr
+          tmpGroup.push(listWrap)
+        }
       }
-      if(checked.length == listWrap.lisExcelWrapper.length){
+      if(checked.length == listWrapLen){
         newState.allCheck = true;            
       }else{
         newState.allCheck = false;