|
@@ -14,7 +14,7 @@
|
|
</thead>
|
|
</thead>
|
|
<tbody
|
|
<tbody
|
|
class="drag-table-tbody"
|
|
class="drag-table-tbody"
|
|
- @drop.prevent="dropInnerElement"
|
|
|
|
|
|
+ @drop.prevent
|
|
@dragover.prevent="dragOver($event)"
|
|
@dragover.prevent="dragOver($event)"
|
|
@dragleave.prevent
|
|
@dragleave.prevent
|
|
>
|
|
>
|
|
@@ -38,7 +38,7 @@
|
|
@mousedown.stop="dragHandleMousedown"
|
|
@mousedown.stop="dragHandleMousedown"
|
|
@mouseup.stop="dragHandleMouseup"
|
|
@mouseup.stop="dragHandleMouseup"
|
|
>
|
|
>
|
|
- <div class="drag-handle">1</div>
|
|
|
|
|
|
+ <i class="el-icon-more"></i>
|
|
</td>
|
|
</td>
|
|
<td v-for="column in columns" :key="column.prop">
|
|
<td v-for="column in columns" :key="column.prop">
|
|
<slot :name="column.prop" v-bind:row="row">
|
|
<slot :name="column.prop" v-bind:row="row">
|
|
@@ -90,9 +90,10 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- this.tableData = val.map((item) => {
|
|
|
|
|
|
+ this.tableData = val.map((item, index) => {
|
|
return {
|
|
return {
|
|
...item,
|
|
...item,
|
|
|
|
+ $index: index + 1,
|
|
$key: randomCode(),
|
|
$key: randomCode(),
|
|
};
|
|
};
|
|
});
|
|
});
|
|
@@ -134,10 +135,8 @@ export default {
|
|
const targetKey = elementDom.id;
|
|
const targetKey = elementDom.id;
|
|
this.curDropRow = this.getSiblingRow(targetKey, 0);
|
|
this.curDropRow = this.getSiblingRow(targetKey, 0);
|
|
},
|
|
},
|
|
- dropInnerElement() {
|
|
|
|
- // console.log(this.curDragRow.id, this.curDropRowId);
|
|
|
|
|
|
+ dragEnd(e) {
|
|
if (this.curDragRow.id === this.curDropRow.id || !this.curDropRow) return;
|
|
if (this.curDragRow.id === this.curDropRow.id || !this.curDropRow) return;
|
|
-
|
|
|
|
// 往下:target上一个位置
|
|
// 往下:target上一个位置
|
|
// 往上:target下一个位置
|
|
// 往上:target下一个位置
|
|
this.moveElementToElement({
|
|
this.moveElementToElement({
|
|
@@ -145,9 +144,9 @@ export default {
|
|
toRow: this.curDropRow,
|
|
toRow: this.curDropRow,
|
|
isDragDown: this.isDragDown,
|
|
isDragDown: this.isDragDown,
|
|
});
|
|
});
|
|
- },
|
|
|
|
- dragEnd(e) {
|
|
|
|
|
|
+
|
|
e.target.setAttribute("draggable", false);
|
|
e.target.setAttribute("draggable", false);
|
|
|
|
+
|
|
this.curDragRow = {};
|
|
this.curDragRow = {};
|
|
this.curDropRow = {};
|
|
this.curDropRow = {};
|
|
this.dragStartPageY = null;
|
|
this.dragStartPageY = null;
|
|
@@ -165,6 +164,7 @@ export default {
|
|
|
|
|
|
this.tableData.forEach((row, index) => {
|
|
this.tableData.forEach((row, index) => {
|
|
row[this.sortField] = index + 1;
|
|
row[this.sortField] = index + 1;
|
|
|
|
+ row.$index = index + 1;
|
|
});
|
|
});
|
|
this.$emit("sort-change", this.tableData);
|
|
this.$emit("sort-change", this.tableData);
|
|
},
|
|
},
|