operation.js
573 Bytes
import { Message } from "element-ui";
// 上移下移
export function upward (index, data) {
if (index > 0) {
let upData = data[index - 1];
data.splice(index - 1, 1);
data.splice(index, 0, upData);
} else {
Message({
message: '已经是第一条,上移失败',
});
}
}
export function down (index, data) {
if ((index + 1) == data.length) {
Message({
message: '已经是最后一条,下移失败',
});
} else {
let downData = data[index + 1];
data.splice(index + 1, 1);
data.splice(index, 0, downData);
}
}