iview/src/components/table/mixin.js

35 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-11-24 15:27:46 +08:00
export default {
methods: {
alignCls (column, type) {
2016-11-30 13:17:55 +08:00
return [
{
[`${column.className}`]: column.className && type === 'body',
2016-11-30 13:17:55 +08:00
[`${this.prefixCls}-column-${column.align}`]: column.align,
[`${this.prefixCls}-hidden`]: (this.fixed === 'left' && column.fixed !== 'left') || (this.fixed === 'right' && column.fixed !== 'right') || (!this.fixed && column.fixed && (column.fixed === 'left' || column.fixed === 'right'))
}
2016-12-25 22:49:42 +08:00
];
2016-11-30 13:17:55 +08:00
},
isPopperShow (column) {
return column.filters && ((!this.fixed && !column.fixed) || (this.fixed === 'left' && column.fixed === 'left') || (this.fixed === 'right' && column.fixed === 'right'));
},
2017-01-05 13:15:26 +08:00
setCellWidth (column, index, top) {
let width = '';
if (column.width) {
width = column.width;
} else if (this.columnsWidth[column._index]) {
2016-12-25 22:49:42 +08:00
width = this.columnsWidth[column._index].width;
}
2017-01-05 13:15:26 +08:00
// when browser has scrollBar,set a width to resolve scroll position bug
2017-01-05 14:10:08 +08:00
if (this.columns.length === index + 1 && top && this.$parent.bodyHeight !== 0) {
2017-01-05 13:15:26 +08:00
width += this.$parent.scrollBarWidth;
}
// when fixed type,reset first right fixed column's width
if (this.fixed === 'right') {
const firstFixedIndex = this.columns.findIndex((col) => col.fixed === 'right');
if (firstFixedIndex === index) width += this.$parent.scrollBarWidth;
}
return width;
2016-11-24 15:27:46 +08:00
}
}
2016-12-25 22:49:42 +08:00
};