Browse Source

Squashed commit of the following:

commit 98d1183a309c2931971ffe368960a889fb7a6e59
Author: liucf <liucf@zjlantone.com>
Date:   Sat Aug 17 10:40:19 2019 +0800

    常见症状最近使用添加完成

commit 1361683e6084590dc808df84fd8884f000fa1ae3
Author: liucf <liucf@zjlantone.com>
Date:   Fri Aug 16 18:02:46 2019 +0800

    主诉常见症状排序(缺搜索)
liucf 5 năm trước cách đây
mục cha
commit
72e6f1dd47

+ 13 - 2
src/components/CommonSymptom/index.jsx

@@ -2,6 +2,7 @@ import React,{Component} from 'react';
 import classNames from 'classnames';
 import $ from 'jquery';
 import style from "./index.less";
+import {storageLocal} from "@utils/tools.js";
 /**
  * author: Liucf
  * 主诉常见症状下拉--修改为横铺多选(3.13)
@@ -33,7 +34,7 @@ class CommonSymptom extends Component{
   handleSelect(e,item){
     e.stopPropagation();
     let {select,ids,conceptId} = this.state;
-    const id = item.questionId
+    const id = item.questionId||item.id; //缓存localStorage中的数据有id
     const copid = item.conceptId
     if(conceptId.includes(copid)){
       conceptId.splice(conceptId.indexOf(copid),1);
@@ -88,8 +89,9 @@ class CommonSymptom extends Component{
       let itemBox = $('#mainSuit')[0];
       let divBox = $('#symptBox')[0];
       let listBox = $('#listBox')[0];
+      let hisBox = $('#his')[0];
       let operBox = $('#oper')[0];
-      if(e.target != itemBox && e.target.parentNode != divBox && e.target.parentNode != listBox && e.target.parentNode != operBox && e.target != divBox){
+      if(e.target != itemBox && e.target.parentNode != divBox && e.target.parentNode != listBox && e.target.parentNode != hisBox && e.target.parentNode != operBox && e.target != divBox){
         this.setState({
           hide:true,
           select:[],
@@ -107,8 +109,17 @@ class CommonSymptom extends Component{
   render(){ 
     const {data} = this.props;
     const {hide} = this.state;
+    const mainSymp = storageLocal.get('mainSymp');
+    const mainHis = mainSymp?JSON.parse(mainSymp).reverse():[];
     return <div className={this.getClass()} contenteditable="false" id="symptBox" style={{'display':hide?'none':'block'}}>
       <ul className={style["listBox"]} id="listBox">
+        {mainHis.length>0?<ul className={style["his"]} id="his">
+          <p>历史搜索:</p>
+          {mainHis.map((it)=>{
+            return <li onClick={(e)=>this.handleSelect(e,it)} className={this.getStyle(it.conceptId)} title={it.name.length>5?it.name:''}>{it.name.length>5?it.name.slice(0,4)+'...':it.name}</li>
+          })}
+        </ul>:''}
+        
         {data&&data.map((it)=>{
           return <li onClick={(e)=>this.handleSelect(e,it)} className={this.getStyle(it.conceptId)} title={it.name.length>5?it.name:''}>{it.name.length>5?it.name.slice(0,4)+'...':it.name}</li>
         })}

+ 8 - 0
src/components/CommonSymptom/index.less

@@ -7,6 +7,14 @@
   .listBox{
     max-width: 460px;
   }
+  .his{
+    color: #777777;
+    border-bottom: 1px solid #EAEDF1;
+    p{
+      line-height: 32px;
+      padding-left: 15px;
+    }
+  }
   li{
     width: 85px;
     line-height: 32px;

+ 97 - 4
src/store/actions/mainSuit.js

@@ -1,4 +1,4 @@
-import {getLabelIndex,fullfillText,getIds,resetTagtype} from '@utils/tools.js';
+import {getLabelIndex,fullfillText,getIds,resetTagtype,storageLocal} from '@utils/tools.js';
 import config from '@config/index.js';
 import {Notify} from '@commonComp';
 
@@ -109,15 +109,47 @@ export const insertMain = (state,action) => {
   const id = action.item.ids;
   const conceptId = action.item.conceptId;
   let data = JSON.parse(JSON.stringify(res.moduleData));
+
+  // 存到本地
+    // >5直接截取替换,<5需要判断是否有重复的--双重遍历
+    const mainSymp = storageLocal.get('mainSymp');
+    if(items.length<5){
+      if(mainSymp){
+        let localArr = JSON.parse(mainSymp);
+        let sympArr = JSON.parse(JSON.stringify(localArr));
+        let num = -1;
+        for(let k=0; k<localArr.length; k++){//判断是否已存在
+          for(let j=0; j<items.length; j++){
+            if(localArr[k].conceptId==items[j].conceptId){
+              num++
+              sympArr.splice(k-num,1);
+            }
+          }
+        }
+        let newArr = sympArr.concat(items);
+        if(newArr.length>5){
+          storageLocal.set('mainSymp',newArr.slice(newArr.length-5,));
+        }else{
+          storageLocal.set('mainSymp',newArr);
+        }  
+      }else{
+        storageLocal.set('mainSymp',items);
+      }
+    }else{
+      let seleArr = items.slice(items.length-5,);//展示后5个
+      storageLocal.set('mainSymp',seleArr);
+    }
+
   if(items.length>1){
     for(let i=1; i<items.length; i++){
       items[i].name = '、'+items[i].name;
-      items[i].value = '、'+items[i].value;
-    } 
+      // items[i].value = '、'+items[i].value;
+      items[i].value = items[i].value?'、'+items[i].value:items[i].name;
+    }
   }
   let obj = [];
   for(let i=0; i<items.length; i++){
-    obj.push({id:items[i].questionId,name:items[i].name,value:items[i].name,tagType:config.tagType,exist:1,conceptId:items[i].conceptId});
+    obj.push({id:items[i].questionId||items[i].id,name:items[i].name,value:items[i].name,tagType:config.tagType,exist:1,conceptId:items[i].conceptId});
   }
   let inserIndx = null;
   data.map((it,i)=>{
@@ -163,6 +195,43 @@ export const confirm = (state,action) =>{
   let arr = res.data;
   let saveText = JSON.parse(JSON.stringify(res.saveText));
   const {exists,withs,ikey,withsName,existsName,ban} = action.data;
+    // 存到本地
+    // >5直接截取替换,<5需要判断是否有重复的--双重遍历
+    const items = exists.concat(withs);
+    const mainSymp = storageLocal.get('mainSymp');
+    if(items.length<5){
+      if(mainSymp){
+        let localArr = JSON.parse(mainSymp);
+        let sympArr = JSON.parse(JSON.stringify(localArr));
+        let num = -1;
+        for(let k=0; k<localArr.length; k++){//判断是否已存在
+          for(let j=0; j<items.length; j++){
+            items[j].exist = 1;
+            if(localArr[k].conceptId==items[j].conceptId){
+              num++
+              sympArr.splice(k-num,1);
+            }
+          }
+        }
+        let newArr = sympArr.concat(items);
+        if(newArr.length>5){
+          storageLocal.set('mainSymp',newArr.slice(newArr.length-5,));
+        }else{
+          storageLocal.set('mainSymp',newArr);
+        }
+        
+      }else{
+        storageLocal.set('mainSymp',items);
+      }
+    }else{
+      // let seleArr = items.slice(0,5);
+      let seleArr = items.slice(items.length-5,);//展示后5个
+      for(let n=0; n<seleArr.length; n++){
+        seleArr[n].exist = 1;//将伴随都改成主症状
+      }
+      storageLocal.set('mainSymp',seleArr);
+    }
+
   let banText = JSON.stringify(ban) == "{}" ? '':{id:ban.id,name:ban.name,value:ban.name,tagType:config.tagType};
   let length = exists.length;
   let existConpId = [];
@@ -338,6 +407,30 @@ export const insertSearch = (state,action)=>{
   let span = action.span;
   let text = {id:id,name:searchData,value:searchData,tagType:config.tagType,conceptId:ids};
   const emptySpan = JSON.parse(config.textLabel);
+
+    // 存到本地
+    const mainSymp = storageLocal.get('mainSymp');
+    let items = JSON.parse(JSON.stringify(action.info));
+    if(mainSymp){
+      let localArr = JSON.parse(mainSymp);
+      let sympArr = JSON.parse(JSON.stringify(localArr));
+      for(let k=0; k<localArr.length; k++){//判断是否已存在
+        if(localArr[k].conceptId==items.conceptId){
+          sympArr.splice(k,1);
+        }
+      }
+      sympArr.push(items);
+      if(sympArr.length>5){
+        storageLocal.set('mainSymp',sympArr.slice(sympArr.length-5,));
+      }else{
+        storageLocal.set('mainSymp',sympArr);
+      }
+    }else{
+      let arr = [];
+      arr.push(items);
+      storageLocal.set('mainSymp',arr);
+    }
+    
   if(data.length==0){   
     let inserIndx = null;
     moduleData.map((it,i)=>{

+ 2 - 2
src/utils/config.js

@@ -1,8 +1,8 @@
 // const host='http://192.168.3.1:5050';//赵
 // const host='http://192.168.3.100:5050';//王峰
-// const host='http://192.168.2.236:5050';//后端接口访问地址
+const host='http://192.168.2.236:5050';//后端接口访问地址
 // const host='http://192.168.2.121:5050';//后端接口访问地址
-const host='http://192.168.2.241:5050';//后端接口访问地址
+// const host='http://192.168.2.241:5050';//后端接口访问地址
 // const host='http://192.168.3.11:5050';//王宇
 //const host='http://192.168.2.164:8080';
 // const host='http://192.168.3.117:5050'; //周铁刚