iview-admin icon indicating copy to clipboard operation
iview-admin copied to clipboard

如何实现表格拖拽排序

Open qinuoyun opened this issue 6 years ago • 2 comments

如何实现表格拖拽排序

qinuoyun avatar Jun 06 '19 04:06 qinuoyun

同问, 之前的table页面咋都没了

four-li avatar Jun 15 '19 07:06 four-li

draggable

dragSort(drapIdx, dropIdx) {
  dragIdx = Number(dragIdx)
  dropIdx = Number(dropIdx)

  const temp = this.data[dragIdx]

  if(dragIdx < dropIdx) {
    for(let i = dragIdx; i < dropIdx; i++) {
      this.data.splice(i, 1, this.list[i + 1])
    }
  }
  
  if(dragIdx > dropIdx) {
    for(let i = dropIdx; i < dragIdx; i++) {
      this.data.splice(i + 1, 1, this.data[i])
    }
  }

  this.data.splice(dropIdx, 1, temp)
}

joriewong avatar Oct 23 '20 03:10 joriewong