|
@@ -2,9 +2,10 @@ import React,{Component} from 'react';
|
|
|
import classNames from 'classnames';
|
|
|
import config from '@config/index.js';
|
|
|
import style from './index.less';
|
|
|
-import {deepClone,filterArr,handleEnter} from '@utils/tools.js';
|
|
|
+import {deepClone,filterArr,handleEnter,isIE} from '@utils/tools.js';
|
|
|
import {Notify} from '@commonComp';
|
|
|
import {getIds} from '@common/js/func.js';
|
|
|
+import $ from 'jquery';
|
|
|
/****
|
|
|
* 标签组合下拉,选中的项目展开
|
|
|
* author:zn@2018-11-21
|
|
@@ -35,6 +36,7 @@ class SpreadDrop extends Component{
|
|
|
editable:false, //双击编辑
|
|
|
labelVal:'', //存放标签原有的值--主诉字数限制用
|
|
|
};
|
|
|
+ this.$div = React.createRef();
|
|
|
this.handleSelect = this.handleSelect.bind(this);
|
|
|
this.clearState = this.clearState.bind(this);
|
|
|
this.handleClear = this.handleClear.bind(this);
|
|
@@ -50,7 +52,7 @@ class SpreadDrop extends Component{
|
|
|
handleShow(e){//单击
|
|
|
e&&e.stopPropagation();
|
|
|
// window.event? window.event.cancelBubble = true : e.stopPropagation();
|
|
|
- this.setStateInit(); //恢复初始选中状态
|
|
|
+ // this.setStateInit(); //恢复初始选中状态
|
|
|
const {ikey,handleShow,placeholder,flag,id,value,tagType,type} = this.props;
|
|
|
const that = this;
|
|
|
this.btnClickFlag = false;
|
|
@@ -65,7 +67,7 @@ class SpreadDrop extends Component{
|
|
|
|
|
|
}
|
|
|
|
|
|
- changeToEdit(e){//双击
|
|
|
+ changeToEdit(e){console.log("标签双击");//双击
|
|
|
const {value,id,placeholder,handleDbclick} = this.props;
|
|
|
let text = e.target.innerText;
|
|
|
// clearTimeout(this.state.timer);//取消延时的单击事件
|
|
@@ -81,7 +83,7 @@ class SpreadDrop extends Component{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- onChange(e){
|
|
|
+ onChange(e){ console.log("标签输入");
|
|
|
const {mainSaveText,ikey,type,handleLabelChange} = this.props;
|
|
|
const {labelVal} = this.state;
|
|
|
let mainText = filterArr(mainSaveText);//主诉字数
|
|
@@ -104,14 +106,14 @@ class SpreadDrop extends Component{
|
|
|
}
|
|
|
|
|
|
handleBlur(e){
|
|
|
- e.stopPropagation();
|
|
|
+ e.stopPropagation();console.log("标签失焦");
|
|
|
const {ikey,type,handleLabelChange} = this.props;
|
|
|
this.setState({
|
|
|
editable:false
|
|
|
});
|
|
|
// 更改标签的value值
|
|
|
let changeVal = e.target.innerText;
|
|
|
- handleLabelChange && handleLabelChange({ikey,changeVal,type});
|
|
|
+ // handleLabelChange && handleLabelChange({ikey,changeVal,type});
|
|
|
|
|
|
}
|
|
|
setStateInit(){
|
|
@@ -146,11 +148,11 @@ class SpreadDrop extends Component{
|
|
|
});
|
|
|
this.btnClickFlag = false;
|
|
|
}
|
|
|
- handleClear(e){
|
|
|
+ handleClear(e){console.log("清空");
|
|
|
e.stopPropagation();
|
|
|
this.clearState();
|
|
|
}
|
|
|
- handleConfirm(e){
|
|
|
+ handleConfirm(e){console.log("确定");
|
|
|
e.stopPropagation();
|
|
|
const {handleConfirm,ikey,type,tagType,order,mainSaveText,copyType} = this.props;
|
|
|
const params = Object.assign({},this.state,{ikey,type,tagType,order,mainSaveText,copyType});
|
|
@@ -159,7 +161,7 @@ class SpreadDrop extends Component{
|
|
|
//点确定后隐藏弹窗
|
|
|
this.props.handleHide();
|
|
|
}
|
|
|
- handleSelect(item,isExclu,joint,listIndex,selected){
|
|
|
+ handleSelect(item,isExclu,joint,listIndex,selected){console.log("选中");
|
|
|
let {withOn,withs,noneOn,exclusion,exists,nowOn,nones,noneIds,ban} = this.state;
|
|
|
/*if(this.props.selecteds)
|
|
|
console.log(exists,this.props.selecteds.exists,exists===this.props.selecteds.exists)*/
|
|
@@ -293,18 +295,31 @@ class SpreadDrop extends Component{
|
|
|
});
|
|
|
return list;
|
|
|
}
|
|
|
+ componentDidMount(){
|
|
|
+ if(isIE()){
|
|
|
+ $(this.$div.current).onIe8Input(function(e){
|
|
|
+ this.onChange(e)
|
|
|
+ },this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
render(){
|
|
|
const {placeholder,value,show} = this.props;
|
|
|
const {editable} = this.state;
|
|
|
- return <div className={style['container']}>
|
|
|
+ return <div className={style['container']}
|
|
|
+ onFocus={(e)=>e.stopPropagation()}
|
|
|
+ onBlur={(e)=>e.stopPropagation()}
|
|
|
+ onInput={(e)=>e.stopPropagation()}>
|
|
|
<div
|
|
|
+ ref={this.$div}
|
|
|
onClick={this.handleShow}
|
|
|
className={this.getClass()}
|
|
|
contentEditable={editable}
|
|
|
onDoubleClick={this.changeToEdit}
|
|
|
onBlur={this.handleBlur}
|
|
|
onInput={this.onChange}
|
|
|
- onkeydown={handleEnter}>{value||placeholder}</div>
|
|
|
+ onkeydown={handleEnter}
|
|
|
+ >{value||placeholder}</div>
|
|
|
<div className={style["drop-list"]} style={{display:show?'block':'none'}} contentEditable="false" onClick={(e)=>{e.stopPropagation();}}>
|
|
|
{this.getLabels()}
|
|
|
<div className="oper">
|
|
@@ -367,7 +382,7 @@ class ListItem extends Component{
|
|
|
render(){
|
|
|
const {data,isSpecialPos} = this.props;
|
|
|
const pos = isSpecialPos?style['independent']:'';
|
|
|
- return <ul className={classNames(style['row'],pos)}>
|
|
|
+ return <ul className={classNames(style['row'],pos)} onBlur={(e)=>e.stopPropagation()}>
|
|
|
{data&&data.map((it,i)=>{
|
|
|
return <li onClick={(e)=>this.handleClick(e,it,i)}
|
|
|
className={this.getClass(it.id)}>{it.labelPrefix}{it.name}{it.labelSuffix}</li>
|