fix(表格合计问题、多表头headerHeight问题):
This commit is contained in:
parent
6784947b67
commit
6e4a08be89
|
@ -278,6 +278,9 @@ var Table = function (_Component) {
|
|||
|
||||
//如果用户传了scroll.x按用户传的为主
|
||||
var setWidthParam = this.props.scroll.x;
|
||||
var computeObj = this.columnManager.getColumnWidth(this.contentWidth);
|
||||
var lastShowIndex = computeObj.lastShowIndex;
|
||||
this.computeWidth = computeObj.computeWidth;
|
||||
if (typeof setWidthParam == 'number') {
|
||||
var numSetWidthParam = parseInt(setWidthParam);
|
||||
this.contentWidth = numSetWidthParam;
|
||||
|
@ -287,13 +290,12 @@ var Table = function (_Component) {
|
|||
this.contentDomWidth = this.contentTable.getBoundingClientRect().width; //表格容器宽度
|
||||
|
||||
this.contentWidth = this.contentDomWidth; //默认与容器宽度一样
|
||||
this.domWidthDiff = this.contentDomWidth - this.computeWidth;
|
||||
if (typeof setWidthParam == 'string' && setWidthParam.indexOf('%')) {
|
||||
this.contentWidth = this.contentWidth * parseInt(setWidthParam) / 100;
|
||||
}
|
||||
}
|
||||
var computeObj = this.columnManager.getColumnWidth(this.contentWidth);
|
||||
var lastShowIndex = computeObj.lastShowIndex;
|
||||
this.computeWidth = computeObj.computeWidth;
|
||||
|
||||
if (this.computeWidth < this.contentWidth) {
|
||||
var contentWidthDiff = this.scrollbarWidth ? this.contentWidth - this.computeWidth - this.scrollbarWidth : this.contentWidth - this.computeWidth;
|
||||
//bordered的表格需要减去边框的差值1
|
||||
|
@ -761,7 +763,15 @@ var Table = function (_Component) {
|
|||
headStyle.marginBottom = '0px';
|
||||
}
|
||||
} else {
|
||||
(fixed ? bodyStyle : headStyle).marginBottom = '-' + scrollbarWidth + 'px';
|
||||
if (fixed) {
|
||||
if (this.domWidthDiff > 0) {
|
||||
innerBodyStyle.overflowX = 'auto';
|
||||
} else {
|
||||
bodyStyle.marginBottom = '-' + scrollbarWidth + 'px';
|
||||
}
|
||||
} else {
|
||||
headStyle.marginBottom = '-' + scrollbarWidth + 'px';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,26 +43,29 @@ function sum(Table) {
|
|||
_this.currentFooter = function () {
|
||||
var data_2 = _this.props.data;
|
||||
var columns_sum = _this.props.columns.concat();
|
||||
var sumCol_index = void 0;
|
||||
var sumCol_index = void 0,
|
||||
sumColIndexArr = [];
|
||||
//用一个对象存储合计数据,这里合计对象的属性对应每列字段
|
||||
for (var i = 0; i < columns_sum.length; i++) {
|
||||
if (columns_sum[i].sumCol) {
|
||||
sumCol_index = columns_sum[i].dataIndex;
|
||||
break;
|
||||
sumColIndexArr.push(columns_sum[i].dataIndex);
|
||||
}
|
||||
}
|
||||
var obj = {};
|
||||
obj[sumCol_index] = 0;
|
||||
if (Array.isArray(data_2)) {
|
||||
for (var _i = 0; _i < data_2.length; _i++) {
|
||||
if (typeof data_2[_i][sumCol_index] == "number" || !isNaN(data_2[_i][sumCol_index])) {
|
||||
obj[sumCol_index] -= -data_2[_i][sumCol_index];
|
||||
} else {
|
||||
obj[sumCol_index] = "";
|
||||
sumColIndexArr.forEach(function (sumCol_index) {
|
||||
|
||||
obj[sumCol_index] = 0;
|
||||
if (Array.isArray(data_2)) {
|
||||
for (var _i = 0; _i < data_2.length; _i++) {
|
||||
if (typeof data_2[_i][sumCol_index] == "number" || !isNaN(data_2[_i][sumCol_index])) {
|
||||
obj[sumCol_index] -= -data_2[_i][sumCol_index];
|
||||
} else {
|
||||
obj[sumCol_index] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
obj.key = "sumData";
|
||||
obj.key = sumCol_index + "sumData";
|
||||
});
|
||||
obj.showSum = "合计";
|
||||
obj = [obj];
|
||||
//将设置的和用户传入的合并属性
|
||||
|
|
|
@ -185,6 +185,5 @@ function getColChildrenLength(columns, chilrenLen) {
|
|||
chilrenLen = getColChildrenLength(item.children, chilrenLen + 1);
|
||||
}
|
||||
});
|
||||
console.log(chilrenLen);
|
||||
return chilrenLen;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bee-table",
|
||||
"version": "1.4.37",
|
||||
"version": "1.4.38",
|
||||
"description": "Table ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
|
|
Loading…
Reference in New Issue