支持用户自定义展开和关闭图标

This commit is contained in:
izbz wh 2019-05-08 23:02:28 +08:00
parent 0b24e76178
commit be75c6e9e8
10 changed files with 4880 additions and 19579 deletions

3
dist/demo.css vendored
View File

@ -209,6 +209,9 @@
.u-table th.text-right, .u-table th.text-right,
.u-table td.text-right { .u-table td.text-right {
text-align: right; } text-align: right; }
.u-table th .expand-icon-con,
.u-table td .expand-icon-con {
cursor: pointer; }
.u-table-sm td { .u-table-sm td {
padding: 8px 8px; } padding: 8px 8px; }
.u-table-lg td { .u-table-lg td {

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

24419
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -85,7 +85,8 @@ import 'bee-table/build/Table.css';
| headerDisplayInRow | 设置表头的内容显示一行,超出显示省略号 | bool | | headerDisplayInRow | 设置表头的内容显示一行,超出显示省略号 | bool |
| bodyDisplayInRow | 设置表体的内容显示一行,超出显示省略号 | bool | | bodyDisplayInRow | 设置表体的内容显示一行,超出显示省略号 | bool |
| rowDraggAble | 是否增加行交换顺序功能 | boolean| false | rowDraggAble | 是否增加行交换顺序功能 | boolean| false
|expandedIcon|嵌套表格场景中展开子表时的展开图标|||
|collapsedIcon|嵌套表格场景中关闭子表时的关闭图标|||
> 快捷键部分参考示例 (快捷键在table中的简单使用应用) > 快捷键部分参考示例 (快捷键在table中的简单使用应用)
*注意: data参数中的key值必需否则会导致部分功能出现问题建议使用唯一的值如id* *注意: data参数中的key值必需否则会导致部分功能出现问题建议使用唯一的值如id*

View File

@ -93,4 +93,4 @@
"tinper-bee": "latest", "tinper-bee": "latest",
"ref-tree": "2.0.1-beta.1" "ref-tree": "2.0.1-beta.1"
} }
} }

View File

@ -20,16 +20,20 @@ class ExpandIcon extends Component{
return !shallowequal(nextProps, this.props); return !shallowequal(nextProps, this.props);
} }
render() { render() {
const { expandable, clsPrefix, onExpand, needIndentSpaced, expanded, record, isHiddenExpandIcon } = this.props; const { expandable, clsPrefix, onExpand, needIndentSpaced, expanded, record, isHiddenExpandIcon,expandedIcon,collapsedIcon } = this.props;
if (expandable && !isHiddenExpandIcon) { if (expandable && !isHiddenExpandIcon) {
const expandClassName = expanded ? 'expanded' : 'collapsed'; const expandClassName = expanded ? 'expanded' : 'collapsed';
return ( let currentIcon = <Icon
<Icon className={`${clsPrefix}-expand-icon ${clsPrefix}-${expandClassName}`}
className={`${clsPrefix}-expand-icon ${clsPrefix}-${expandClassName}`} type={expanded ? 'uf-triangle-down' : 'uf-triangle-right'}
type={expanded ? 'uf-triangle-down' : 'uf-triangle-right'}
onClick={(e) => onExpand(!expanded, record, e)} />;
/> if(expanded && expandedIcon){
); currentIcon = expandedIcon;
}else if(!expanded && collapsedIcon){
currentIcon = collapsedIcon;
}
return (<span onClick={(e) => onExpand(!expanded, record, e)} className='expand-icon-con'>{currentIcon}</span>);
} else if (needIndentSpaced || isHiddenExpandIcon) { } else if (needIndentSpaced || isHiddenExpandIcon) {
return <span className={`${clsPrefix}-expand-icon ${clsPrefix}-spaced`} />; return <span className={`${clsPrefix}-expand-icon ${clsPrefix}-spaced`} />;
} }

View File

@ -702,6 +702,8 @@ class Table extends Component {
onDragRow={this.onDragRow} onDragRow={this.onDragRow}
contentTable={this.contentTable} contentTable={this.contentTable}
tableUid = {this.tableUid} tableUid = {this.tableUid}
expandedIcon={props.expandedIcon}
collapsedIcon={props.collapsedIcon}
/> />
); );
this.treeRowIndex++; this.treeRowIndex++;

View File

@ -117,6 +117,9 @@ $icon-color:#505F79;
&.text-right{ &.text-right{
text-align: right; text-align: right;
} }
.expand-icon-con{
cursor: pointer;
}
} }
&-sm { &-sm {
td { td {

View File

@ -353,6 +353,7 @@ class TableRow extends Component{
clsPrefix, columns, record, height, visible, index, clsPrefix, columns, record, height, visible, index,
expandIconColumnIndex, expandIconAsCell, expanded, expandRowByClick,rowDraggAble, expandIconColumnIndex, expandIconAsCell, expanded, expandRowByClick,rowDraggAble,
expandable, onExpand, needIndentSpaced, indent, indentSize,isHiddenExpandIcon,fixed,bodyDisplayInRow expandable, onExpand, needIndentSpaced, indent, indentSize,isHiddenExpandIcon,fixed,bodyDisplayInRow
,expandedIcon,collapsedIcon
} = this.props; } = this.props;
let showSum = false; let showSum = false;
let { className } = this.props; let { className } = this.props;
@ -373,6 +374,8 @@ class TableRow extends Component{
needIndentSpaced={needIndentSpaced} needIndentSpaced={needIndentSpaced}
expanded={expanded} expanded={expanded}
record={record} record={record}
expandedIcon={expandedIcon}
collapsedIcon={collapsedIcon}
isHiddenExpandIcon={isHiddenExpandIcon} isHiddenExpandIcon={isHiddenExpandIcon}
/> />
); );