//上移函数
upGo = (dataSource, index) => {
if (index != 0) {
dataSource[index] = dataSource.splice(index - 1, 1, dataSource[index])[0];
} else {
dataSource.push(dataSource.shift());
}
};
//下移函数
downGo = (dataSource, index) => {
if (index != dataSource.length - 1) {
dataSource[index] = dataSource.splice(index + 1, 1, dataSource[index])[0];
} else {
dataSource.unshift(dataSource.splice(index, 1)[0]);
}
};
//操作上移下移
onMove = (type, row, index) => {
let { dataSource } = this.state;
if (type == ‘UP’) {
this.upGo(dataSource, index);
} else {
this.downGo(dataSource, index);
}
this.setState({ dataSource }, () => {
this.updatePatrolRelation();
});
};
table表格上移下移操作方法总结
最新推荐文章于 2024-05-14 13:47:57 发布