2017-06-30 16:26:31 +08:00
|
|
|
<template>
|
2019-03-04 16:34:32 +08:00
|
|
|
<tr :class="rowClasses(row._index)" :draggable="draggable" @dragstart="onDrag($event,row._index)" @drop="onDrop($event,row._index)" @dragover="allowDrop($event)" v-if="draggable"><slot></slot></tr>
|
|
|
|
<tr :class="rowClasses(row._index)" v-else><slot></slot></tr>
|
2017-06-30 16:26:31 +08:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
row: Object,
|
2018-10-29 14:46:27 +08:00
|
|
|
prefixCls: String,
|
2019-03-04 16:34:32 +08:00
|
|
|
draggable: Boolean
|
2017-06-30 16:26:31 +08:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
objData () {
|
|
|
|
return this.$parent.objData;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2019-03-04 16:34:32 +08:00
|
|
|
onDrag (e,index) {
|
2018-10-29 14:46:27 +08:00
|
|
|
e.dataTransfer.setData("index",index);
|
|
|
|
},
|
2019-03-04 16:34:32 +08:00
|
|
|
onDrop (e,index) {
|
|
|
|
const dragIndex = e.dataTransfer.getData("index");
|
2018-10-29 14:46:27 +08:00
|
|
|
this.$parent.$parent.dragAndDrop(dragIndex,index);
|
|
|
|
e.preventDefault();
|
|
|
|
},
|
2019-03-04 16:34:32 +08:00
|
|
|
allowDrop (e) {
|
2018-10-29 14:46:27 +08:00
|
|
|
e.preventDefault();
|
|
|
|
},
|
2017-06-30 16:26:31 +08:00
|
|
|
rowClasses (_index) {
|
|
|
|
return [
|
|
|
|
`${this.prefixCls}-row`,
|
|
|
|
this.rowClsName(_index),
|
|
|
|
{
|
|
|
|
[`${this.prefixCls}-row-highlight`]: this.objData[_index] && this.objData[_index]._isHighlight,
|
|
|
|
[`${this.prefixCls}-row-hover`]: this.objData[_index] && this.objData[_index]._isHover
|
|
|
|
}
|
|
|
|
];
|
|
|
|
},
|
|
|
|
rowClsName (_index) {
|
|
|
|
return this.$parent.$parent.rowClassName(this.objData[_index], _index);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
2019-03-04 16:34:32 +08:00
|
|
|
</script>
|