Explorar o código

解决bug1880导致贯标左右移动有问题,已解决

luolei %!s(int64=6) %!d(string=hai) anos
pai
achega
3d5fd574ac

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

@@ -24,6 +24,7 @@ class RadioDrop extends Component{
     this.state={
       editable:false,
       timer:null,
+      tmpDom:null
     };
     this.$cont = React.createRef();
     this.isIE = navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g,"")=="MSIE8.0";
@@ -74,12 +75,15 @@ class RadioDrop extends Component{
     // e.stopPropagation();
     const {handleShow,ikey,id,patId} = this.props;
     const that = this;
-    const timer = setTimeout(function(){
+    const timer = setTimeout(()=>{
       if (that.state.editable) {//如果处于编辑状态点击不显示下拉框
         return
       }else {
         document.activeElement.blur()//chrome41有效,但是失去焦点的span仍能编辑
         $(e.target).parent().prev().attr({"contentEditable":false})
+        this.setState({
+          tmpDom:e.target
+        })
         handleShow && handleShow({ikey,id:patId||id});
       }
     },300);
@@ -134,6 +138,10 @@ class RadioDrop extends Component{
   }
   render(){
     const {data,placeholder,show,value,hideTag,boxMark} = this.props;
+    const {tmpDom} = this.state
+    if(!show&&tmpDom){
+      $(tmpDom).parent().prev().attr({"contentEditable":true})
+    }
     return <div className={style['container']} ref = {this.$cont}>
       <div className={this.getClass()}
            onBlur={this.handleEditLabel}

+ 10 - 2
src/components/RadioInpDrop/index.jsx

@@ -23,7 +23,8 @@ class RadioInpDrop extends Component{
       editable:false,
       timer:null,
       texts:props.vals||{0:props.value||props.placeholder},
-      over:false
+      over:false,
+      tmpDom:null
     };
     this.$cont = React.createRef();
     this.isIE = navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.split(";")[1].replace(/[ ]/g,"")=="MSIE8.0";
@@ -78,12 +79,15 @@ class RadioInpDrop extends Component{
     //e.stopPropagation();
     const {handleShow,ikey,id,patId} = this.props;
     const that = this;
-    const timer = setTimeout(function(){
+    const timer = setTimeout(()=>{
       if (that.state.editable) {//如果处于编辑状态点击不显示下拉框
         return
       }else {
         document.activeElement.blur()//chrome41有效,但是失去焦点的span仍能编辑
         $(e.target).parent().parent().prev().attr({"contentEditable":false})
+        this.setState({
+          tmpDom:e.target
+        })
         handleShow && handleShow({ikey,id:patId||id});
       }
     },300);
@@ -188,6 +192,10 @@ class RadioInpDrop extends Component{
   }
   render(){
     const {data,show,vals,placeholder,hideTag} = this.props;
+    const {tmpDom} = this.state
+    if(!show&&tmpDom){
+      $(tmpDom).parent().parent().prev().attr({"contentEditable":true})
+    }
     return <div className={style['container']} ref = {this.$cont}>
       <div className={this.getClass()}
            onBlur={this.handleEditLabel}

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

@@ -44,6 +44,7 @@ class SpreadDrop extends Component{
       ban:{},  //放'伴'字段
       editable:false,      //双击编辑
       labelVal:'',  //存放标签原有的值--主诉字数限制用
+      tmpDom:null
     };
     this.$div = React.createRef();
     this.handleSelect = this.handleSelect.bind(this);
@@ -72,12 +73,15 @@ class SpreadDrop extends Component{
     const that = this;
     this.btnClickFlag = false;
     clearTimeout(this.state.timer);
-    this.state.timer = setTimeout(function(){
+    this.state.timer = setTimeout(()=>{
       if (that.state.editable) {//如果处于编辑状态点击不显示下拉框
         return
       }else{
         document.activeElement.blur()//chrome41有效,但是失去焦点的span仍能编辑
         $(e.target).parent().prev().attr({"contentEditable":false})
+        this.setState({
+          tmpDom:e.target
+        })
         handleShow&&handleShow({ikey,placeholder,flag,id,value,tagType,type});
       }
     },300)
@@ -338,6 +342,10 @@ class SpreadDrop extends Component{
 
   render(){
     const {placeholder,value,show,data,order} = this.props;
+    const {tmpDom} = this.state
+    if(!show&&tmpDom){
+      $(tmpDom).parent().prev().attr({"contentEditable":true})
+    }
     const {editable} = this.state;
     return  <div className={style['container']}
               onFocus={(e)=>e.stopPropagation()}