Forráskód Böngészése

血压类组合组件不可双击编辑

zhouna 5 éve
szülő
commit
0e54c5a014
2 módosított fájl, 8 hozzáadás és 81 törlés
  1. 3 42
      src/components/MultSpread/index.jsx
  2. 5 39
      src/containers/MultSpread.js

+ 3 - 42
src/components/MultSpread/index.jsx

@@ -33,12 +33,8 @@ class MultSpread extends Component{
   constructor(props){
     super(props);
     this.state = {
-      editable: false,
       numDoms:[]
     };
-    this.$cont = React.createRef();
-    this.changeToEdit = this.changeToEdit.bind(this);
-    this.handleEdit = this.handleEdit.bind(this);
   }
   getClass(){
     const {saveText,ikey,showAdd} = this.props;
@@ -76,12 +72,11 @@ class MultSpread extends Component{
   }
   getLabels(){
     const {data,ikey,showArr,copyId,selecteds,boxMark} = this.props;
-    const {editable}= this.state;
     let show = false;
     let inx = '',count=0;
     const list = data.map((it,i)=>{
       inx=ikey+'-'+i;
-      show = editable?false:showArr&&showArr[inx];
+      show = showArr&&showArr[inx];
       switch (true){
         case +it.tagType===8:
           return it.name;
@@ -166,33 +161,6 @@ class MultSpread extends Component{
     });
     return list;
   }
-  changeToEdit(e){
-    const {name,copyId,ikey,placeholder,handleDbclick,saveText,prefix,suffix} = this.props;
-    const labelInx = tools.getLabelIndex(ikey);
-    const text = saveText&&saveText[+labelInx];
-    //clearTimeout(this.state.timer);//取消延时的单击事件
-    e.preventDefault();
-    if(text&&text.trim()) {//有选中值的标签才能双击编辑
-      this.setState({
-        editable: true
-      });
-      //失焦关闭编辑状态
-      setTimeout(()=>{
-        this.$cont.current.focus();
-      });
-      //双击埋点记录
-      handleDbclick && handleDbclick({id:copyId});
-    }
-  }
-  handleEdit(e){
-    const {saveEditText,ikey} = this.props;
-    if(!this.state.editable) return;
-    this.setState({
-      editable: false
-    });
-    let totalVal = e.target.innerText || e.target.innerHTML;
-    saveEditText && saveEditText({ikey,type:ikey.split("-")[0],totalVal});
-  }
   componentDidMount(){
     //挂载完成保存有加号的项目数据
     const {saveAddItem,fullData,copyId,showAdd} = this.props;
@@ -204,23 +172,16 @@ class MultSpread extends Component{
     }
   }
   getContClass(){
-    const {editable} = this.state;
     const {isImports,ikey,saveText} = this.props;
     const labelInx = tools.getLabelIndex(ikey);
     const text = saveText&&saveText[+labelInx];
     const orgBorder = isImports&&!text?style['orange-border']:'';
-    const edit = editable?style['blue-border']:'';
-    return classNames(edit,orgBorder);
+    return classNames(orgBorder);
   }
   render(){
     const {showAdd,addLabelItem,ikey,copyId,textPrefix,textSuffix} = this.props;
     return (<div className={this.getContClass()}
-                 style={{display:'inline-block'}}
-                 onDoubleClick={this.changeToEdit}
-                 ref = {this.$cont}
-                 contentEditable={this.state.editable}
-                 onBlur={this.handleEdit}
-                 onKeyDown={tools.handleEnter}>
+                 style={{display:'inline-block'}}>
       {textPrefix?<span>{textPrefix}</span>:''}
       <div className={this.getClass()}>
       {this.getLabels()}

+ 5 - 39
src/containers/MultSpread.js

@@ -1,11 +1,11 @@
 import React from 'react';
 import {connect} from 'react-redux';
 import MultSpread from "@components/MultSpread";
-import {SETSELECTED,CLEARSELECTED,CONFIRMSELECTED,CHANGEOTHERTEXTLABEL,OTHERADDLABELITEM} from '@types/otherHistory';
-import {CHANGECHECKTEXTLABEL,ADDLABELITEM} from '@types/checkBody.js';
-import {CHANGE_LABELVAL,MAINADDLABELITEM} from '@store/types/mainSuit.js';
-import {CURRENTADDLABELITEM,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
-import {HIDE,RESET,CLICKCOUNT,SETADDITEMINIT,ISREAD} from '@store/types/homePage.js';
+import {OTHERADDLABELITEM} from '@types/otherHistory';
+import {ADDLABELITEM} from '@types/checkBody';
+import {MAINADDLABELITEM} from '@store/types/mainSuit';
+import {CURRENTADDLABELITEM} from '@store/types/currentIll';
+import {HIDE,RESET,CLICKCOUNT,SETADDITEMINIT,ISREAD} from '@store/types/homePage';
 
 function mapStateToProps(state){
   return {}
@@ -34,15 +34,6 @@ const getCopyData = (copyId,inx,boxMark)=>{
   }
 };
 
-/**************************双击标签输入*********************************/
-
-const editTypes={
-  1:CHANGE_LABELVAL,      //主诉
-  2:CURRENT_TEXT_LABEL,                   //现病史
-  3:CHANGEOTHERTEXTLABEL,  //其他史
-  4:CHANGECHECKTEXTLABEL    //查体
-};
-
 function mapDispatchToProps(dispatch){
   return {
     resetHide(){
@@ -50,14 +41,6 @@ function mapDispatchToProps(dispatch){
         type: RESET
       })
     },
-    handleDbclick(obj){
-      dispatch({
-        type:CLICKCOUNT,
-        data:obj,
-        clickType:'双击',
-        num:1
-      });
-    },
     saveAddItem(id,data){      //保存有加号的标签原始数据
       dispatch({
         type:SETADDITEMINIT,
@@ -78,16 +61,6 @@ function mapDispatchToProps(dispatch){
       });
       dispatch(getCopyData(copyId,inx,boxMark));
     },
-    saveEditText(params){
-      const {type} = params;
-      const index = params.ikey;
-      let ikey = index.split("-")[1];
-      const {changeVal,totalVal} = params;
-      dispatch({
-        type:editTypes[+type],
-        data:{changeVal:changeVal,ikey:ikey,totalVal}
-      });
-    },
     handleClick(obj){
       dispatch({
         type:CLICKCOUNT,
@@ -96,13 +69,6 @@ function mapDispatchToProps(dispatch){
         num:1
       });
     }
-    /*handleConfirm(checks,key){
-      dispatch({
-        type: CONFIRMSELECTED,
-        checks,
-        key
-      })
-    }*/
   }
 }