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
}