mixin.js
2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
export default {
methods: {
alignCls (column, row = {}) {
let cellClassName = '';
if (row.cellClassName && column.key && row.cellClassName[column.key]) {
cellClassName = row.cellClassName[column.key];
}
return [
{
[`${cellClassName}`]: cellClassName, // cell className
[`${column.className}`]: column.className, // column className
[`${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'))
}
];
},
isPopperShow (column) {
return column.filters && ((!this.fixed && !column.fixed) || (this.fixed === 'left' && column.fixed === 'left') || (this.fixed === 'right' && column.fixed === 'right'));
},
setCellWidth (column, index, top) {
let width = '';
if (column.width) {
width = column.width;
} else if (this.columnsWidth[column._index]) {
width = this.columnsWidth[column._index].width;
}
// when browser has scrollBar,set a width to resolve scroll position bug
if (width && this.columns.length === index + 1 && top && this.$parent.bodyHeight !== 0 && column.fixed!=='left' && !this.fixed) {
let scrollBarWidth = this.$parent.scrollBarWidth;
if (!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
width += scrollBarWidth;
}
// when fixed type,reset first right fixed column's width
if (this.fixed === 'right' && top ) {
//const firstFixedIndex = this.columns.findIndex((col) => col.fixed === 'right');
if (this.columns.length === index + 1) {
let scrollBarWidth = this.$parent.scrollBarWidth;
if (!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
width += scrollBarWidth;
}
}
if (width === '0') width = '';
return width;
}
}
};