update Table
update Table
This commit is contained in:
parent
b8a4300003
commit
52874e27e5
7 changed files with 70 additions and 13 deletions
|
@ -5,7 +5,7 @@
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tbody :class="[prefixCls + '-tbody']">
|
<tbody :class="[prefixCls + '-tbody']">
|
||||||
<tr
|
<tr
|
||||||
v-for="(index, row) in data"
|
v-for="(index, row) in cloneData"
|
||||||
:class="rowClasses(row, index)"
|
:class="rowClasses(row, index)"
|
||||||
@mouseenter.stop="handleMouseIn(index)"
|
@mouseenter.stop="handleMouseIn(index)"
|
||||||
@mouseleave.stop="handleMouseOut(index)"
|
@mouseleave.stop="handleMouseOut(index)"
|
||||||
|
@ -34,7 +34,6 @@
|
||||||
prefixCls: String,
|
prefixCls: String,
|
||||||
style: Object,
|
style: Object,
|
||||||
columns: Array,
|
columns: Array,
|
||||||
data: Array,
|
|
||||||
cloneData: Array,
|
cloneData: Array,
|
||||||
fixed: Boolean
|
fixed: Boolean
|
||||||
},
|
},
|
||||||
|
@ -53,7 +52,7 @@
|
||||||
return this.$parent.setCellWidth(column, index);
|
return this.$parent.setCellWidth(column, index);
|
||||||
},
|
},
|
||||||
rowClsName (index) {
|
rowClsName (index) {
|
||||||
return this.$parent.rowClassName(this.data[index], index);
|
return this.$parent.rowClassName(this.cloneData[index], index);
|
||||||
},
|
},
|
||||||
handleMouseIn (index) {
|
handleMouseIn (index) {
|
||||||
this.$parent.handleMouseIn(index);
|
this.$parent.handleMouseIn(index);
|
||||||
|
|
|
@ -8,7 +8,13 @@
|
||||||
<th v-for="column in columns" :class="alignCls(column)">
|
<th v-for="column in columns" :class="alignCls(column)">
|
||||||
<div :class="cellClasses(column)">
|
<div :class="cellClasses(column)">
|
||||||
<template v-if="column.type === 'selection'"><Checkbox :checked="isSelectAll" @on-change="selectAll"></Checkbox></template>
|
<template v-if="column.type === 'selection'"><Checkbox :checked="isSelectAll" @on-change="selectAll"></Checkbox></template>
|
||||||
<template v-else>{{{ renderHeader(column, $index) }}}</template>
|
<template v-else>
|
||||||
|
{{{ renderHeader(column, $index) }}}
|
||||||
|
<span :class="[prefixCls + '-sort']" v-if="column.sortable">
|
||||||
|
<i class="ivu-icon ivu-icon-arrow-up-b" @click="handleSortAsc($index)"></i>
|
||||||
|
<i class="ivu-icon ivu-icon-arrow-down-b" @click="handleSortDesc($index)"></i>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -57,6 +63,12 @@
|
||||||
selectAll () {
|
selectAll () {
|
||||||
const status = !this.isSelectAll;
|
const status = !this.isSelectAll;
|
||||||
this.$parent.selectAll(status);
|
this.$parent.selectAll(status);
|
||||||
|
},
|
||||||
|
handleSortAsc (index) {
|
||||||
|
this.$parent.handleSort(index, 'asc');
|
||||||
|
},
|
||||||
|
handleSortDesc (index) {
|
||||||
|
this.$parent.handleSort(index, 'desc');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
:prefix-cls="prefixCls"
|
:prefix-cls="prefixCls"
|
||||||
:style="tableStyle"
|
:style="tableStyle"
|
||||||
:columns="cloneColumns"
|
:columns="cloneColumns"
|
||||||
:data="data"
|
|
||||||
:clone-data="cloneData"></table-body>
|
:clone-data="cloneData"></table-body>
|
||||||
</div>
|
</div>
|
||||||
<div :class="[prefixCls + '-fixed']">
|
<div :class="[prefixCls + '-fixed']">
|
||||||
|
@ -32,7 +31,6 @@
|
||||||
:prefix-cls="prefixCls"
|
:prefix-cls="prefixCls"
|
||||||
:style="fixedTableStyle"
|
:style="fixedTableStyle"
|
||||||
:columns="leftFixedColumns"
|
:columns="leftFixedColumns"
|
||||||
:data="data"
|
|
||||||
:clone-data="cloneData"></table-body>
|
:clone-data="cloneData"></table-body>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -51,7 +49,6 @@
|
||||||
:prefix-cls="prefixCls"
|
:prefix-cls="prefixCls"
|
||||||
:style="fixedRightTableStyle"
|
:style="fixedRightTableStyle"
|
||||||
:columns="rightFixedColumns"
|
:columns="rightFixedColumns"
|
||||||
:data="data"
|
|
||||||
:clone-data="cloneData"></table-body>
|
:clone-data="cloneData"></table-body>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -269,9 +266,11 @@
|
||||||
});
|
});
|
||||||
this.cloneData = tmpData;
|
this.cloneData = tmpData;
|
||||||
|
|
||||||
|
const selection = this.getSelection();
|
||||||
if (status) {
|
if (status) {
|
||||||
this.$emit('on-select-all', this.getSelection());
|
this.$emit('on-select-all', selection);
|
||||||
}
|
}
|
||||||
|
this.$emit('on-selection-change', selection);
|
||||||
},
|
},
|
||||||
fixedHeader () {
|
fixedHeader () {
|
||||||
if (!!this.height) {
|
if (!!this.height) {
|
||||||
|
@ -315,6 +314,13 @@
|
||||||
} else {
|
} else {
|
||||||
$body.scrollLeft = $body.scrollLeft - 10;
|
$body.scrollLeft = $body.scrollLeft - 10;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
handleSort (index, type) {
|
||||||
|
if (type === 'asc') {
|
||||||
|
|
||||||
|
} else if (type === 'desc') {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
compiled () {
|
compiled () {
|
||||||
|
|
|
@ -197,7 +197,7 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
box-shadow: 1px 0 8px #d3d4d6;
|
box-shadow: @shadow-right;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
|
@ -215,7 +215,7 @@
|
||||||
top: 0;
|
top: 0;
|
||||||
left: auto;
|
left: auto;
|
||||||
right: 0;
|
right: 0;
|
||||||
box-shadow: -1px 0 8px #d3d4d6;
|
box-shadow: @shadow-left;
|
||||||
}
|
}
|
||||||
&-fixed-header{
|
&-fixed-header{
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -227,4 +227,8 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-sort{
|
||||||
|
.sortable();
|
||||||
|
}
|
||||||
}
|
}
|
33
src/styles/mixins/caret.less
Normal file
33
src/styles/mixins/caret.less
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// sortable
|
||||||
|
.sortable() {
|
||||||
|
display: inline-block;
|
||||||
|
width: 8px;
|
||||||
|
height: 12px;
|
||||||
|
margin-left: 4px;
|
||||||
|
margin-top: -1px;
|
||||||
|
vertical-align: middle;
|
||||||
|
overflow: hidden;
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
i {
|
||||||
|
display: block;
|
||||||
|
height: 6px;
|
||||||
|
line-height: 6px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: absolute;
|
||||||
|
color: @btn-disable-color;
|
||||||
|
transition: color @transition-time @ease-in-out;
|
||||||
|
|
||||||
|
&:hover{
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:first-child{
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
&:last-child{
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,3 +12,4 @@
|
||||||
@import "content"; // card、modal
|
@import "content"; // card、modal
|
||||||
@import "tooltip";
|
@import "tooltip";
|
||||||
@import "select";
|
@import "select";
|
||||||
|
@import "caret";
|
|
@ -9,8 +9,9 @@
|
||||||
<br>
|
<br>
|
||||||
<i-table
|
<i-table
|
||||||
width="450"
|
width="450"
|
||||||
height="200"
|
:height="height"
|
||||||
stripe
|
stripe
|
||||||
|
border
|
||||||
highlight-row
|
highlight-row
|
||||||
:show-header="true"
|
:show-header="true"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
|
@ -55,6 +56,7 @@
|
||||||
key: 'age',
|
key: 'age',
|
||||||
align: 'right',
|
align: 'right',
|
||||||
// fixed: 'left',
|
// fixed: 'left',
|
||||||
|
sortable: true,
|
||||||
width: 100
|
width: 100
|
||||||
// render (row) {
|
// render (row) {
|
||||||
// return `<i-button>${row.age}</i-button>`
|
// return `<i-button>${row.age}</i-button>`
|
||||||
|
@ -80,7 +82,7 @@
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: 120,
|
width: 120,
|
||||||
render (row, column, index) {
|
render (row, column, index) {
|
||||||
return `<i-button @click="edit(${index})">${row.name}</i-button>`
|
return `<i-button @click="edit(${index})">${row.name}${index}</i-button>`
|
||||||
// return `<a>${row.name}</a>`
|
// return `<a>${row.name}</a>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +155,6 @@
|
||||||
// this.columns[2].width = 150;
|
// this.columns[2].width = 150;
|
||||||
// return;
|
// return;
|
||||||
// this.height = 150;
|
// this.height = 150;
|
||||||
// return
|
|
||||||
// this.data.push({
|
// this.data.push({
|
||||||
// name: '刘天娇2',
|
// name: '刘天娇2',
|
||||||
// age: 272,
|
// age: 272,
|
||||||
|
@ -161,6 +162,7 @@
|
||||||
// edit: false
|
// edit: false
|
||||||
// });
|
// });
|
||||||
// this.data.splice(1, 1)
|
// this.data.splice(1, 1)
|
||||||
|
// this.columns.splice(2,1)
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue