2.3.15-beta.6

This commit is contained in:
gx-mac 2021-03-04 16:40:17 +08:00
parent e072df43fb
commit f1dfb9c85f
5 changed files with 66 additions and 3 deletions

View File

@ -292,6 +292,17 @@ var Table = function (_Component) {
return Number(tdPaddingTop.replace('px', '')) + Number(tdPaddingBottom.replace('px', '')) + Number(tdBorderTop.replace('px', '')) + Number(tdBorderBottom.replace('px', ''));
};
_this.getFlatRecords = function (data) {
var result = [];
for (var i = 0; i < data.length; i++) {
result.push(data[i]);
if ((data[i].children || []).length) {
result = result.concat(_this.getFlatRecords(data[i].children));
}
}
return result;
};
_this.clearBodyMouseLeaveTimer = function () {
if (_this.bodyMouseLeaveTimmer) {
clearTimeout(_this.bodyMouseLeaveTimmer);
@ -1504,11 +1515,21 @@ var Table = function (_Component) {
}
return headerHeight ? height : parseInt(row.getBoundingClientRect().height) || 'auto';
});
var flatRecords = this.getFlatRecords(this.props.data || []);
var fixedColumnsBodyRowsHeight = [].map.call(bodyRows, function (row, index) {
var rsHeight = height;
if (bodyDisplayInRow && rsHeight) {
return rsHeight;
} else {
var rowKey = row.getAttribute('data-row-key');
var record = flatRecords.find(function (record) {
return record.key === rowKey;
}) || {};
var leafKey = 'isleaf' in record ? 'isleaf' : '_isLeaf' in record ? '_isLeaf' : null; // ncc传递这俩属性区分是否是子节点
var isLeaf = leafKey && record[leafKey] === true;
if (isLeaf) {
return Number(Number(row.getBoundingClientRect().height).toFixed(2)) || 'auto';
}
// 为了提高性能,默认获取主表的高度,但是有的场景中固定列的高度比主表的高度高,所以提供此属性,会统计所有列的高度取最大的,设置
// 内容折行显示,并又设置了 height 的情况下,也要获取主表高度
if (heightConsistent || !bodyDisplayInRow && rsHeight) {

25
dist/demo.js vendored
View File

@ -48201,6 +48201,17 @@
return Number(tdPaddingTop.replace('px', '')) + Number(tdPaddingBottom.replace('px', '')) + Number(tdBorderTop.replace('px', '')) + Number(tdBorderBottom.replace('px', ''));
};
_this.getFlatRecords = function (data) {
var result = [];
for (var i = 0; i < data.length; i++) {
result.push(data[i]);
if ((data[i].children || []).length) {
result = result.concat(_this.getFlatRecords(data[i].children));
}
}
return result;
};
_this.clearBodyMouseLeaveTimer = function () {
if (_this.bodyMouseLeaveTimmer) {
clearTimeout(_this.bodyMouseLeaveTimmer);
@ -48423,7 +48434,7 @@
this.isShowScrollY();
if (this.bodyTable) {
var currentOverflowX = window.getComputedStyle(this.bodyTable).overflowX;
if ((!this.props.scroll.x || this.props.scroll.x === '100%') && currentOverflowX === 'scroll') {
if ((!this.props.scroll.x || this.props.scroll.x === '100%') && currentOverflowX !== 'hidden') {
this.bodyTable.style.overflowX = 'hidden';
}
if (this.props.scroll.x && this.props.scroll.x !== '100%' && currentOverflowX !== 'scroll') {
@ -49138,6 +49149,8 @@
innerBodyStyle.overflowY = bodyStyle.overflowY || 'scroll';
if (scroll.x && scroll.x !== '100%') {
innerBodyStyle.overflowX = 'scroll';
} else {
innerBodyStyle.overflowX = 'hidden';
}
} else {
bodyStyle.maxHeight = bodyStyle.maxHeight || scroll.y;
@ -49411,11 +49424,21 @@
}
return headerHeight ? height : parseInt(row.getBoundingClientRect().height) || 'auto';
});
var flatRecords = this.getFlatRecords(this.props.data || []);
var fixedColumnsBodyRowsHeight = [].map.call(bodyRows, function (row, index) {
var rsHeight = height;
if (bodyDisplayInRow && rsHeight) {
return rsHeight;
} else {
var rowKey = row.getAttribute('data-row-key');
var record = flatRecords.find(function (record) {
return record.key === rowKey;
}) || {};
var leafKey = 'isleaf' in record ? 'isleaf' : '_isLeaf' in record ? '_isLeaf' : null; // ncc传递这俩属性区分是否是子节点
var isLeaf = leafKey && record[leafKey] === true;
if (isLeaf) {
return Number(Number(row.getBoundingClientRect().height).toFixed(2)) || 'auto';
}
// 为了提高性能,默认获取主表的高度,但是有的场景中固定列的高度比主表的高度高,所以提供此属性,会统计所有列的高度取最大的,设置
// 内容折行显示,并又设置了 height 的情况下,也要获取主表高度
if (heightConsistent || !bodyDisplayInRow && rsHeight) {

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "bee-table",
"version": "2.3.15-beta.5",
"version": "2.3.15-beta.6",
"description": "Table ui component for react",
"keywords": [
"react",

View File

@ -1255,6 +1255,17 @@ class Table extends Component {
}
getFlatRecords = data => {
var result = []
for (var i = 0; i < data.length; i++) {
result.push(data[i])
if ((data[i].children || []).length) {
result = result.concat(this.getFlatRecords(data[i].children))
}
}
return result
};
syncFixedTableRowHeight() {
//this.props.height、headerHeight分别为用户传入的行高和表头高度如果有值所有行的高度都是固定的主要为了避免在千行数据中有固定列时获取行高度有问题
const { clsPrefix, height, headerHeight,columns,heightConsistent, bodyDisplayInRow } = this.props;
@ -1273,12 +1284,20 @@ class Table extends Component {
}
return headerHeight ? height : (parseInt(row.getBoundingClientRect().height) || 'auto')}
);
const flatRecords = this.getFlatRecords(this.props.data || [])
const fixedColumnsBodyRowsHeight = [].map.call(
bodyRows, (row,index) =>{
let rsHeight = height;
if(bodyDisplayInRow && rsHeight){
return rsHeight;
}else{
const rowKey = row.getAttribute('data-row-key')
const record = flatRecords.find(record => record.key === rowKey) || {}
const leafKey = 'isleaf' in record ? 'isleaf' : '_isLeaf' in record ? '_isLeaf' : null // ncc传递这俩属性区分是否是子节点
const isLeaf = leafKey && record[leafKey] === true
if (isLeaf) {
return Number((Number(row.getBoundingClientRect().height)).toFixed(2)) || 'auto';
}
// 为了提高性能,默认获取主表的高度,但是有的场景中固定列的高度比主表的高度高,所以提供此属性,会统计所有列的高度取最大的,设置
// 内容折行显示,并又设置了 height 的情况下,也要获取主表高度
if(heightConsistent || (!bodyDisplayInRow && rsHeight)){