依赖:sortablejs、vxe-table
import Sortable from "sortablejs";
import VXETable from "vxe-table";
mounted(){
this.getPlanList();
this.rowDrop();
// this.getTableData();
},
beforeDestroy() {
if (this.sortable) {
this.sortable.destroy();
}
},
methods:{
// 行拖动
rowDrop() {
this.$nextTick(() => {
let xTable = this.$refs.xTable;
this.sortable = Sortable.create(
xTable.$el.querySelector(".body--wrapper>.vxe-table--body tbody"),
{
handle: ".vxe-body--row",
animation: 150,
onEnd: ({ newIndex, oldIndex }) => {
this.tableData.splice(newIndex, 0, this.tableData.splice(oldIndex, 1)[0]);
var newArray = this.tableData.slice(0);
this.tableData = [];
this.$nextTick(function () {
this.tableData = newArray;
this.fn_order();
});
},
}
);
});
},
}