rowDrop () { const tbody = document.querySelector('.el-table__body-wrapper tbody') const _this = this let sort = Sortable.create(tbody, { forceFallback: false, onMove: (evt, originalEvent) => { // 出现非发布和已发布,立即还原交换 if (_this.initTableData[evt.dragged.rowIndex].status != _this.initTableData[evt.related.rowIndex].status) { return false } }, onEnd ({ newIndex, oldIndex }) { let newRow = _this.initTableData[newIndex] let oldRow = _this.initTableData[oldIndex] const currRow = _this.initTableData.splice(oldIndex, 1)[0] if (!newRow) { let index = _this.initTableData.length - 1 let sort = _this.initTableData[index].sequence currRow.sequence = sort + 1 _this.initTableData.splice(oldIndex, 0, currRow) return } let old = newRow.sequence let current = currRow.sequence currRow.sequence = old //交换顺序 newRow.sequence = current _this.initTableData.splice(newIndex, 0, currRow) _this.temp.push(currRow) _this.temp.push(newRow) _this.$emit('update:initTableData', _this.initTableData) } }) },