Selaa lähdekoodia

现病史搜标签处理

liucf 6 vuotta sitten
vanhempi
commit
c923390367

+ 8 - 2
src/common/components/ItemBox/index.jsx

@@ -1,6 +1,6 @@
 import React,{Component} from 'react';
 import style from './index.less';
-import {isIE} from '@utils/tools.js';
+import {isIE,handleEnter} from '@utils/tools.js';
 import $ from 'jquery';
 /***
  * author:zn@2018-11-13
@@ -38,6 +38,12 @@ class ItemBox extends Component {
     }
   }
 
+  /*componentWillReceiveProps(next){
+    if(this.props.value && next.value!=this.props.value){
+      this.$div.current.innerText?(this.$div.current.innerText = next.value||''):(this.$div.current.innerHTML = next.value||'');
+    }
+  }*/
+
   componentDidMount(){
     if(isIE()){
       $(this.$div.current).onIe8Input(function(e){
@@ -50,7 +56,7 @@ class ItemBox extends Component {
     const {title,children,editable,className,handleFocus,onchange,fuzhen,border,handleBlur,titleTop,backgroundColor,boxId} = this.props;
     return <div className={style["box"]+" "+"clearfix"} >
       <div className={style["title"] + ' '+(className||'')} style={{marginTop:titleTop?'22px':''}}>{title}</div>
-      <div ref={this.$div} className={`${style["content"]} ${border?style["border"]:''} ${backgroundColor?style["noBorder"]:''}`} contentEditable={editable} style={this.getBoxStyle()} onFocus={handleFocus} onInput={this.handleInput} onClick={(e)=>{this.handleClick(e);}} onBlur={handleBlur} id={boxId}>
+      <div ref={this.$div} className={`${style["content"]} ${border?style["border"]:''} ${backgroundColor?style["noBorder"]:''}`} contentEditable={editable} style={this.getBoxStyle()} onFocus={handleFocus} onInput={this.handleInput} onClick={(e)=>{this.handleClick(e);}} onBlur={handleBlur} id={boxId} onkeydown={handleEnter}>
         {fuzhen?children||fuzhen:children}
       </div>
     </div>

+ 3 - 3
src/components/MainSuit/index.jsx

@@ -233,16 +233,16 @@ class MainSuit extends Component{
   handleBlur(e){//隐藏常见症状下拉、存自由输入的值
     const {freeText,saveText,datas,clearSearch,getSymptomFeature,currentData} = this.props;
     const that = this;
+    const ev = e || window.event;
     let data = this.state.inpText;
     if(!isIE()){
       if(currentData&&currentData.length==0){//现病史没有模板的时候才去获取
-        getSymptomFeature && getSymptomFeature(e.target.innerText);
+        getSymptomFeature && getSymptomFeature(ev.target.innerText);
       } 
-      e.target.innerText?(e.target.innerText=""):(e.target.innerHTML="")
+      ev.target.innerText?(ev.target.innerText=""):(ev.target.innerHTML="")
       freeText && freeText(data.trim());
     }else{
       if(datas.length==0){
-        const ev = e || window.event;
         const data = ev.target.innerText;
         // freeText && freeText(data.trim());
         freeText && freeText(data);

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

@@ -581,7 +581,7 @@ export function setCheckText(state,action) {
 //搜索 插入标签数据
 export function insertLabelData(state,action){
   let res = Object.assign({},state); 
-  const {index,data,isReplace,span}=action;console.log('现病史搜索数据',action);
+  const {index,data,isReplace,span}=action;
   let id = data.id;
   let searchData = action.name;
   // res.symptomIds.push(id);
@@ -679,11 +679,23 @@ export function insertLabelData(state,action){
       res.saveText = fullfillText(resData).saveText;
     }else{//标签
       if(strIndex < 1){//前
-        res.data.splice(focusIndex,0,data,textEmpty);
-        res.saveText.splice(focusIndex,0,'','');
-        res.selecteds.splice(focusIndex,0,null,null);
-        res.data[focusIndex+1].value = value;
-        res.saveText[focusIndex+1] = value;
+        // 判断前一个是否为文本标签,是直接插入标签,不是则在前面插入一个空文本标签
+        const preItem = res.data[focusIndex-1];
+        if(preItem&&preItem.tagType==8){
+          res.data.splice(focusIndex,0,data);
+          res.saveText.splice(focusIndex,0,'','');
+          res.selecteds.splice(focusIndex,0,null,null);
+          res.data[focusIndex+1].value = value;
+          res.saveText[focusIndex+1] = value;
+        }else{
+          res.data.splice(focusIndex,0,textEmpty,data);
+          res.saveText.splice(focusIndex,0,'','');
+          res.selecteds.splice(focusIndex,0,null,null);
+          res.data[focusIndex+2].value = value;
+          res.saveText[focusIndex+2] = value;
+        }
+        // res.data.splice(focusIndex,0,data,textEmpty);
+        
       }else{
         res.data.splice(focusIndex+1,0,data,textEmpty);
         res.saveText.splice(focusIndex+1,0,'','');
@@ -697,7 +709,7 @@ export function insertLabelData(state,action){
     // res.saveText = fullfillText(resData).saveText;
   }
   res.searchData = [];    //选中清空搜索内容(即关闭搜索弹窗)
-  res.update = Math.random();
+  res.update = Math.random();//console.log('现病史',res);
   return res;
 }
 

+ 5 - 3
src/store/actions/mainSuit.js

@@ -111,13 +111,14 @@ export const insertMain = (state,action) => {
         inserIndx = i;
       }
     })
-  data.splice(inserIndx-1,1,...obj);
+  // data.splice(inserIndx-1,1,...obj);
+  // 防止没有flag的情况下报错,找不到flag就插到最后
+  inserIndx?data.splice(inserIndx-1,1,...obj):data.splice(-1,0,...obj);
   // data[inserIndx-1] = text;//替换空标签
   res.data = data;
   res.saveText = [];//将手动输入的值清掉
   // res.saveText[inserIndx] = text.name;
   res.saveText = fullfillText(res.data).saveText;
-  // res.mainIds.push(id);
   res.mainIds = res.mainIds.concat(id);
   res.editClear = false;//主诉框编辑状态
   res.update=Math.random();
@@ -309,7 +310,7 @@ export const insertSearch = (state,action)=>{
       }
     })
     // flag=1前是文本标签就替换,否则插入
-    const iftext = moduleData[inserIndx-1].tagType;
+    const iftext = inserIndx?moduleData[inserIndx-1].tagType:null;
     if(iftext==config.tagType){
        moduleData.splice(inserIndx-1,1,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1});
      }else{
@@ -545,6 +546,7 @@ export const saveFreeVal = (state,action)=>{
     res.saveText = [];
   }*/
   // res.update = Math.random();
+  // console.log(666,action,res);
   return res;
 }