Commit 05765173 authored by 周远喜's avatar 周远喜

树形数据修改成功

parent 94a6169b
......@@ -43,7 +43,7 @@
v-show="show(item)"
class="treetr"
:id="'tr' + index"
:draggable="drag"
:draggable="drag && !item._drag"
@dragstart="dragstart($event, index, item)"
@drop="dragdrop($event, index, item)"
@dragenter="dragenter($event, index, item)"
......@@ -250,23 +250,21 @@ export default {
},
},
mounted() {
if (this.items && this.items.length > 0) {
this.dataLength = this.Length(this.items);
this.initData(this.deepCopy(this.items), 1, null);
this.cloneColumns = this.makeColumns();
this.checkGroup = this.renderCheck(this.items);
if (this.checkGroup.length == this.dataLength) {
this.checks = true;
} else {
this.checks = false;
}
if (this.items && this.items.length > 0) {
this.dataLength = this.Length(this.items);
this.initData(this.deepCopy(this.items), 1, null);
this.cloneColumns = this.makeColumns();
this.checkGroup = this.renderCheck(this.items);
if (this.checkGroup.length == this.dataLength) {
this.checks = true;
} else {
this.checks = false;
}
}
//this.initData();
},
methods: {
initData() {
},
initData() {},
slots() {
return this.$scopedSlots;
},
......@@ -278,7 +276,12 @@ export default {
//进入
dragenter(e, index, row) {
var tr = document.getElementById("tr" + index);
tr.className += " move";
if (this.dragIndex > index) {
tr.className += " move";
} else if (this.dragIndex < index) {
tr.className += " sort";
}
// console.warn("进入",e, e.clientY,tr.clientTop, tr.className);
},
// 悬浮
......@@ -286,27 +289,20 @@ export default {
// console.warn("悬浮",e)
e.preventDefault();
// 鼠标Y
var my = e.clientY;
var ty = e.toElement.offsetTop;
var my = e.offsetY;
var h = e.toElement.clientHeight;
var tr = document.getElementById("tr" + index);
if (tr.className.indexOf(" sort") == -1 && 2.5 * h < my - ty) {
if (this.dragIndex > index && my/h<0.5) {
tr.className = tr.className.replace(" move", " sort");
}
// console.warn("在上边",my,ty,my-ty,h, tr.className);
this.logs.push({ index, ty, my, h });
if (this.dragIndex < index && my/h>0.5) {
tr.className = tr.className.replace(" sort", " move");
}
},
// 离开
dragleave(e, index, row) {
var tr = document.getElementById("tr" + index);
tr.className = tr.className.replace(" move", "").replace(" sort", "");
console.warn(
"离开",
e.clientY,
e.toElement.offsetTop,
e.toElement.clientHeight,
tr.className
);
},
//放下
dragdrop(e, index, row) {
......@@ -314,9 +310,9 @@ export default {
var tr = document.getElementById("tr" + index);
tr.className = tr.className.replace(" move", "").replace(" sort", "");
if (index != this.dragIndex) {
this.$emit("on-drag-drop", this.dragIndex, index, this.trs);
this.$emit("on-drag-drop", this.dragIndex, index, this.trs, e);
}
console.log(JSON.stringify(this.logs));
console.log(e.offsetY/ e.toElement.clientHeight);
},
/**
* @dragover="dragover($event, index, item)"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment