feat: onDropRow增加参数targetIndex
This commit is contained in:
parent
54f77ec52e
commit
17bf7b9c49
|
@ -239,11 +239,15 @@ var Table = function (_Component) {
|
||||||
targetIndex = i;
|
targetIndex = i;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (currentIndex > -1) {
|
||||||
data = _this.swapArray(data, currentIndex, targetIndex);
|
data = _this.swapArray(data, currentIndex, targetIndex);
|
||||||
_this.props.onDropRow && _this.props.onDropRow(data, record);
|
_this.props.onDropRow && _this.props.onDropRow(data, record, targetIndex);
|
||||||
_this.setState({
|
_this.setState({
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
_this.props.onDropRow && _this.props.onDropRow(data, record, targetIndex);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.swapArray = function (arr, index1, index2) {
|
_this.swapArray = function (arr, index1, index2) {
|
||||||
|
@ -1556,6 +1560,9 @@ var Table = function (_Component) {
|
||||||
this.lastScrollTop = e.target.scrollTop;
|
this.lastScrollTop = e.target.scrollTop;
|
||||||
if (handleScrollY) {
|
if (handleScrollY) {
|
||||||
(0, _utils.debounce)(handleScrollY(this.lastScrollTop, this.treeType, onBodyScroll), 300);
|
(0, _utils.debounce)(handleScrollY(this.lastScrollTop, this.treeType, onBodyScroll), 300);
|
||||||
|
} else {
|
||||||
|
//滚动回调
|
||||||
|
onBodyScroll(this.lastScrollTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ const data = [ ...new Array(10000) ].map((e, i) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class Demo32 extends Component {
|
class Demo43 extends Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -87,4 +87,4 @@ class Demo32 extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Demo32;
|
export default Demo43;
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -664,11 +664,15 @@ class Table extends Component {
|
||||||
targetIndex = i;
|
targetIndex = i;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if(currentIndex > -1) {
|
||||||
data = this.swapArray(data,currentIndex,targetIndex);
|
data = this.swapArray(data,currentIndex,targetIndex);
|
||||||
this.props.onDropRow && this.props.onDropRow(data,record);
|
this.props.onDropRow && this.props.onDropRow(data,record,targetIndex);
|
||||||
this.setState({
|
this.setState({
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.props.onDropRow && this.props.onDropRow(data,record,targetIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 数组元素交换位置
|
* 数组元素交换位置
|
||||||
|
|
Loading…
Reference in New Issue