fix: update时判断表格数据

This commit is contained in:
izbz wh 2020-12-15 20:55:48 +08:00
parent 7558e57018
commit 9e7b9f763d
6 changed files with 19 additions and 16 deletions

View File

@ -459,7 +459,7 @@ var Table = function (_Component) {
Table.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
// todo: IE 大数据渲染,行高不固定,且设置了 heightConsistent={true} 时,滚动加载操作会导致 ie11 浏览器崩溃
// https://github.com/tinper-bee/bee-table/commit/bd2092cdbaad236ff89477304e58dea93325bf09
if (this.columnManager.isAnyColumnsFixed()) {
if (this.columnManager.isAnyColumnsFixed() && !prevProps.height && prevProps.data == this.props.data) {
this.syncFixedTableRowHeight();
}
@ -1437,7 +1437,7 @@ var Table = function (_Component) {
if (headerHeight) {
height = ((0, _utils.getMaxColChildrenLength)(columns) + 1) * headerHeight;
}
return headerHeight ? height : row.getBoundingClientRect().height || 'auto';
return headerHeight ? height : parseInt(row.getBoundingClientRect().height) || 'auto';
});
var fixedColumnsBodyRowsHeight = [].map.call(bodyRows, function (row, index) {
var rsHeight = height;
@ -1451,13 +1451,13 @@ var Table = function (_Component) {
rightHeight = void 0,
currentHeight = void 0,
maxHeight = void 0;
leftHeight = leftBodyRows[index] ? leftBodyRows[index].getBoundingClientRect().height : 0;
rightHeight = rightBodyRows[index] ? rightBodyRows[index].getBoundingClientRect().height : 0;
currentHeight = row.getBoundingClientRect().height;
leftHeight = leftBodyRows[index] ? parseInt(leftBodyRows[index].getBoundingClientRect().height) : 0;
rightHeight = rightBodyRows[index] ? parseInt(rightBodyRows[index].getBoundingClientRect().height) : 0;
currentHeight = parseInt(row.getBoundingClientRect().height);
maxHeight = Math.max(leftHeight, rightHeight, currentHeight);
return maxHeight || 'auto';
} else {
return row.getBoundingClientRect().height || 'auto';
return parseInt(row.getBoundingClientRect().height) || 'auto';
}
}
});
@ -1465,19 +1465,20 @@ var Table = function (_Component) {
// expandedRows为NodeList Array.prototype.forEach ie 下报错 对象不支持 “forEach” 方法
expandedRows.length > 0 && Array.prototype.forEach.call(expandedRows, function (row) {
var parentRowKey = row && row.previousSibling && row.previousSibling.getAttribute("data-row-key"),
height = row && row.getBoundingClientRect().height || 'auto';
height = row && parseInt(row.getBoundingClientRect().height) || 'auto';
try {
//子表数据减少时,动态计算高度
var td = row.querySelector('td');
var tdPadding = _this5.getTdPadding(td);
var trueheight = row.querySelectorAll('.u-table')[0].getBoundingClientRect().height;
var trueheight = parseInt(row.querySelectorAll('.u-table')[0].getBoundingClientRect().height);
height = trueheight + tdPadding;
} catch (error) {}
fixedColumnsExpandedRowsHeight[parentRowKey] = height;
fixedColumnsExpandedRowsHeight[parentRowKey] = parseInt(height);
});
if ((0, _shallowequal2["default"])(this.state.fixedColumnsHeadRowsHeight, fixedColumnsHeadRowsHeight) && (0, _shallowequal2["default"])(this.state.fixedColumnsBodyRowsHeight, fixedColumnsBodyRowsHeight) && (0, _shallowequal2["default"])(this.state.fixedColumnsExpandedRowsHeight, fixedColumnsExpandedRowsHeight)) {
return;
}
this.setState({
fixedColumnsHeadRowsHeight: fixedColumnsHeadRowsHeight,
fixedColumnsBodyRowsHeight: fixedColumnsBodyRowsHeight,

View File

@ -607,7 +607,7 @@ var _initialiseProps = function _initialiseProps() {
}
var currentObj = _this8.table.cols[currentIndex];
_this8.drag.currIndex = currentIndex;
_this8.drag.oldLeft = event.x;
_this8.drag.oldLeft = event.clientX;
_this8.drag.oldWidth = parseInt(currentObj.style.width);
_this8.drag.minWidth = currentObj.style.minWidth != "" ? parseInt(currentObj.style.minWidth) : defaultWidth;
_this8.drag.tableWidth = parseInt(_this8.table.table.style.width ? _this8.table.table.style.width : _this8.table.table.scrollWidth);
@ -680,7 +680,7 @@ var _initialiseProps = function _initialiseProps() {
if (_this8.props.dragborder && _this8.drag.option == "border") {
//移动改变宽度
var currentCols = _this8.table.cols[_this8.drag.currIndex];
var diff = event.x - _this8.drag.oldLeft;
var diff = event.clientX - _this8.drag.oldLeft;
var newWidth = _this8.drag.oldWidth + diff;
_this8.drag.newWidth = newWidth > 0 ? newWidth : _this8.minWidth;
if (newWidth > _this8.minWidth) {

View File

@ -249,7 +249,8 @@ function sort(Table, Icon) {
this.multiSort = function (columns) {
var _state = _this3.state,
data = _state.data,
oldData = _state.oldData;
_state$oldData = _state.oldData,
oldData = _state$oldData === undefined ? [] : _state$oldData;
var self = _this3;
var orderCols = {},
@ -274,7 +275,8 @@ function sort(Table, Icon) {
this.toggleSortOrder = function (order, column) {
var _state2 = _this3.state,
data = _state2.data,
oldData = _state2.oldData,
_state2$oldData = _state2.oldData,
oldData = _state2$oldData === undefined ? [] : _state2$oldData,
flatColumns = _state2.flatColumns;
var sort = _this3.props.sort;

2
dist/demo.js vendored
View File

@ -48143,7 +48143,7 @@
Table.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
// todo: IE 大数据渲染,行高不固定,且设置了 heightConsistent={true} 时,滚动加载操作会导致 ie11 浏览器崩溃
// https://github.com/tinper-bee/bee-table/commit/bd2092cdbaad236ff89477304e58dea93325bf09
if (this.columnManager.isAnyColumnsFixed() && !prevProps.height) {
if (this.columnManager.isAnyColumnsFixed() && !prevProps.height && prevProps.data == this.props.data) {
this.syncFixedTableRowHeight();
}

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -251,7 +251,7 @@ class Table extends Component {
componentDidUpdate(prevProps, prevState) {
// todo: IE 大数据渲染,行高不固定,且设置了 heightConsistent={true} 时,滚动加载操作会导致 ie11 浏览器崩溃
// https://github.com/tinper-bee/bee-table/commit/bd2092cdbaad236ff89477304e58dea93325bf09
if(this.columnManager.isAnyColumnsFixed() && !prevProps.height) {
if(this.columnManager.isAnyColumnsFixed() && !prevProps.height && prevProps.data == this.props.data) {
this.syncFixedTableRowHeight();
}