对element table实行拖拽排序
import Sortable from 'sortablejs'
mounted() {
this.$nextTick(() => {
this.tableDrag()
})
}
methods: {
tableDrag () {
const el1 = document.querySelectorAll('.dragger-table .el-table__body-wrapper')[0].querySelectorAll('table > tbody')[0]
Sortable.create(el1, {
disabled: false,
ghostClass: 'sortable-ghost',
animation: 150,
group: {
pull: false,
put: false
},
onEnd: (e) => {
console.log('e', e)
let arr = this.relationshipForShiftList
arr.splice(e.newIndex, 0, arr.splice(e.oldIndex, 1)[0]);
this.$nextTick(function () {
this.relationshipForShiftList = arr
})
}
})
},
}
<style lang="scss" scoped>
.sortable-ghost {
opacity: 0.4;
background-color: #F4E2C9;
}
</style>