解决switch拖拽,拖拽改成插入
This commit is contained in:
parent
8e4d5b88e8
commit
d067cce97b
|
@ -230,7 +230,16 @@ var Table = function (_Component) {
|
|||
};
|
||||
|
||||
_this.swapArray = function (arr, index1, index2) {
|
||||
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
|
||||
var value1 = arr[index1];
|
||||
arr.splice(index1, 1);
|
||||
if (index1 < index2) {
|
||||
console.log('向下拖');
|
||||
arr.splice(index2, 0, value1);
|
||||
} else {
|
||||
console.log('向上拖');
|
||||
arr.splice(index2 + 1, 0, value1);
|
||||
}
|
||||
// arr[index1] = arr.splice(index2, 1, arr[index1])[0];
|
||||
return arr;
|
||||
};
|
||||
|
||||
|
|
|
@ -165,6 +165,10 @@ var TableRow = function (_Component) {
|
|||
var event = _utils.Event.getEvent(e),
|
||||
_target = _utils.Event.getTarget(event),
|
||||
target = _target.parentNode;
|
||||
|
||||
while (target.tagName != 'TR') {
|
||||
target = target.parentNode;
|
||||
}
|
||||
_this.currentIndex = target.getAttribute("data-row-key");
|
||||
|
||||
onDragRowStart && onDragRowStart(_this.currentIndex);
|
||||
|
|
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
12
src/Table.js
12
src/Table.js
|
@ -617,7 +617,17 @@ class Table extends Component {
|
|||
* @param {number} index2 删除项目的位置
|
||||
*/
|
||||
swapArray = (arr, index1, index2) => {
|
||||
arr[index1] = arr.splice(index2, 1, arr[index1])[0];
|
||||
var value1 = arr[index1]
|
||||
arr.splice(index1,1)
|
||||
if(index1<index2){
|
||||
console.log('向下拖')
|
||||
arr.splice(index2,0,value1)
|
||||
|
||||
}else {
|
||||
console.log('向上拖')
|
||||
arr.splice(index2+1,0,value1)
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
|
|
@ -198,6 +198,10 @@ class TableRow extends Component{
|
|||
let event = Event.getEvent(e) ,
|
||||
_target = Event.getTarget(event),
|
||||
target = _target.parentNode;
|
||||
|
||||
while (target.tagName != 'TR') {
|
||||
target = target.parentNode
|
||||
}
|
||||
this.currentIndex = target.getAttribute("data-row-key");
|
||||
|
||||
onDragRowStart && onDragRowStart(this.currentIndex);
|
||||
|
|
Loading…
Reference in New Issue