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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import _extends from 'babel-runtime/helpers/extends';
import PropTypes from '../../_util/vue-types';
import { measureScrollbar } from './utils';
import BaseTable from './BaseTable';
export default {
name: 'BodyTable',
props: {
fixed: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
columns: PropTypes.array.isRequired,
tableClassName: PropTypes.string.isRequired,
handleBodyScroll: PropTypes.func.isRequired,
handleWheel: PropTypes.func.isRequired,
getRowKey: PropTypes.func.isRequired,
expander: PropTypes.object.isRequired,
isAnyColumnsFixed: PropTypes.bool
},
inject: {
table: { 'default': function _default() {
return {};
} }
},
mounted: function mounted() {
this.updateTableRef();
},
updated: function updated() {
this.updateTableRef();
},
methods: {
updateTableRef: function updateTableRef() {
this.$refs.fixedColumnsBodyLeft && this.table.saveChildrenRef('fixedColumnsBodyLeft', this.$refs.fixedColumnsBodyLeft);
this.$refs.fixedColumnsBodyRight && this.table.saveChildrenRef('fixedColumnsBodyRight', this.$refs.fixedColumnsBodyRight);
this.$refs.bodyTable && this.table.saveChildrenRef('bodyTable', this.$refs.bodyTable);
}
},
render: function render() {
var h = arguments[0];
var _table = this.table,
prefixCls = _table.prefixCls,
scroll = _table.scroll;
var columns = this.columns,
fixed = this.fixed,
tableClassName = this.tableClassName,
getRowKey = this.getRowKey,
handleBodyScroll = this.handleBodyScroll,
handleWheel = this.handleWheel,
expander = this.expander,
isAnyColumnsFixed = this.isAnyColumnsFixed;
var useFixedHeader = this.table.useFixedHeader;
var bodyStyle = _extends({}, this.table.bodyStyle);
var innerBodyStyle = {};
if (scroll.x || fixed) {
bodyStyle.overflowX = bodyStyle.overflowX || 'scroll';
// Fix weired webkit render bug
// https://github.com/ant-design/ant-design/issues/7783
bodyStyle.WebkitTransform = 'translate3d (0, 0, 0)';
}
if (scroll.y) {
// maxHeight will make fixed-Table scrolling not working
// so we only set maxHeight to body-Table here
var maxHeight = bodyStyle.maxHeight || scroll.y;
maxHeight = typeof maxHeight === 'number' ? maxHeight + 'px' : maxHeight;
if (fixed) {
innerBodyStyle.maxHeight = maxHeight;
innerBodyStyle.overflowY = bodyStyle.overflowY || 'scroll';
} else {
bodyStyle.maxHeight = maxHeight;
}
bodyStyle.overflowY = bodyStyle.overflowY || 'scroll';
useFixedHeader = true;
// Add negative margin bottom for scroll bar overflow bug
var scrollbarWidth = measureScrollbar();
if (scrollbarWidth > 0 && fixed) {
bodyStyle.marginBottom = '-' + scrollbarWidth + 'px';
bodyStyle.paddingBottom = '0px';
}
}
var baseTable = h(BaseTable, {
attrs: {
tableClassName: tableClassName,
hasHead: !useFixedHeader,
hasBody: true,
fixed: fixed,
columns: columns,
expander: expander,
getRowKey: getRowKey,
isAnyColumnsFixed: isAnyColumnsFixed
}
});
if (fixed && columns.length) {
var refName = void 0;
if (columns[0].fixed === 'left' || columns[0].fixed === true) {
refName = 'fixedColumnsBodyLeft';
} else if (columns[0].fixed === 'right') {
refName = 'fixedColumnsBodyRight';
}
delete bodyStyle.overflowX;
delete bodyStyle.overflowY;
return h(
'div',
{ key: 'bodyTable', 'class': prefixCls + '-body-outer', style: _extends({}, bodyStyle) },
[h(
'div',
{
'class': prefixCls + '-body-inner',
style: innerBodyStyle,
ref: refName,
on: {
'wheel': handleWheel,
'scroll': handleBodyScroll
}
},
[baseTable]
)]
);
}
return h(
'div',
{
key: 'bodyTable',
'class': prefixCls + '-body',
style: bodyStyle,
ref: 'bodyTable',
on: {
'wheel': handleWheel,
'scroll': handleBodyScroll
}
},
[baseTable]
);
}
};