Browse Source

主诉搜索添加itemType限制字段;现病史处理搜标签

liucf 6 years ago
parent
commit
eef376a966

+ 17 - 0
src/common/components/EditableSpan/index.jsx

@@ -157,6 +157,23 @@ class EditableSpan extends Component{
         preVal:innerVal
       })
     }
+    let range = window.getSelection();
+    let textIndex = range.focusOffset;
+    let textLength = range.anchorNode.length;
+    if(ev.keyCode==37){//向左
+      let preObj = $(this.$span.current).prev();
+      let obj = preObj[0]&&preObj[0].nodeName=="DIV"?preObj.prev():preObj;
+      if(textIndex == 0){
+        this.moveEnd(obj[0]);
+      }
+    }
+    if(ev.keyCode==39){//向右
+      let nextObj = $(this.$span.current).next();
+      let obj = nextObj[0]&&nextObj[0].nodeName=="DIV"?nextObj.next():nextObj;
+      if(textIndex == textLength){
+        obj.focus();
+      }
+    }
   }  
   handleKeyup(e){
     const {boxMark,handleKeydown,i,value,removeId,handleClear,delSingleLable,setSearchLocation} = this.props;

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

@@ -131,7 +131,7 @@ class MainSuit extends Component{
       clearSearch && clearSearch();
       return
     }
-    clearTimeout(this.state.timer);
+    // clearTimeout(this.state.timer);
     if(datas.length==0){//没有使用模板时点击搜索结构要展开模板
       insertSearch &&insertSearch({item,span});
       this.setState({
@@ -222,7 +222,7 @@ class MainSuit extends Component{
     const timer = setTimeout(function(){
       pushMessage && pushMessage(data);
       //调搜索接口 使用模板走EditableSpan里的搜索方法
-      getSearchData && getSearchData({inpStr:data,boxMark:1});
+      getSearchData && getSearchData({inpStr:data,boxMark:1,itemType:0});
     },config.delayTime);
     this.setState({
       timer
@@ -249,16 +249,16 @@ class MainSuit extends Component{
       }
     }
     // 延时关闭常见症状下拉、清空搜索结果,不延时会影响选中
-      clearTimeout(this.state.clearTimer);
+      /*clearTimeout(this.state.clearTimer);
       const clearTimer = setTimeout(function(){
         clearSearch && clearSearch();
-        /*that.setState({
+        that.setState({
           symptom:false
-        })*/
+        })
       },config.delayTime-200);
       this.setState({
         clearTimer
-      });  
+      });*/  
   }
 
 

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

@@ -61,7 +61,7 @@ class SearchDrop extends Component{
         <ul>
           {this.props.data&&this.props.data.map((it)=>{
             litext = it.showType==1?it.name:it.name+'('+it.retrievalName+')';
-            return <li onmouseup={(e)=>this.handleSelect(e,it)} title={litext}>{litext}</li>
+            return <li onClick={(e)=>this.handleSelect(e,it)} title={litext}>{litext}</li>
           })}
         </ul>
       </div>

+ 1 - 1
src/containers/EditableSpan.js

@@ -21,7 +21,7 @@ function mapStateToProps(state){//console.log(state)
 function mainSuitSearch(obj){
   return (dispatch)=>{
     const text = obj.text.replace(/\,/,'');
-    getSearch({boxMark:1,inpStr:text,mainIds:obj.mainIds}).then((res)=>{
+    getSearch({boxMark:1,inpStr:text,mainIds:obj.mainIds,itemType:0}).then((res)=>{
       if(res.data.code=='0'){
         dispatch({
           type:SET_SEARCH,

+ 71 - 51
src/store/actions/currentIll.js

@@ -581,11 +581,12 @@ export function setCheckText(state,action) {
 //搜索 插入标签数据
 export function insertLabelData(state,action){
   let res = Object.assign({},state); 
-  const {index,data,isReplace,span}=action;
+  const {index,data,isReplace,span}=action;console.log('现病史搜索数据',action);
   let id = data.id;
   let searchData = action.name;
-  res.symptomIds.push(id);
+  // res.symptomIds.push(id);
   const text = Object.assign(JSON.parse(config.textLabel),{name:searchData},{id:id});
+  const textEmpty = Object.assign({},JSON.parse(config.textLabel));
   let focusIndex = res.focusIndex;
   let saveText = res.saveText;
   let banIdx = saveText.indexOf("伴");
@@ -602,55 +603,15 @@ export function insertLabelData(state,action){
     res.saveText[focusIndex] = searchData;
   }else{
     let resData;
-    // res.data.splice(index,0,data);
     const searchStr = res.searchStr;
     let innerText = span.current.innerText || span.current.innerHTML;
     let strIndex = innerText.indexOf(searchStr);
     const value = innerText.replace(searchStr,"");
-    // 没有伴展开主诉symptomType=0/1的尾巴,有伴一>第一个点选上去的伴为依据,伴前展开主诉,伴后展开伴随;多余的伴以及手动输入的伴不做处理(2-25)
-    if(banIdx==-1){
-      // if(strIndex <= 1){//前
-      if(strIndex < 1){//前
-        res.data.splice(focusIndex,0,text);
-        res.saveText.splice(focusIndex,0,searchData);
-        res.data[focusIndex+1].value = value;
-        res.saveText[focusIndex+1] = value;
-        resData = JSON.parse(JSON.stringify(res.data));
-        resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
-                                return item.symptomType==0||item.symptomType==1;
-                              })));
-      }else{
-        res.data.splice(focusIndex+1,0,text);
-        res.saveText.splice(focusIndex+1,0,searchData);
-        res.data[focusIndex].value = value;
-        resData = JSON.parse(JSON.stringify(res.data));
-        // +2是因为插入一个文本标签  
-        resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
-                                return item.symptomType==0||item.symptomType==1;
-                              })));
-      }
-    }else{
-      if(focusIndex > banIdx){//伴后
-        if(strIndex < 1){//前
-          res.data.splice(focusIndex,0,text);
-          res.saveText.splice(focusIndex,0,searchData);
-          res.data[focusIndex+1].value = value;
-          res.saveText[focusIndex+1] = value;
-          resData = JSON.parse(JSON.stringify(res.data));
-          resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
-                                  return item.symptomType==0||item.symptomType==2;
-                                })));
-        }else{
-          res.data.splice(focusIndex+1,0,text);
-          res.saveText.splice(focusIndex+1,0,searchData);
-          res.data[focusIndex].value = value;
-          resData = JSON.parse(JSON.stringify(res.data));
-          // +2是因为插入一个文本标签  
-          resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
-                                  return item.symptomType==0||item.symptomType==2;
-                                })));
-        }
-      }else{//伴前
+    if(data.itemType==0){//症状
+      res.symptomIds.push(id);
+      // 没有伴展开主诉symptomType=0/1的尾巴,有伴一>第一个点选上去的伴为依据,伴前展开主诉,伴后展开伴随;多余的伴以及手动输入的伴不做处理(2-25)
+      if(banIdx==-1){
+        // if(strIndex <= 1){//前
         if(strIndex < 1){//前
           res.data.splice(focusIndex,0,text);
           res.saveText.splice(focusIndex,0,searchData);
@@ -664,20 +625,79 @@ export function insertLabelData(state,action){
           res.data.splice(focusIndex+1,0,text);
           res.saveText.splice(focusIndex+1,0,searchData);
           res.data[focusIndex].value = value;
+          res.saveText[focusIndex] = value;
           resData = JSON.parse(JSON.stringify(res.data));
           // +2是因为插入一个文本标签  
           resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
                                   return item.symptomType==0||item.symptomType==1;
                                 })));
         }
+      }else{
+        if(focusIndex > banIdx){//伴后
+          if(strIndex < 1){//前
+            res.data.splice(focusIndex,0,text);
+            res.saveText.splice(focusIndex,0,searchData);
+            res.data[focusIndex+1].value = value;
+            res.saveText[focusIndex+1] = value;
+            resData = JSON.parse(JSON.stringify(res.data));
+            resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
+                                    return item.symptomType==0||item.symptomType==2;
+                                  })));
+          }else{
+            res.data.splice(focusIndex+1,0,text);
+            res.saveText.splice(focusIndex+1,0,searchData);
+            res.data[focusIndex].value = value;
+            resData = JSON.parse(JSON.stringify(res.data));
+            // +2是因为插入一个文本标签  
+            resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
+                                    return item.symptomType==0||item.symptomType==2;
+                                  })));
+          }
+        }else{//伴前
+          if(strIndex < 1){//前
+            res.data.splice(focusIndex,0,text);
+            res.saveText.splice(focusIndex,0,searchData);
+            res.data[focusIndex+1].value = value;
+            res.saveText[focusIndex+1] = value;
+            resData = JSON.parse(JSON.stringify(res.data));
+            resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
+                                    return item.symptomType==0||item.symptomType==1;
+                                  })));
+          }else{
+            res.data.splice(focusIndex+1,0,text);
+            res.saveText.splice(focusIndex+1,0,searchData);
+            res.data[focusIndex].value = value;
+            resData = JSON.parse(JSON.stringify(res.data));
+            // +2是因为插入一个文本标签  
+            resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
+                                    return item.symptomType==0||item.symptomType==1;
+                                  })));
+          }
+        }
+      }
+      res.data = fullfillText(resData).newArr;
+      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;
+      }else{
+        res.data.splice(focusIndex+1,0,data,textEmpty);
+        res.saveText.splice(focusIndex+1,0,'','');
+        res.selecteds.splice(focusIndex+1,0,null,null);
+        res.data[focusIndex].value = value;
+        res.saveText[focusIndex] = value;
       }
     }
-    span.current.innerText?(span.current.innerText = value):(span.current.innerHTML = value);
-    res.data = fullfillText(resData).newArr;
-    res.saveText = fullfillText(resData).saveText;
+    // span.current.innerText?(span.current.innerText = value):(span.current.innerHTML = value);
+    // res.data = fullfillText(resData).newArr;
+    // res.saveText = fullfillText(resData).saveText;
   }
   res.searchData = [];    //选中清空搜索内容(即关闭搜索弹窗)
-  res.update = Math.random();//console.log(899,res,action);
+  res.update = Math.random();
   return res;
 }
 

+ 2 - 1
src/store/actions/mainSuit.js

@@ -320,6 +320,7 @@ export const insertSearch = (state,action)=>{
     res.data = moduleData;
     // res.saveText[inserIndx] = searchData;
     res.saveText = fullfillText(res.data).saveText;
+    // res.saveText[inserIndx] = searchData;
     res.mainIds.push(id);
     res.editClear = false;//主诉框编辑状态
   }else{
@@ -543,7 +544,7 @@ export const saveFreeVal = (state,action)=>{
   }else{
     res.saveText = [];
   }*/
-  res.update = Math.random();
+  // res.update = Math.random();
   return res;
 }
 

+ 21 - 9
src/store/async-actions/fetchModules.js

@@ -47,15 +47,27 @@ export const getModule = (id)=>{
 //搜索接口
 export const getSearch = (param)=>{
   const {patInfo} = store.getState();
-    const {inpStr,boxMark,mainIds} = param;
-    const params = {
-      "age": patInfo.message.patientAge,
-      "inputIds":mainIds&&mainIds.length>0?mainIds:[],//主诉去重
-      "inputStr": inpStr.trim(),
-      // "inputStr": inpStr,
-      "sexType": patInfo.message.sex,
-      "type": boxMark //1为搜症状
-    };
+    const {inpStr,boxMark,mainIds,itemType} = param;
+    let params = {};
+    if(itemType==0){//主诉,仅限症状
+      params = {
+        "age": patInfo.message.patientAge,
+        "inputIds":mainIds&&mainIds.length>0?mainIds:[],//主诉去重
+        "inputStr": inpStr.trim(),
+        "sexType": patInfo.message.sex,
+        "type": boxMark, //1为主诉现病史
+        "itemType":itemType
+      };
+    }else{
+      params = {
+        "age": patInfo.message.patientAge,
+        "inputIds":mainIds&&mainIds.length>0?mainIds:[],//主诉去重
+        "inputStr": inpStr.trim(),
+        // "inputStr": inpStr,
+        "sexType": patInfo.message.sex,
+        "type": boxMark //1为搜症状
+      };
+    }
     return json(api.searchURL,params);
 };