1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
rowDrop() { const tbody = document.querySelector('.el-table__body-wrapper tbody') const _this = this Sortable.create(tbody, { animation: 500, onMove(e) { const target = e.related.innerText.replace(/\s+/g, '') console.log("🚀 ~ onMove ~ target", target) if (target.indexOf('小计') !== -1) { if (_this.reloadData) { _this.$message({ type: 'warning', message: '不能拖拽到其他分段,请刷新页面重新进行拖拽' }) } _this.reloadData = true return false } else { } return true; }, onEnd(evt) { const list = _this.tableDataT3A; const oldIndex = evt.oldIndex; const newIndex = evt.newIndex; const oldItem = _this.tableDataT3A.splice(oldIndex, 1)[0]; _this.tableDataT3A.splice(newIndex, 0, oldItem); if (_this.reloadData) { _this.reloadData = false const item = list.splice(newIndex, 1)[0]; list.splice(oldIndex, 0, item); const tagName = evt.item.tagName; const items = evt.from.getElementsByTagName(tagName); if (evt.oldIndex > evt.newIndex) { evt.from.insertBefore(evt.item, items[evt.oldIndex + 1]); } else { evt.from.insertBefore(evt.item, items[evt.oldIndex]); } } else { const currRow = _this.tableDataT3A.splice(oldIndex, 1)[0] _this.tableDataT3A.splice(newIndex, 0, currRow) let arr = Array.from(_this.tableDataT3A) this.apiObjDrag = arr } }, }) },
|