//上移函数
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();
});
};