Browse Source

选中删除bug修改2802

zhouna 5 years ago
parent
commit
1fd456cc0e

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

@@ -342,6 +342,7 @@ class EditableSpan extends Component{
   selectEnd(){
     const {i,setSelectArea,boxMark}= this.props;
     setSelectArea({i,boxMark,dir:'end'});
+    window.getSelection().empty();
   }
   getClass(){
     const {full,value,saveText,i,preIsExt,afterIsExt,mouseSelect} = this.props;

+ 2 - 8
src/components/MultSpread/index.jsx

@@ -240,12 +240,6 @@ class MultSpread extends Component{
     });
     return list;
   }
-  handleMouseUp(){
-    const {select_start,i,setSelectArea,boxMark}= this.props;
-    if(select_start!==undefined){
-      setSelectArea({i,boxMark,dir:'end'});
-    }
-  }
   handleMouseDown(){
     const {i,setSelectArea,boxMark}= this.props;
     setSelectArea({i,boxMark,dir:'start'});
@@ -261,7 +255,7 @@ class MultSpread extends Component{
     }
   }
   getContClass(){
-    const {isImports,ikey,saveText,isExtBlue,mouseSelect} = this.props;
+    const {isImports,ikey,saveText,isExtBlue,mouseSelect,select_start,i,boxMark} = this.props;
     const labelInx = tools.getLabelIndex(ikey);
     const text = saveText&&saveText[+labelInx];
     const ext = !text&&isExtBlue?style['ext']:'';
@@ -273,7 +267,7 @@ class MultSpread extends Component{
     const {showAdd,addLabelItem,ikey,copyId,textPrefix,textSuffix,isExtBlue} = this.props;
     return (<div className={this.getContClass()}
                  style={{display:'inline-block'}}
-                 onMouseUp={this.handleMouseUp.bind(this)}
+                 onMouseUp={()=>handleMouseUp({select_start,i,boxMark})}
                  onMouseDown={this.handleMouseDown.bind(this)}>
         {textPrefix?<span className="prefixUnset">{textPrefix}</span>:''}
         <div className={this.getClass()}>

+ 3 - 9
src/components/Multiple/index.jsx

@@ -2,7 +2,7 @@ import react from "react";
 import style from "./index.less";
 import $ from 'jquery';
 import classNames from 'classnames';
-import {handleEnter,isIE,filterArr,deepClone,filterDataArr,setFontColorSize} from '@utils/tools.js';
+import {handleEnter,isIE,filterArr,deepClone,filterDataArr,setFontColorSize,handleMouseUp} from '@utils/tools.js';
 import {Notify} from '@commonComp';
 import SlideItem from "./SlideItem";
 import config from '@config/index.js';
@@ -161,12 +161,6 @@ class Multiple extends react.Component{
     handleConfirm&&handleConfirm(params);
     handleHide&&handleHide();
   }
-  handleMouseUp(){
-    const {select_start,i,setSelectArea,boxMark}= this.props;
-    if(select_start!==undefined){
-      setSelectArea({i,boxMark,dir:'end'});
-    }
-  }
   handleMouseDown(){
     const {i,setSelectArea,boxMark}= this.props;
     setSelectArea({i,boxMark,dir:'start'});
@@ -179,7 +173,7 @@ class Multiple extends react.Component{
     }
   }
   render(){
-    const {placeholder,value,show,data,hideTag} = this.props;
+    const {placeholder,value,show,data,hideTag,select_start,i,boxMark} = this.props;
     const {editable,seleData,seleId} = this.state;
     return <div className={style["container"]}>
       <div className={this.getClass()}
@@ -189,7 +183,7 @@ class Multiple extends react.Component{
       onBlur={this.handleBlur}
       onInput={this.onChange}
       onKeyDown={handleEnter}
-      onMouseUp={this.handleMouseUp.bind(this)}
+      onMouseUp={()=>handleMouseUp({select_start,i,boxMark})}
       onMouseDown={this.handleMouseDown.bind(this)}
       contentEditable={editable}>{value||placeholder}</div>
       <div className={this.getListClass()} contentEditable="false">

+ 3 - 9
src/components/NumberDrop/index.jsx

@@ -2,7 +2,7 @@ import React,{Component} from 'react';
 import className from 'classnames';
 import {NumberPan,Notify} from '@commonComp';
 import style from './index.less';
-import {setFontColorSize} from '@utils/tools'
+import {setFontColorSize,handleMouseUp} from '@utils/tools'
 /***
  * author:zn@2018-11-19
  * 接收参数:
@@ -218,12 +218,6 @@ class NumberDrop extends Component{
   stopBubble(e){
     e.stopPropagation();
   }
-  handleMouseUp(){
-    const {select_start,i,setSelectArea,boxMark}= this.props;
-    if(select_start!==undefined){
-      setSelectArea({i,boxMark,dir:'end'});
-    }
-  }
   handleMouseDown(){
     const {i,setSelectArea,boxMark}= this.props;
     setSelectArea({i,boxMark,dir:'start'});
@@ -259,13 +253,13 @@ class NumberDrop extends Component{
     });
   }
   render(){
-    const {prefix,suffix,show,value,handleHide,allClick,bmi,formulaCode,nospecial,isSelectAll,isExtBlue} = this.props;
+    const {prefix,suffix,show,value,handleHide,allClick,bmi,formulaCode,nospecial,isSelectAll,isExtBlue,select_start,i,boxMark} = this.props;
     const val = formulaCode==="BMI_RES"?(+bmi===Infinity||isNaN(bmi)?'':bmi):value;
     const {placeholder,hasSelect} = this.state;
     return <div className={this.getClasses(nospecial)}
                 style={{position:'relative'}}
                 onClick={allClick?this.handleNumClick:null}
-                onMouseUp={this.handleMouseUp.bind(this)}
+                onMouseUp={()=>handleMouseUp({select_start,i,boxMark})}
                 onMouseDown={this.handleMouseDown.bind(this)}>
       <span className={`${setFontColorSize(val?'':isSelectAll?2:isExtBlue?2:1)} prefixUnset`}>{prefix}</span>
       <span onFocus={this.handleNumFocus}

+ 3 - 10
src/components/NumberUnitDrop/index.jsx

@@ -3,7 +3,7 @@ import className from 'classnames';
 import {NumberUnitPan} from '@commonComp';
 import style from './index.less';
 import config from '@config/index.js';
-import {filterArr,handleEnter,isIE,filterDataArr,setFontColorSize} from '@utils/tools.js';
+import {filterArr,handleEnter,isIE,filterDataArr,setFontColorSize,handleMouseUp} from '@utils/tools.js';
 import {Notify} from '@commonComp';
 import $ from 'jquery';
 /***
@@ -67,13 +67,6 @@ class NumberUnitDrop extends Component{
     });
     handleHide&&handleHide();
   }
-
-  handleMouseUp(){
-    const {select_start,i,setSelectArea,boxMark}= this.props;
-    if(select_start!==undefined){
-      setSelectArea({i,boxMark,dir:'end'});
-    }
-  }
   handleMouseDown(){
     const {i,setSelectArea,boxMark}= this.props;
     setSelectArea({i,boxMark,dir:'start'});
@@ -103,11 +96,11 @@ class NumberUnitDrop extends Component{
   }
 
   render(){
-    const {placeholder,prefix,suffix,show,value,handleHide,hideTag,isExtBlue} = this.props;
+    const {placeholder,prefix,suffix,show,value,handleHide,select_start,i,boxMark} = this.props;
     const {editable,hasSelect} = this.state;
     return <div className={this.getClasses()}
                 ref={this.$cont}
-                onMouseUp={this.handleMouseUp.bind(this)}
+                onMouseUp={()=>handleMouseUp({select_start,i,boxMark})}
                 onMouseDown={this.handleMouseDown.bind(this)}
                 onClick={this.handleNumClick}>
       <span ref = {this.$pre} className="prefixUnset">{prefix?prefix+' ':prefix}</span>

+ 3 - 9
src/components/RadioDrop/index.jsx

@@ -1,5 +1,5 @@
 import React,{Component} from 'react';
-import {handleEnter,windowEventHandler,setFontColorSize} from '@utils/tools.js';
+import {handleEnter,windowEventHandler,setFontColorSize,handleMouseUp} from '@utils/tools.js';
 import {DropList} from '@commonComp';
 import classNames from 'classnames';
 import style from "./index.less";
@@ -149,18 +149,12 @@ class RadioDrop extends Component{
     })
     handleDbclick&&handleDbclick({id:patId||id});
   }
-  handleMouseUp(){
-    const {select_start,i,setSelectArea,boxMark}= this.props;
-    if(select_start!==undefined){
-      setSelectArea({i,boxMark,dir:'end'});
-    }
-  }
   handleMouseDown(){
     const {i,setSelectArea,boxMark}= this.props;
     setSelectArea({i,boxMark,dir:'start'});
   }
   render(){
-    const {data,placeholder,show,value,hideTag,boxMark} = this.props;
+    const {data,placeholder,show,value,hideTag,boxMark,select_start,i} = this.props;
     const {tmpDom} = this.state
     if(!show&&tmpDom){
       $(tmpDom).parent().prev().attr({"contentEditable":true})
@@ -172,7 +166,7 @@ class RadioDrop extends Component{
            onDoubleClick={hideTag?null:this.handledbClick}
            onFocus={(e)=>{e.stopPropagation()}}
            onClick={(e)=>this.handleShow(e,true)}
-           onMouseUp={this.handleMouseUp.bind(this)}
+           onMouseUp={()=>handleMouseUp({select_start,i,boxMark})}
            onMouseDown={this.handleMouseDown.bind(this)}
            onKeyDown={handleEnter}>
         {value||placeholder}

+ 3 - 9
src/components/RadioInpDrop/index.jsx

@@ -1,5 +1,5 @@
 import React,{Component} from 'react';
-import {handleEnter,windowEventHandler,filterDataArr,getLabelIndex,setFontColorSize} from '@utils/tools.js';
+import {handleEnter,windowEventHandler,filterDataArr,getLabelIndex,setFontColorSize,handleMouseUp} from '@utils/tools.js';
 import {DropList,Notify} from '@commonComp';
 import config from '@config/index';
 import style from "./index.less";
@@ -96,12 +96,6 @@ class RadioInpDrop extends Component{
     });
     handleSaveInp({values:vals,ikey,boxMark,mainSaveText});
   }
-  handleMouseUp(){
-    const {select_start,i,setSelectArea,boxMark}= this.props;
-    if(select_start!==undefined){
-      setSelectArea({i,boxMark,dir:'end'});
-    }
-  }
   handleMouseDown(){
     const {i,setSelectArea,boxMark}= this.props;
     setSelectArea({i,boxMark,dir:'start'});
@@ -129,11 +123,11 @@ class RadioInpDrop extends Component{
     return list;
   }
   render(){
-    const {data,show,vals,placeholder} = this.props;
+    const {data,show,vals,placeholder,select_start,i,boxMark} = this.props;
     return <div className={style['container']} ref = {this.$cont}>
       <div className={this.getClass()}
            onClick={(e)=>this.handleShow(e)}
-           onMouseUp={this.handleMouseUp.bind(this)}
+           onMouseUp={()=>handleMouseUp({select_start,i,boxMark})}
            onMouseDown={this.handleMouseDown.bind(this)}
            onKeyDown={handleEnter}>
         {vals?this.parseInputDom():<span className='inheritStyle'>{placeholder}</span>}

+ 3 - 9
src/components/SpreadDrop/index.jsx

@@ -2,7 +2,7 @@ import React,{Component} from 'react';
 import classNames from 'classnames';
 import config from '@config/index.js';
 import style from './index.less';
-import {setPosition,deepClone,handleEnter,isIE,windowEventHandler,filterDataArr,getIds,getPageCoordinate,setFontColorSize} from '@utils/tools.js';
+import {setPosition,deepClone,handleEnter,isIE,windowEventHandler,filterDataArr,getIds,getPageCoordinate,setFontColorSize,handleMouseUp} from '@utils/tools.js';
 import {Notify} from '@commonComp';
 import ListItems from '@components/ListItems';
 import CommonSymptom from '@components/CommonSymptom';
@@ -374,12 +374,6 @@ class SpreadDrop extends Component{
     const showDefaulted = ((type=='2'&&curDefault)||(type=='3'&&otherDefault))&&showVal;
     return showDefaulted;
   }
-  handleMouseUp(){
-    const {select_start,i,setSelectArea,boxMark}= this.props;
-    if(select_start!==undefined){
-      setSelectArea({i,boxMark,dir:'end'});
-    }
-  }
   handleMouseDown(){
     const {i,setSelectArea,boxMark}= this.props;
     setSelectArea({i,boxMark,dir:'start'});
@@ -392,7 +386,7 @@ class SpreadDrop extends Component{
     }
   }
   render(){
-    const {placeholder,value,show,data,order,type,tagType,pos,defaulted,showVal,CommonSymptoms} = this.props;
+    const {placeholder,value,show,data,order,type,tagType,pos,defaulted,showVal,CommonSymptoms,select_start,i,boxMark} = this.props;
     const {tmpDom,left} = this.state;
     let showDefaulted = this.ifDefault();
     let showV = showDefaulted&&value===undefined?showVal:value;       //未选中过值时展示默认选中
@@ -414,7 +408,7 @@ class SpreadDrop extends Component{
         onBlur={this.handleBlur}
         onInput={this.onChange}
         onkeydown={handleEnter}
-        onMouseUp={this.handleMouseUp.bind(this)}
+        onMouseUp={()=>handleMouseUp({select_start,i,boxMark})}
         onMouseDown={this.handleMouseDown.bind(this)}
         >{showV||placeholder}</div>
       {showCommonData&&show?<CommonSymptom data={CommonSymptoms} show={true} onSelect={this.handleCommonSelect.bind(this)} isCurrent={true} />:

+ 14 - 2
src/utils/tools.js

@@ -7,7 +7,7 @@ import {clearAssistData,addAssistLabel} from '@store/actions/assistCheck';
 import {clearAllLabel,addLabel} from '@store/actions/inspect';
 import {CLEAR_ALL_DIAG} from '@store/types/diagnosticList';
 import {CLEAR_ALL_PUSH_MESSAGE, SET_TIPS,BILLING_ADVICE,PUSHCHANGE} from '@store/types/pushMessage';
-import {ISREAD, SETREADDITEMS} from "../store/types/homePage";
+import {ISREAD, SETREADDITEMS,SET_SELECTED_AREA} from "../store/types/homePage";
 import {CLEAR_FIRST_MAIN_DIAG, CLEAR_ALL_TREAT} from "../store/types/treat";
 import {tabChange} from '@store/actions/tabTemplate';
 import {CLEAR_ASSESS_RESULT_VALUE} from '@types/assessResult';
@@ -1529,6 +1529,17 @@ function removeRepeat(arr1,arr2){     //arr1被完全保留的数组
   return arr;
 }
 
+function handleMouseUp(param){
+  const {select_start,i,boxMark}= param;
+  if(select_start!==undefined){
+    store.dispatch({
+      type:SET_SELECTED_AREA,
+      data:{i,boxMark,dir:'end'}
+    });
+    window.getSelection().empty();
+  }
+}
+
 module.exports = {
     getIds,
     getWindowInnerWidth,
@@ -1583,5 +1594,6 @@ module.exports = {
     moveEnd,
     setFontColorSize,
     getValuedLabels,
-    removeRepeat
+    removeRepeat,
+    handleMouseUp
 };