|
@@ -37,6 +37,7 @@ class EditableSpan extends Component{
|
|
|
this.handleKeydown = this.handleKeydown.bind(this);
|
|
|
this.handleKeyup = this.handleKeyup.bind(this);
|
|
|
this.moveEnd = this.moveEnd.bind(this);
|
|
|
+ this.stopIt = this.stopIt.bind(this);
|
|
|
}
|
|
|
handleFocus(e){
|
|
|
e.stopPropagation();
|
|
@@ -61,7 +62,7 @@ class EditableSpan extends Component{
|
|
|
e.stopPropagation();
|
|
|
const {handleChange,boxMark,i,handleSearch,value,mainSaveText,mainIds,handleClear} = this.props;
|
|
|
const {labelVal,searchPre} = this.state;
|
|
|
- const text1 =e.target.innerText;
|
|
|
+ const text1 =e.target.innerText? e.target.innerText : e.target.innerHTML;
|
|
|
let mainText = filterDataArr(mainSaveText);//主诉字数
|
|
|
if(+boxMark==1){
|
|
|
if(mainText.length >= config.limited){
|
|
@@ -157,18 +158,31 @@ class EditableSpan extends Component{
|
|
|
preVal:innerVal
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+ stopIt(e){
|
|
|
+ if(e.returnValue){
|
|
|
+ e.returnValue = false ;
|
|
|
+ }
|
|
|
+ if(e.preventDefault ){
|
|
|
+ e.preventDefault();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
handleKeyup(e){
|
|
|
- const {boxMark,handleKeydown,i,value,removeId,handleClear,delSingleLable} = this.props;
|
|
|
+ const {boxMark,handleKeydown,i,value,removeId,handleClear,delSingleLable,setSearchLocation} = this.props;
|
|
|
const {preVal,index} = this.state;
|
|
|
const ev = e||window.event;
|
|
|
const target = ev.target||ev.srcElement;
|
|
|
- let innerVal = target.innerText;
|
|
|
+ let innerVal = target.innerText? target.innerText : target.innerHTML;
|
|
|
if(ev.keyCode==8){
|
|
|
+ const elem = ev.srcElement || ev.currentTarget;
|
|
|
+ const nodeN = elem.nodeName;
|
|
|
+ if(nodeN != "SPAN"){//光标没落到span的时候阻止默认事件(backspace回退页面的情况)
|
|
|
+ return this.stopIt(ev);
|
|
|
+ }
|
|
|
// 主诉现病史去重:删除最后一个字的时候移除该数据(将name、id和value替换成空)并移除id
|
|
|
// 前面是标签,内容为空时再删一次才移除标签;前面是文本,则直接移除;
|
|
|
- // console.log(77,innerVal,preVal);
|
|
|
+ // console.log(77,elem,nodeN);
|
|
|
let preObj = $(this.$span.current).prev();
|
|
|
if(index!==0&&preVal.trim().length==1&& !innerVal){
|
|
|
removeId && removeId({boxMark,i:index,text:""});
|
|
@@ -201,18 +215,23 @@ class EditableSpan extends Component{
|
|
|
index: null
|
|
|
})
|
|
|
}
|
|
|
+ let ele = document.activeElement;
|
|
|
+ let boxTop = getPageCoordinate(e).boxTop;
|
|
|
+ setSearchLocation(boxTop,ele.offsetLeft) //搜索框的位置动态获取
|
|
|
}
|
|
|
}
|
|
|
componentWillReceiveProps(next){
|
|
|
const isRead = this.props.isRead;
|
|
|
if(next.isRead != isRead){
|
|
|
- this.$span.current.innerText = next.value||'';
|
|
|
+ this.$span.current.innerText = next.value||''
|
|
|
+ // this.$span.current.innerText?(this.$span.current.innerText = next.value||''):(this.$span.current.innerHTML = next.value||'');
|
|
|
}
|
|
|
}
|
|
|
componentDidMount(){
|
|
|
const {value} = this.props;
|
|
|
if(value){
|
|
|
- this.$span.current.innerText = value||'';
|
|
|
+ this.$span.current.innerText?(this.$span.current.innerText = value||''):(this.$span.current.innerHTML = value||'');
|
|
|
+ // this.$span.current.innerText = value||''
|
|
|
}
|
|
|
if(isIE()){
|
|
|
$(this.$span.current).onIe8Input(function(e){
|
|
@@ -220,6 +239,14 @@ class EditableSpan extends Component{
|
|
|
},this);
|
|
|
}
|
|
|
}
|
|
|
+ /*cancelSelect(e){//双击不选中
|
|
|
+ if(document.selection&&document.selection.empty){
|
|
|
+ document.selection.empty();
|
|
|
+ }else if (window.getSelection) {
|
|
|
+ var sel=window.getSelection();
|
|
|
+ sel.removeAllRanges();
|
|
|
+ }
|
|
|
+ }*/
|
|
|
|
|
|
getClass(){
|
|
|
const {full,value,saveText,i} = this.props;
|