commit
cd8302d5be
4 changed files with 36 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Table ref="currentRowTable" :columns="columns3" :data="data1"></Table>
|
<Table ref="currentRowTable" :columns="columns3" :data="data1" :draggable="true" @on-drag-drop="onDragDrop"></Table>
|
||||||
<Button @click="handleClearCurrentRow">Clear</Button>
|
<Button @click="handleClearCurrentRow">Clear</Button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -62,6 +62,10 @@
|
||||||
methods: {
|
methods: {
|
||||||
handleClearCurrentRow () {
|
handleClearCurrentRow () {
|
||||||
this.$refs.currentRowTable.clearCurrentRow();
|
this.$refs.currentRowTable.clearCurrentRow();
|
||||||
|
},
|
||||||
|
onDragDrop(a,b){
|
||||||
|
console.log(a,b);
|
||||||
|
this.data1.splice(b,1,...this.data1.splice(a, 1 , this.data1[b]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<tbody :class="[prefixCls + '-tbody']">
|
<tbody :class="[prefixCls + '-tbody']">
|
||||||
<template v-for="(row, index) in data">
|
<template v-for="(row, index) in data">
|
||||||
<table-tr
|
<table-tr
|
||||||
|
:draggable="draggable"
|
||||||
:row="row"
|
:row="row"
|
||||||
:key="row._rowKey"
|
:key="row._rowKey"
|
||||||
:prefix-cls="prefixCls"
|
:prefix-cls="prefixCls"
|
||||||
|
@ -58,6 +59,10 @@
|
||||||
fixed: {
|
fixed: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
draggable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<tr :class="rowClasses(row._index)"><slot></slot></tr>
|
<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>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
row: Object,
|
row: Object,
|
||||||
prefixCls: String
|
prefixCls: String,
|
||||||
|
draggable: Boolean
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
objData () {
|
objData () {
|
||||||
|
@ -13,6 +15,17 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onDrag (e,index) {
|
||||||
|
e.dataTransfer.setData("index",index);
|
||||||
|
},
|
||||||
|
onDrop (e,index) {
|
||||||
|
const dragIndex = e.dataTransfer.getData("index");
|
||||||
|
this.$parent.$parent.dragAndDrop(dragIndex,index);
|
||||||
|
e.preventDefault();
|
||||||
|
},
|
||||||
|
allowDrop (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
},
|
||||||
rowClasses (_index) {
|
rowClasses (_index) {
|
||||||
return [
|
return [
|
||||||
`${this.prefixCls}-row`,
|
`${this.prefixCls}-row`,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
v-show="!((!!localeNoDataText && (!data || data.length === 0)) || (!!localeNoFilteredDataText && (!rebuildData || rebuildData.length === 0)))">
|
v-show="!((!!localeNoDataText && (!data || data.length === 0)) || (!!localeNoFilteredDataText && (!rebuildData || rebuildData.length === 0)))">
|
||||||
<table-body
|
<table-body
|
||||||
ref="tbody"
|
ref="tbody"
|
||||||
|
:draggable="draggable"
|
||||||
:prefix-cls="prefixCls"
|
:prefix-cls="prefixCls"
|
||||||
:styleObject="tableStyle"
|
:styleObject="tableStyle"
|
||||||
:columns="cloneColumns"
|
:columns="cloneColumns"
|
||||||
|
@ -53,6 +54,7 @@
|
||||||
<div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedBody" @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel">
|
<div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedBody" @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel">
|
||||||
<table-body
|
<table-body
|
||||||
fixed="left"
|
fixed="left"
|
||||||
|
:draggable="draggable"
|
||||||
:prefix-cls="prefixCls"
|
:prefix-cls="prefixCls"
|
||||||
:styleObject="fixedTableStyle"
|
:styleObject="fixedTableStyle"
|
||||||
:columns="leftFixedColumns"
|
:columns="leftFixedColumns"
|
||||||
|
@ -77,6 +79,7 @@
|
||||||
<div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedRightBody" @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel">
|
<div :class="[prefixCls + '-fixed-body']" :style="fixedBodyStyle" ref="fixedRightBody" @mousewheel="handleFixedMousewheel" @DOMMouseScroll="handleFixedMousewheel">
|
||||||
<table-body
|
<table-body
|
||||||
fixed="right"
|
fixed="right"
|
||||||
|
:draggable="draggable"
|
||||||
:prefix-cls="prefixCls"
|
:prefix-cls="prefixCls"
|
||||||
:styleObject="fixedRightTableStyle"
|
:styleObject="fixedRightTableStyle"
|
||||||
:columns="rightFixedColumns"
|
:columns="rightFixedColumns"
|
||||||
|
@ -183,6 +186,10 @@
|
||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
draggable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -909,6 +916,9 @@
|
||||||
const data = Csv(columns, datas, params, noHeader);
|
const data = Csv(columns, datas, params, noHeader);
|
||||||
if (params.callback) params.callback(data);
|
if (params.callback) params.callback(data);
|
||||||
else ExportCsv.download(params.filename, data);
|
else ExportCsv.download(params.filename, data);
|
||||||
|
},
|
||||||
|
dragAndDrop(a,b) {
|
||||||
|
this.$emit('on-drag-drop', a,b);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue