浏览代码

输入组件不可双击编辑

zhouna 5 年之前
父节点
当前提交
f3160889fa
共有 2 个文件被更改,包括 4 次插入68 次删除
  1. 4 43
      src/common/components/InlineTag/index.jsx
  2. 0 25
      src/containers/InlineTag.js

+ 4 - 43
src/common/components/InlineTag/index.jsx

@@ -15,49 +15,16 @@ import {handleEnter} from '@utils/tools.js';
 class InlineTag extends Component {
   constructor(props){
     super(props);
-    this.$box = React.createRef();
     this.$span = React.createRef();
-    this.$pre = React.createRef();
-    this.$suf = React.createRef();
     this.state = {
-      editable:false,
       value:props.value||'',
       placeholder:props.placeholder||''
     };
-    this.changeToEdit = this.changeToEdit.bind(this);
-    this.changeToClick = this.changeToClick.bind(this);
     this.handleBlur = this.handleBlur.bind(this);
     this.handleInput = this.handleInput.bind(this);
     this.handleFocus = this.handleFocus.bind(this);
     this.handleFixClick = this.handleFixClick.bind(this);
   }
-  changeToEdit(e){
-    const {handledbClick,id} = this.props;
-    // 输入框有值才可以双击编辑
-    const text = this.$span.current.innerText;
-    if(!text.trim()){
-      return
-    }
-    this.setState({
-      editable:true
-    });
-    //埋点记录
-    handledbClick&&handledbClick({id});
-  }
-  changeToClick(e){
-    e.stopPropagation();
-    const {saveEditText,ikey} = this.props;
-    this.setState({
-      editable:false
-    });
-    saveEditText&&saveEditText({
-      changeVal:this.$span.current.innerText,
-      totalVal:this.$box.current.innerText,
-      prefix:this.$pre.current.innerText,
-      suffix:this.$suf.current.innerText,
-      ikey
-    });
-  }
   handleInput(e){       //输入时保存临时值,在修改灰显为黑色时判断用
     e.stopPropagation();
   }
@@ -125,24 +92,18 @@ class InlineTag extends Component {
   }
   render(){
     const {prefix,suffix} = this.props;
-    const {editable,placeholder,value} = this.state;
+    const {placeholder,value} = this.state;
     return <div className={this.getStyle()}
-                 onDoubleClick={this.changeToEdit}
-                 /*onClick={!editable?this.handleFixClick:''}*/
-                 onKeyDown={handleEnter}
-                 onBlur={this.changeToClick} 
-                 ref={this.$box} 
-                 contentEditable={editable}>
-                <span ref={this.$pre}>&nbsp;{prefix}</span>
+                onClick={this.handleFixClick}>
+                <span>{prefix}</span>
                 <span className={style['free-in']}
                       contentEditable={true}
                       onBlur={this.handleBlur}
                       onInput={this.handleInput}
                       onFocus={this.handleFocus}
-                      /*onClick={e=>e.stopPropagation()}*/
                       onKeyDown={handleEnter}
                       ref={this.$span}>&nbsp;{value||placeholder}</span>
-                <span ref={this.$suf}>&nbsp;{suffix}</span>
+                <span>{suffix}</span>
             </div>;
     }
 }

+ 0 - 25
src/containers/InlineTag.js

@@ -6,7 +6,6 @@ import {SETCURRENTINPUT,CURRENT_TEXT_LABEL} from '@types/currentIll';
 import {SETCHECKINPUT} from "@types/checkBody";
 import InlineTag from "../common/components/InlineTag";
 import {getLabelIndex} from '@utils/tools.js';
-import {CLICKCOUNT} from '@types/homePage.js';
 import {CHANGEOTHERTEXTLABEL} from "../store/types/otherHistory";
 import {CHANGECHECKTEXTLABEL} from "../store/types/checkBody";
 import {CHANGE_LABELVAL} from "../store/types/mainSuit";
@@ -22,13 +21,6 @@ const tagInpActions = {
   4:SETCHECKINPUT
 };
 
-const inpEditActions = {
-  1:CHANGE_LABELVAL,
-  2:CURRENT_TEXT_LABEL,
-  3:CHANGEOTHERTEXTLABEL,
-  4:CHANGECHECKTEXTLABEL
-};
-
 function mapDispatchToProps(dispatch,store){
   return {
     handleInput(params) {
@@ -45,23 +37,6 @@ function mapDispatchToProps(dispatch,store){
         subIndex:inner
       })
     },
-    handledbClick(obj){
-      dispatch({
-        type:CLICKCOUNT,
-        data:obj,
-        clickType:'双击',
-        num:1
-      });
-    },
-    saveEditText(obj){
-      const i = getLabelIndex(obj.ikey);
-      const type = obj.ikey.substr(0,1);
-      obj.ikey = i;
-      dispatch({
-        type:inpEditActions[type],
-        data:obj
-      })
-    }
   }
 }