onMoveUp (index) {
if (index !== 0) {
this.swapArray(this.dataList, index, index - 1)
} else {
this.$message({message: '已经处于置顶,无法上移', type: 'warning'})
}
},
onMoveDown (index) {
let len = this.dataList.length
if (index + 1 !== len) {
this.swapArray(this.dataList, index, index + 1)
} else {
this.$message({message: '已经处于置底,无法下移', type: 'warning'})
}
},
swapArray (arr, indexOne, indexTwo) {
arr[indexOne] = arr.splice(indexTwo, 1, arr[indexOne])[0]
return arr
}