Commit a404bbaed33d567ed1de2576059c68e6ff5ed2af

Authored by 梁灏
1 parent 3d6fa54b

update Table #167

update Table
src/components/table/mixin.js
... ... @@ -19,7 +19,7 @@ export default {
19 19 width = this.columnsWidth[column._index].width;
20 20 }
21 21 // when browser has scrollBar,set a width to resolve scroll position bug
22   - if (this.columns.length === index + 1 && top) {
  22 + if (this.columns.length === index + 1 && top && this.$parent.bodyHeight !== 0) {
23 23 width += this.$parent.scrollBarWidth;
24 24 }
25 25 // when fixed type,reset first right fixed column's width
... ...
src/components/table/table-head.vue
1 1 <template>
2   - <table cellspacing="0" cellpadding="0" border="0" :style="style">
  2 + <table cellspacing="0" cellpadding="0" border="0" :style="styles">
3 3 <colgroup>
4 4 <col v-for="column in columns" :width="setCellWidth(column, $index, true)">
5 5 </colgroup>
... ... @@ -75,6 +75,12 @@
75 75 }
76 76 },
77 77 computed: {
  78 + styles () {
  79 + const style = Object.assign({}, this.style);
  80 + const width = this.$parent.bodyHeight === 0 ? parseInt(this.style.width) : parseInt(this.style.width) + this.$parent.scrollBarWidth;
  81 + style.width = `${width}px`;
  82 + return style;
  83 + },
78 84 isSelectAll () {
79 85 let isSelectAll = true;
80 86 if (!this.data.length) isSelectAll = false;
... ...
test/routers/table.vue
... ... @@ -4,7 +4,9 @@
4 4 }
5 5 </style>
6 6 <template>
7   - <i-table width="550" height="200" border :columns="columns2" :data="data4"></i-table>
  7 + <i-table border :columns="columns1" :data="data1"></i-table>
  8 + <i-table border height="200" :columns="columns1" :data="data2"></i-table>
  9 + <!--<i-table width="550" height="200" border :columns="columns2" :data="data4"></i-table>-->
8 10 <!--<i-button @click="changeFilter">改变filter</i-button>-->
9 11 <!--<span v-if="currentRow !== null">Current Row: {{currentRow.name}}</span>-->
10 12 <!--<Switch size="small" @on-change="switchCellEllipsis"></Switch> Ellipsis-->
... ...