liucf пре 6 година
родитељ
комит
f9874cab84

+ 9 - 49
src/components/MainSuit/index.jsx

@@ -8,12 +8,7 @@ import chooseType from '@containers/eleType.js';
 import config from "@config/index";
 import {isIE,getPageCoordinate,windowEventHandler,filterDataArr} from "@utils/tools.js"
 import $ from 'jquery';
-let clearText = (dom)=>{
-  // console.log(555,dom);
-  if(dom){
-    dom.current.innerText = '';
-  }
-}
+
 class MainSuit extends Component{
   constructor(props){
     super(props);
@@ -34,9 +29,6 @@ class MainSuit extends Component{
       overFlag:false,
       tmpScroll:0,
       tmpTop:0,
-      searchData:props.searchData||[],
-      clearFlag:false,
-      n:0
     };
     this.toggleEditable = this.toggleEditable.bind(this);
     this.handleFocus = this.handleFocus.bind(this);
@@ -48,12 +40,6 @@ class MainSuit extends Component{
   }
   componentWillReceiveProps(nextProps){
     this.setState({boxLeft:nextProps.boxLeft})
-    const {datas,saveText} = this.props;
-    // if(datas.length==0&&nextProps.saveText[0]!=this.props.saveText[0]){
-    if(datas.length==0&&nextProps.saveText[0]){
-      // 引用模板赋值
-      this.$div.current.innerText = nextProps.saveText[0];
-    } 
   }
   toggleEditable(){
     this.setState({
@@ -81,7 +67,6 @@ class MainSuit extends Component{
     e.stopPropagation();
     const {getCommonSymptoms,datas,clearDiagnose} = this.props;
     let innerText = e.target.innerText || e.target.innerHTML;//兼容火狐43
-    console.log(789,innerText);
     clearDiagnose&&clearDiagnose();//清除复诊数据
     if(!isIE()){//IE会触发onfocus和onblur事件
       if(!innerText.trim()){//有内容就走搜索接口
@@ -147,7 +132,6 @@ class MainSuit extends Component{
       return
     }
     // clearTimeout(this.state.timer);
-    this.$div.current.innerText = '';
     if(datas.length==0){//没有使用模板时点击搜索结构要展开模板
       insertSearch &&insertSearch({item,span});
       this.setState({
@@ -249,22 +233,19 @@ 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;
-    let data = ev.target.innerText;
+    let data = this.state.inpText;
     if(!isIE()){
       if(currentData&&currentData.length==0){//现病史没有模板的时候才去获取
-        getSymptomFeature && getSymptomFeature(ev.target.innerText);
+        getSymptomFeature && getSymptomFeature(e.target.innerText);
       } 
-      // ev.target.innerText?(ev.target.innerText=""):(ev.target.innerHTML="")
-      // this.$div.current.innerText = data; 
-      // freeText && freeText(data.trim());
-      freeText && freeText({data:data.trim(),div:this.$div});
+      e.target.innerText?(e.target.innerText=""):(e.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});
+        freeText && freeText(data);
       }
     }
     // 延时关闭常见症状下拉、清空搜索结果,不延时会影响选中
@@ -279,30 +260,10 @@ class MainSuit extends Component{
         clearTimer
       });  
   }
-  /*componentDidMount(){
-    const {datas,saveText} = this.props;
-    let text = this.$div.current?this.$div.current.innerText:'';  
-    // if(datas.length==0&&saveText[0]&& !text){
-      console.log("回读赋值",saveText[0]) ;//数据未更新完成
-    if(datas.length==0&&saveText[0]){
-      this.$div.current.innerText = saveText[0];
-    }
-  }*/
 
-  componentDidUpdate(){   
-    const {datas,saveText,clearAction,refresh} = this.props;
-    if(clearAction){//清除
-      if(clearText){
-        clearText(this.$div);
-        // 更新页面
-        // refresh&&refresh()
-      }
-      clearText = null;
-    }
-  }
 
   render(){
-    const {type,CommonSymptoms,fetchPushInfos,searchData,isRead,totalHide,handleInput,fuzhen,saveText,editClear,datas,commSymHide,boxLeft,boxTop} = this.props;
+    const {type,CommonSymptoms,searchData,fetchPushInfos,isRead,totalHide,handleInput,fuzhen,saveText,editClear,datas,commSymHide,boxLeft,boxTop} = this.props;
     const {showModule,show,symptom,search} = this.state;
     const symptomFlag = CommonSymptoms.length>0 ? true : false;
     const searchFlag = searchData.length>0 ? true : false;
@@ -311,7 +272,6 @@ class MainSuit extends Component{
     }
     return  <div className={`${'mainsuit-box'} ${style['main-suit']}`} id="mainsuitBox">
       <ItemBox 
-      setRef={(el) =>{this.$div = el}}
       fuzhen={fuzhen} 
       title='主诉' 
       editable={editClear||datas.length==0?true:false} 
@@ -322,7 +282,7 @@ class MainSuit extends Component{
       handleBlur={this.handleBlur}
       data={datas}
       boxId="mainSuit">
-        {datas.length>0?<div style={{display:'inline-block'}}>{this.getInlineTag()}</div>:''}
+        {datas.length>0?<div style={{display:'inline-block'}}>{this.getInlineTag()}</div>:(saveText[0]?saveText[0]:'')}
       </ItemBox>
       {/*没有推送结果就不显示*/}
       {symptomFlag && !searchFlag ? <CommonSymptom data={CommonSymptoms} show={!totalHide&&symptom} onSelect={this.handleSelect} /> : ( searchFlag ? <SearchDrop data={searchData} show={!commSymHide} onSelect={this.handleSearchSelect} left={boxLeft} top={boxTop} />:"")}

+ 2 - 5
src/containers/MainSuit.js

@@ -1,7 +1,7 @@
 import React from 'react';
 import { connect } from 'react-redux';
 import MainSuit from '@components/MainSuit';
-import {CLEAR_COMSYMPTOMS,SHOW_TAIL,INSERT_MAIN,CLEAR_SEARCH,SET_SEARCH,SAVE_FREE,SET_DATA,INSERT_SEARCH,SETTEXTMODEVALUE,SET_FEATURE,REFRESH_ITEM} from '@store/types/mainSuit';
+import {CLEAR_COMSYMPTOMS,SHOW_TAIL,INSERT_MAIN,CLEAR_SEARCH,SET_SEARCH,SAVE_FREE,SET_DATA,INSERT_SEARCH,SETTEXTMODEVALUE,SET_FEATURE} from '@store/types/mainSuit';
 import {RESET,CLICKCOUNT,ISREAD,SEARCH_DROP_LOCATION} from '@store/types/homePage.js';
 import {getCommSymptoms,getCommSymptomPush} from '@store/async-actions/mainSuit.js'
 import {SET_MAIN_SUIT} from '@store/types/fillInfo';
@@ -12,7 +12,7 @@ import {filterArr,didPushParamChange,filterDataArr} from '@utils/tools.js';
 import config from '@config/index.js';
 import {Notify} from '@commonComp';
 
-function mapStateToProps(state) {console.log(11,state);
+function mapStateToProps(state) {//console.log(11,state);
   return {
     showDrop:state.mainSuit.showDrop,//用于更新
     update:state.mainSuit.update,
@@ -179,9 +179,6 @@ function mapDispatchToProps(dispatch) {
             data:data
           })
         }
-      },
-      refresh(){
-        dispatch({type:REFRESH_ITEM})
       }
     }
 }

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

@@ -98,7 +98,7 @@ export const insertMain = (state,action) => {
   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].name;
+      items[i].value = '、'+items[i].value;
     } 
   }
   let obj = [];
@@ -111,14 +111,13 @@ export const insertMain = (state,action) => {
         inserIndx = i;
       }
     })
-  // data.splice(inserIndx-1,1,...obj);
-  // 防止没有flag的情况下报错,找不到flag就插到最后
-  inserIndx?data.splice(inserIndx-1,1,...obj):data.splice(-1,0,...obj);
+  data.splice(inserIndx-1,1,...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();
@@ -310,7 +309,7 @@ export const insertSearch = (state,action)=>{
       }
     })
     // flag=1前是文本标签就替换,否则插入
-    const iftext = inserIndx?moduleData[inserIndx-1].tagType:null;
+    const iftext = moduleData[inserIndx-1].tagType;
     if(iftext==config.tagType){
        moduleData.splice(inserIndx-1,1,{id:id,name:searchData,value:searchData,tagType:config.tagType,exist:1});
      }else{
@@ -539,16 +538,13 @@ export const changeNumLabelVal = (state,action)=>{
 export const saveFreeVal = (state,action)=>{
   const res = Object.assign({},state);
   let data = action.data;
-  // res.saveText[0] = data;
-  res.saveText[0] = data.data;
-  res.div = data.div;
+  res.saveText[0] = data;
   /*if(data.trim()){
    res.saveText[0] = data;
   }else{
     res.saveText = [];
   }*/
   // res.update = Math.random();
-  // console.log(345,action,res);
   return res;
 }
 
@@ -566,12 +562,6 @@ export const clearMainSuit = (state,action)=>{//回读和清除
   if(res.data.length > 0){//回读
     res.editClear = false;
   }
-   res.clearAction = action.clearAction;
-  // console.log(345,action,res);
-  if(action.clearAction){//清除
-    res.div?res.div.current.innerText = '':'';
-  }
-  res.update = Math.random();
   return res;
 }
 

+ 1 - 4
src/store/reducers/mainSuit.js

@@ -1,7 +1,7 @@
 import {COMM_SYMPTOMS,CLEAR_COMSYMPTOMS,SHOW_TAIL,INSERT_MAIN,
   SET_SEARCH,CLEAR_SEARCH,GET_BIGDATAPUSH,SET_MAINSUIT,MIX_CONFIRM,NUMBER_SELECT,
   RADIO_SELECT,COMM_CONFIRM,CHANGE_LABELVAL,SAVE_FREE,CLEAR_MAIN_SUIT,SET_DATA,
-  INSERT_SEARCH,MAIN_FOCUS_INDEX,SETTEXTMODEVALUE,SETMAINTEXT,MAINADDLABELITEM,SETMAININPUT,DEL_MAIN,CHANGE_LABELVAL_NUMBER,REMOVE_MAIN_ID,MAINSUIT_MUL,DEL_MAIN_LABLE,SET_FEATURE,REFRESH_ITEM} from '../types/mainSuit'
+  INSERT_SEARCH,MAIN_FOCUS_INDEX,SETTEXTMODEVALUE,SETMAINTEXT,MAINADDLABELITEM,SETMAININPUT,DEL_MAIN,CHANGE_LABELVAL_NUMBER,REMOVE_MAIN_ID,MAINSUIT_MUL,DEL_MAIN_LABLE,SET_FEATURE} from '../types/mainSuit'
 import {getCommSymptoms,handleTailClick,insertMain,setSearch,getBigSymptom,setMainMoudle,confirm,
   setNumberValue,setRadioValue,commConfirm,changeLabelVal,saveFreeVal,clearMainSuit,insertSearch,setTextModeValue,setCheckText,changeEditClear,addLabelItem,setInputLabel,backspaceText,changeNumLabelVal,removeId,multipleComfirn,delSingleLable,getSymptomFeature} from '../actions/mainSuit'
 
@@ -94,9 +94,6 @@ export default function(state=initState,action){
       return delSingleLable(state,action);
     case SET_FEATURE://主诉分词
       return getSymptomFeature(state,action);
-    case REFRESH_ITEM:
-      res.clearAction = false
-      return res;
     default:
       return state;
   }

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

@@ -26,5 +26,4 @@ export const CHANGE_LABELVAL_NUMBER = 'CHANGE_LABELVAL_NUMBER';     //数字键
 export const REMOVE_MAIN_ID = 'REMOVE_MAIN_ID';     //移除id
 export const MAINSUIT_MUL = 'MAINSUIT_MUL';     //单列多选
 export const DEL_MAIN_LABLE = 'DEL_MAIN_LABLE';     
-export const SET_FEATURE = 'SET_FEATURE';  //主诉分词   
-export const REFRESH_ITEM = 'REFRESH_ITEM';  //清除后更新主诉   
+export const SET_FEATURE = 'SET_FEATURE';  //主诉分词