|
@@ -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()}
|