el-table表格拖动排序

 

sortable.js->minix文件

import Sortable from 'sortablejs'

export default {
  data () {
    return {}
  },
  computed: {

  },
  methods: {
    rowDrop () {
      const tbody = document.querySelector('.el-table__body-wrapper tbody')
      if (!tbody) return
      Sortable.create(tbody, {
        animation: 600,
        onEnd: this.onEnd
      })
    },
    onEnd ({
      newIndex,
      oldIndex
    }) {
      const currRow = this.tableData.splice(oldIndex, 1)[0]
      this.tableData.splice(newIndex, 0, currRow)
      this.confirmTaskClassificationTableOrder && this.confirmTaskClassificationTableOrder() // 分类表格排序
      this.confirmTaskManagentTableOrder && this.confirmTaskManagentTableOrder() // 任务管理表格排序
    }

  },
  created () {},
  mounted () {
    // this.rowDrop()
  }

}
View Code

 

 

 

posted on 2020-11-14 09:48  章画  阅读(414)  评论(0编辑  收藏  举报

导航