feat(bee-table): tableCell colSpan==0 return null & isLeaf 改为 _isLeaf
This commit is contained in:
parent
792698025a
commit
4452dc6a69
|
@ -879,11 +879,11 @@ var Table = function (_Component) {
|
|||
var record = data[i];
|
||||
var key = this.getRowKey(record, i);
|
||||
// 兼容 NCC 以前的业务逻辑,支持外部通过 record 中的 isleaf 字段,判断是否为叶子节点
|
||||
record['isLeaf'] = typeof record['isleaf'] === 'boolean' ? record['isleaf'] : record['isLeaf'];
|
||||
// isLeaf 字段是在 bigData 里添加的,只有层级树大数据场景需要该字段
|
||||
// isLeaf 有三种取值情况:true / false / null。(Table内部字段)
|
||||
var isLeaf = typeof record['isLeaf'] === 'boolean' ? record['isLeaf'] : null;
|
||||
var childrenColumn = isLeaf ? false : record[childrenColumnName];
|
||||
record['_isLeaf'] = typeof record['isleaf'] === 'boolean' ? record['isleaf'] : record['_isLeaf'];
|
||||
// _isLeaf 字段是在 bigData 里添加的,只有层级树大数据场景需要该字段
|
||||
// _isLeaf 有三种取值情况:true / false / null。(Table内部字段)
|
||||
var _isLeaf = typeof record['_isLeaf'] === 'boolean' ? record['_isLeaf'] : null;
|
||||
var childrenColumn = _isLeaf ? false : record[childrenColumnName];
|
||||
var isRowExpanded = this.isRowExpanded(record, i);
|
||||
var expandedRowContent = void 0;
|
||||
var expandedContentHeight = 0;
|
||||
|
@ -948,7 +948,7 @@ var Table = function (_Component) {
|
|||
visible: visible,
|
||||
expandRowByClick: expandRowByClick,
|
||||
onExpand: this.onExpanded,
|
||||
expandable: expandedRowRender || (childrenColumn && childrenColumn.length > 0 ? true : isLeaf === false),
|
||||
expandable: expandedRowRender || (childrenColumn && childrenColumn.length > 0 ? true : _isLeaf === false),
|
||||
expanded: isRowExpanded,
|
||||
clsPrefix: props.clsPrefix + '-row',
|
||||
childrenColumnName: childrenColumnName,
|
||||
|
|
|
@ -429,19 +429,22 @@ var TableCell = function (_Component) {
|
|||
className += ' u-table-inline-icon';
|
||||
}
|
||||
return _react2["default"].createElement(
|
||||
'td',
|
||||
{
|
||||
colSpan: colSpan,
|
||||
rowSpan: rowSpan,
|
||||
className: className,
|
||||
onClick: this.handleClick,
|
||||
title: title,
|
||||
style: _extends({ maxWidth: column.width, color: fontColor, backgroundColor: bgColor }, column.style)
|
||||
},
|
||||
indentText,
|
||||
expandIcon,
|
||||
text,
|
||||
colMenu
|
||||
_react.Fragment,
|
||||
null,
|
||||
colSpan == 0 ? null : _react2["default"].createElement(
|
||||
'td',
|
||||
{
|
||||
colSpan: colSpan,
|
||||
rowSpan: rowSpan,
|
||||
className: className,
|
||||
onClick: this.handleClick,
|
||||
title: title,
|
||||
style: _extends({ maxWidth: column.width, color: fontColor, backgroundColor: bgColor }, column.style) },
|
||||
indentText,
|
||||
expandIcon,
|
||||
text,
|
||||
colMenu
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -410,14 +410,14 @@ function bigData(Table) {
|
|||
children = _dataCopy$i.children,
|
||||
props = _objectWithoutProperties(_dataCopy$i, ["key", "children"]),
|
||||
dataCopyI = new Object(),
|
||||
isLeaf = children && children.length > 0 ? false : true,
|
||||
_isLeaf = children && children.length > 0 ? false : true,
|
||||
isExpanded = parentKey === null || expandedKeysSet.has(parentKey) ? expandedKeysSet.has(key) : false;
|
||||
|
||||
dataCopyI = _extends(dataCopyI, {
|
||||
key: key,
|
||||
isExpanded: isExpanded,
|
||||
parentKey: parentKey,
|
||||
isLeaf: isLeaf,
|
||||
_isLeaf: _isLeaf,
|
||||
index: flatTreeData.length
|
||||
}, _extends({}, props));
|
||||
|
||||
|
@ -439,7 +439,7 @@ function bigData(Table) {
|
|||
id: 'key',
|
||||
parendId: 'parentKey',
|
||||
rootId: null,
|
||||
isLeaf: 'isLeaf'
|
||||
_isLeaf: '_isLeaf'
|
||||
};
|
||||
var treeData = (0, _utils.convertListToTree)(treeList, attr, _this4.flatTreeKeysMap);
|
||||
|
||||
|
|
|
@ -371,13 +371,13 @@ var Event = exports.Event = {
|
|||
var key = node.key,
|
||||
title = node.title,
|
||||
children = node.children,
|
||||
isLeaf = node.isLeaf,
|
||||
otherProps = _objectWithoutProperties(node, ['key', 'title', 'children', 'isLeaf']);
|
||||
_isLeaf = node._isLeaf,
|
||||
otherProps = _objectWithoutProperties(node, ['key', 'title', 'children', '_isLeaf']);
|
||||
|
||||
var obj = {
|
||||
key: key,
|
||||
title: title,
|
||||
isLeaf: isLeaf,
|
||||
_isLeaf: _isLeaf,
|
||||
children: []
|
||||
};
|
||||
tree.push(_extends(obj, _extends({}, otherProps)));
|
||||
|
@ -397,7 +397,7 @@ var Event = exports.Event = {
|
|||
|
||||
var obj = {
|
||||
key: item[attr.id],
|
||||
isLeaf: item[attr.isLeaf],
|
||||
_isLeaf: item[attr._isLeaf],
|
||||
children: []
|
||||
};
|
||||
tree.push(_extends(obj, _extends({}, otherProps)));
|
||||
|
@ -423,7 +423,7 @@ var Event = exports.Event = {
|
|||
|
||||
var _obj = {
|
||||
key: _item[attr.id],
|
||||
isLeaf: _item[attr.isLeaf],
|
||||
_isLeaf: _item[attr._isLeaf],
|
||||
children: []
|
||||
};
|
||||
treeArrs[_i].children.push(_extends(_obj, _extends({}, _otherProps)));
|
||||
|
|
|
@ -38073,11 +38073,11 @@
|
|||
var record = data[i];
|
||||
var key = this.getRowKey(record, i);
|
||||
// 兼容 NCC 以前的业务逻辑,支持外部通过 record 中的 isleaf 字段,判断是否为叶子节点
|
||||
record['isLeaf'] = typeof record['isleaf'] === 'boolean' ? record['isleaf'] : record['isLeaf'];
|
||||
// isLeaf 字段是在 bigData 里添加的,只有层级树大数据场景需要该字段
|
||||
// isLeaf 有三种取值情况:true / false / null。(Table内部字段)
|
||||
var isLeaf = typeof record['isLeaf'] === 'boolean' ? record['isLeaf'] : null;
|
||||
var childrenColumn = isLeaf ? false : record[childrenColumnName];
|
||||
record['_isLeaf'] = typeof record['isleaf'] === 'boolean' ? record['isleaf'] : record['_isLeaf'];
|
||||
// _isLeaf 字段是在 bigData 里添加的,只有层级树大数据场景需要该字段
|
||||
// _isLeaf 有三种取值情况:true / false / null。(Table内部字段)
|
||||
var _isLeaf = typeof record['_isLeaf'] === 'boolean' ? record['_isLeaf'] : null;
|
||||
var childrenColumn = _isLeaf ? false : record[childrenColumnName];
|
||||
var isRowExpanded = this.isRowExpanded(record, i);
|
||||
var expandedRowContent = void 0;
|
||||
var expandedContentHeight = 0;
|
||||
|
@ -38142,7 +38142,7 @@
|
|||
visible: visible,
|
||||
expandRowByClick: expandRowByClick,
|
||||
onExpand: this.onExpanded,
|
||||
expandable: expandedRowRender || (childrenColumn && childrenColumn.length > 0 ? true : isLeaf === false),
|
||||
expandable: expandedRowRender || (childrenColumn && childrenColumn.length > 0 ? true : _isLeaf === false),
|
||||
expanded: isRowExpanded,
|
||||
clsPrefix: props.clsPrefix + '-row',
|
||||
childrenColumnName: childrenColumnName,
|
||||
|
@ -39911,13 +39911,13 @@
|
|||
var key = node.key,
|
||||
title = node.title,
|
||||
children = node.children,
|
||||
isLeaf = node.isLeaf,
|
||||
otherProps = _objectWithoutProperties(node, ['key', 'title', 'children', 'isLeaf']);
|
||||
_isLeaf = node._isLeaf,
|
||||
otherProps = _objectWithoutProperties(node, ['key', 'title', 'children', '_isLeaf']);
|
||||
|
||||
var obj = {
|
||||
key: key,
|
||||
title: title,
|
||||
isLeaf: isLeaf,
|
||||
_isLeaf: _isLeaf,
|
||||
children: []
|
||||
};
|
||||
tree.push(_extends(obj, _extends({}, otherProps)));
|
||||
|
@ -39937,7 +39937,7 @@
|
|||
|
||||
var obj = {
|
||||
key: item[attr.id],
|
||||
isLeaf: item[attr.isLeaf],
|
||||
_isLeaf: item[attr._isLeaf],
|
||||
children: []
|
||||
};
|
||||
tree.push(_extends(obj, _extends({}, otherProps)));
|
||||
|
@ -39963,7 +39963,7 @@
|
|||
|
||||
var _obj = {
|
||||
key: _item[attr.id],
|
||||
isLeaf: _item[attr.isLeaf],
|
||||
_isLeaf: _item[attr._isLeaf],
|
||||
children: []
|
||||
};
|
||||
treeArrs[_i].children.push(_extends(_obj, _extends({}, _otherProps)));
|
||||
|
@ -40821,19 +40821,22 @@
|
|||
className += ' u-table-inline-icon';
|
||||
}
|
||||
return _react2['default'].createElement(
|
||||
'td',
|
||||
{
|
||||
colSpan: colSpan,
|
||||
rowSpan: rowSpan,
|
||||
className: className,
|
||||
onClick: this.handleClick,
|
||||
title: title,
|
||||
style: _extends({ maxWidth: column.width, color: fontColor, backgroundColor: bgColor }, column.style)
|
||||
},
|
||||
indentText,
|
||||
expandIcon,
|
||||
text,
|
||||
colMenu
|
||||
_react.Fragment,
|
||||
null,
|
||||
colSpan == 0 ? null : _react2['default'].createElement(
|
||||
'td',
|
||||
{
|
||||
colSpan: colSpan,
|
||||
rowSpan: rowSpan,
|
||||
className: className,
|
||||
onClick: this.handleClick,
|
||||
title: title,
|
||||
style: _extends({ maxWidth: column.width, color: fontColor, backgroundColor: bgColor }, column.style) },
|
||||
indentText,
|
||||
expandIcon,
|
||||
text,
|
||||
colMenu
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -264171,14 +264174,14 @@
|
|||
children = _dataCopy$i.children,
|
||||
props = _objectWithoutProperties(_dataCopy$i, ["key", "children"]),
|
||||
dataCopyI = new Object(),
|
||||
isLeaf = children && children.length > 0 ? false : true,
|
||||
_isLeaf = children && children.length > 0 ? false : true,
|
||||
isExpanded = parentKey === null || expandedKeysSet.has(parentKey) ? expandedKeysSet.has(key) : false;
|
||||
|
||||
dataCopyI = _extends(dataCopyI, {
|
||||
key: key,
|
||||
isExpanded: isExpanded,
|
||||
parentKey: parentKey,
|
||||
isLeaf: isLeaf,
|
||||
_isLeaf: _isLeaf,
|
||||
index: flatTreeData.length
|
||||
}, _extends({}, props));
|
||||
|
||||
|
@ -264200,7 +264203,7 @@
|
|||
id: 'key',
|
||||
parendId: 'parentKey',
|
||||
rootId: null,
|
||||
isLeaf: 'isLeaf'
|
||||
_isLeaf: '_isLeaf'
|
||||
};
|
||||
var treeData = (0, _utils.convertListToTree)(treeList, attr, _this4.flatTreeKeysMap);
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bee-table",
|
||||
"version": "2.2.39",
|
||||
"version": "2.2.40",
|
||||
"description": "Table ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
|
|
12
src/Table.js
12
src/Table.js
|
@ -717,11 +717,11 @@ class Table extends Component {
|
|||
const record = data[i];
|
||||
const key = this.getRowKey(record, i);
|
||||
// 兼容 NCC 以前的业务逻辑,支持外部通过 record 中的 isleaf 字段,判断是否为叶子节点
|
||||
record['isLeaf'] = typeof record['isleaf'] === 'boolean' ? record['isleaf'] : record['isLeaf'];
|
||||
// isLeaf 字段是在 bigData 里添加的,只有层级树大数据场景需要该字段
|
||||
// isLeaf 有三种取值情况:true / false / null。(Table内部字段)
|
||||
const isLeaf = typeof record['isLeaf'] === 'boolean' ? record['isLeaf'] : null;
|
||||
const childrenColumn = isLeaf ? false : record[childrenColumnName];
|
||||
record['_isLeaf'] = typeof record['isleaf'] === 'boolean' ? record['isleaf'] : record['_isLeaf'];
|
||||
// _isLeaf 字段是在 bigData 里添加的,只有层级树大数据场景需要该字段
|
||||
// _isLeaf 有三种取值情况:true / false / null。(Table内部字段)
|
||||
const _isLeaf = typeof record['_isLeaf'] === 'boolean' ? record['_isLeaf'] : null;
|
||||
const childrenColumn = _isLeaf ? false : record[childrenColumnName];
|
||||
const isRowExpanded = this.isRowExpanded(record, i);
|
||||
let expandedRowContent;
|
||||
let expandedContentHeight = 0;
|
||||
|
@ -789,7 +789,7 @@ class Table extends Component {
|
|||
visible={visible}
|
||||
expandRowByClick={expandRowByClick}
|
||||
onExpand={this.onExpanded}
|
||||
expandable={expandedRowRender || ((childrenColumn && childrenColumn.length > 0) ? true : isLeaf === false)}
|
||||
expandable={expandedRowRender || ((childrenColumn && childrenColumn.length > 0) ? true : _isLeaf === false)}
|
||||
expanded={isRowExpanded}
|
||||
clsPrefix={`${props.clsPrefix}-row`}
|
||||
childrenColumnName={childrenColumnName}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { Component } from 'react';
|
||||
import React, { Component,Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import objectPath from 'object-path';
|
||||
import i18n from './lib/i18n';
|
||||
|
@ -281,19 +281,22 @@ class TableCell extends Component{
|
|||
className += ' u-table-inline-icon'
|
||||
}
|
||||
return (
|
||||
<td
|
||||
colSpan={colSpan}
|
||||
rowSpan={rowSpan}
|
||||
className={className}
|
||||
onClick={this.handleClick}
|
||||
title={title}
|
||||
style={{maxWidth:column.width, color:fontColor, backgroundColor:bgColor, ...column.style}}
|
||||
>
|
||||
{indentText}
|
||||
{expandIcon}
|
||||
{text}
|
||||
{colMenu}
|
||||
</td>
|
||||
<Fragment>
|
||||
{
|
||||
colSpan==0?null:<td
|
||||
colSpan={colSpan}
|
||||
rowSpan={rowSpan}
|
||||
className={className}
|
||||
onClick={this.handleClick}
|
||||
title={title}
|
||||
style={{maxWidth:column.width, color:fontColor, backgroundColor:bgColor, ...column.style}}>
|
||||
{indentText}
|
||||
{expandIcon}
|
||||
{text}
|
||||
{colMenu}
|
||||
</td>
|
||||
}
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -134,14 +134,14 @@ export default function bigData(Table) {
|
|||
for (let i=0, l=dataCopy.length; i<l; i++) {
|
||||
let { key, children, ...props } = dataCopy[i],
|
||||
dataCopyI = new Object(),
|
||||
isLeaf = (children && children.length > 0) ? false : true,
|
||||
_isLeaf = (children && children.length > 0) ? false : true,
|
||||
//如果父节点是收起状态,则子节点的展开状态无意义。(一级节点或根节点直接判断自身状态即可)
|
||||
isExpanded = (parentKey === null || expandedKeysSet.has(parentKey)) ? expandedKeysSet.has(key) : false;
|
||||
dataCopyI = Object.assign(dataCopyI,{
|
||||
key,
|
||||
isExpanded,
|
||||
parentKey : parentKey,
|
||||
isLeaf,
|
||||
_isLeaf,
|
||||
index: flatTreeData.length
|
||||
},{...props});
|
||||
|
||||
|
@ -166,7 +166,7 @@ export default function bigData(Table) {
|
|||
id: 'key',
|
||||
parendId: 'parentKey',
|
||||
rootId: null,
|
||||
isLeaf: 'isLeaf'
|
||||
_isLeaf: '_isLeaf'
|
||||
};
|
||||
let treeData = convertListToTree(treeList, attr, this.flatTreeKeysMap);
|
||||
|
||||
|
|
|
@ -347,11 +347,11 @@ export function convertListToTree(treeData, attr, flatTreeKeysMap) {
|
|||
}else{
|
||||
// 用 treeKeysMap 判断,避免重复累加
|
||||
if (!treeKeysMap.hasOwnProperty(node[attr.id]) ) {
|
||||
let { key, title, children, isLeaf, ...otherProps } = node;
|
||||
let { key, title, children, _isLeaf, ...otherProps } = node;
|
||||
let obj = {
|
||||
key,
|
||||
title,
|
||||
isLeaf,
|
||||
_isLeaf,
|
||||
children: []
|
||||
}
|
||||
tree.push(Object.assign(obj, {...otherProps}));
|
||||
|
@ -366,7 +366,7 @@ export function convertListToTree(treeData, attr, flatTreeKeysMap) {
|
|||
let { key, title, children, ...otherProps } = item;
|
||||
let obj = {
|
||||
key: item[attr.id],
|
||||
isLeaf: item[attr.isLeaf],
|
||||
_isLeaf: item[attr._isLeaf],
|
||||
children: []
|
||||
};
|
||||
tree.push(Object.assign(obj, {...otherProps}));
|
||||
|
@ -387,7 +387,7 @@ export function convertListToTree(treeData, attr, flatTreeKeysMap) {
|
|||
let { key, title, children, ...otherProps } = item;
|
||||
let obj = {
|
||||
key: item[attr.id],
|
||||
isLeaf: item[attr.isLeaf],
|
||||
_isLeaf: item[attr._isLeaf],
|
||||
children: []
|
||||
};
|
||||
treeArrs[i].children.push(Object.assign(obj, {...otherProps}));
|
||||
|
|
Loading…
Reference in New Issue