fix:设置expandIconAsCell后样式错乱的问题

This commit is contained in:
yangchch6 2019-07-11 20:52:45 +08:00
parent 9cbf5bf7be
commit 93f5ee329d
13 changed files with 95 additions and 84 deletions

View File

@ -179,6 +179,9 @@
overflow: hidden; } overflow: hidden; }
.u-table-body { .u-table-body {
position: relative; } position: relative; }
.u-table-body .u-table-row-expand-columns-in-body .expand-icon-con {
display: none;
pointer-events: none; }
.u-table-hiden-drag { .u-table-hiden-drag {
position: relative; } position: relative; }
.u-table-hiden-drag-li { .u-table-hiden-drag-li {
@ -221,12 +224,16 @@
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) { .u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) {
display: flex; display: flex;
flex-direction: row-reverse; } flex-direction: row-reverse; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body):nth-last-child(1):last-child {
border-right: none; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con { .u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con {
height: 15px; } height: 14px; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .uf { .u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .uf {
padding-left: 0; } padding: 0; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .u-table-row-expand-icon { .u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .u-table-row-expand-icon {
width: 0; } width: 2px; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .u-checkbox {
margin: 0; }
.u-table tr.tr-row-hover { .u-table tr.tr-row-hover {
background: rgb(235, 236, 240); } background: rgb(235, 236, 240); }
.u-table th, .u-table th,
@ -245,7 +252,10 @@
text-align: right; } text-align: right; }
.u-table th .expand-icon-con, .u-table th .expand-icon-con,
.u-table td .expand-icon-con { .u-table td .expand-icon-con {
cursor: pointer; } cursor: pointer;
display: inline-block;
font-size: 12px;
line-height: 12px; }
.u-table-sm td { .u-table-sm td {
padding: 8px 8px; } padding: 8px 8px; }
.u-table-lg td { .u-table-lg td {
@ -337,13 +347,12 @@
.u-table-row-expand-icon, .u-table-expanded-row-expand-icon { .u-table-row-expand-icon, .u-table-expanded-row-expand-icon {
cursor: pointer; cursor: pointer;
display: inline-block; display: inline-block;
margin-right: 0px; margin-right: 8px;
width: 14px; width: 14px;
height: 14px; height: 14px;
text-align: center; text-align: center;
line-height: 14px; line-height: 14px;
user-select: none; user-select: none; }
margin-right: 10px; }
.u-table-row-expand-icon.uf, .u-table-expanded-row-expand-icon.uf { .u-table-row-expand-icon.uf, .u-table-expanded-row-expand-icon.uf {
font-size: 12px; font-size: 12px;
padding: 0; } padding: 0; }

View File

@ -908,7 +908,7 @@ var Table = function (_Component) {
}; };
Table.prototype.getRows = function getRows(columns, fixed) { Table.prototype.getRows = function getRows(columns, fixed) {
//统计index只有含有鼠表结构才有用,因为数表结构时,固定列的索引取值有问题 //统计index只有含有树表结构才有用,因为树表结构时,固定列的索引取值有问题
this.treeRowIndex = 0; this.treeRowIndex = 0;
var rs = this.getRowsByData(this.state.data, true, 0, columns, fixed); var rs = this.getRowsByData(this.state.data, true, 0, columns, fixed);
return rs; return rs;
@ -993,7 +993,8 @@ var Table = function (_Component) {
footerScroll = _props3.footerScroll, footerScroll = _props3.footerScroll,
headerScroll = _props3.headerScroll, headerScroll = _props3.headerScroll,
_props3$hideHeaderScr = _props3.hideHeaderScroll, _props3$hideHeaderScr = _props3.hideHeaderScroll,
hideHeaderScroll = _props3$hideHeaderScr === undefined ? false : _props3$hideHeaderScr; hideHeaderScroll = _props3$hideHeaderScr === undefined ? false : _props3$hideHeaderScr,
expandIconAsCell = _props3.expandIconAsCell;
var _props4 = this.props, var _props4 = this.props,
useFixedHeader = _props4.useFixedHeader, useFixedHeader = _props4.useFixedHeader,
data = _props4.data; data = _props4.data;
@ -1172,9 +1173,10 @@ var Table = function (_Component) {
} }
var leftFixedWidth = this.columnManager.getLeftColumnsWidth(this.contentWidth); var leftFixedWidth = this.columnManager.getLeftColumnsWidth(this.contentWidth);
var rightFixedWidth = this.columnManager.getRightColumnsWidth(this.contentWidth); var rightFixedWidth = this.columnManager.getRightColumnsWidth(this.contentWidth);
var expandIconWidth = expandIconAsCell ? 33 : 0;
var parStyle = {}; var parStyle = {};
if (!fixed) { if (!fixed) {
parStyle = { 'marginLeft': leftFixedWidth, 'marginRight': rightFixedWidth }; parStyle = { 'marginLeft': leftFixedWidth + expandIconWidth, 'marginRight': rightFixedWidth };
} }
return _react2["default"].createElement( return _react2["default"].createElement(
'div', 'div',

View File

@ -560,13 +560,13 @@ var TableRow = function (_Component) {
collapsedIcon: collapsedIcon, collapsedIcon: collapsedIcon,
isHiddenExpandIcon: isHiddenExpandIcon isHiddenExpandIcon: isHiddenExpandIcon
}); });
var isExpandIconAsCell = expandIconAsCell ? clsPrefix + '-expand-columns-in-body' : '';
for (var i = 0; i < columns.length; i++) { for (var i = 0; i < columns.length; i++) {
if (expandIconAsCell && i === 0 && !showSum) { if (expandIconAsCell && i === 0 && !showSum) {
cells.push(_react2["default"].createElement( cells.push(_react2["default"].createElement(
'td', 'td',
{ {
className: clsPrefix + '-expand-icon-cell', className: clsPrefix + '-expand-icon-cell ' + isExpandIconAsCell,
key: 'rc-table-expand-icon-cell-' + i key: 'rc-table-expand-icon-cell-' + i
}, },
expandIcon expandIcon

View File

@ -2,20 +2,21 @@
* *
* @title 嵌套子表格 * @title 嵌套子表格
* @parent 扩展行 Expanded Row * @parent 扩展行 Expanded Row
* @description 通过expandedRowRender参数来实现子表格收起和展开的图标可自定义传入 * @description 通过expandedRowRender参数来实现子表格收起和展开的图标可自定义传入注意多选功能和嵌套表格一起使用时需要设置 expandIconAsCell={true}把展开按钮放在单元格中展示
* demo1101 * demo1101
*/ */
import React, { Component } from "react"; import React, { Component } from "react";
import { Popconfirm,Icon } from 'tinper-bee'; import { Popconfirm,Icon,Checkbox } from 'tinper-bee';
import Table from "../../src"; import Table from "../../src";
import multiSelect from "../../src/lib/multiSelect";
const columns16 = [ const columns16 = [
{ {
title: "操作", title: "操作",
dataIndex: "d", dataIndex: "d",
key: "d", key: "d",
width:200, width:100,
render(text, record, index) { render(text, record, index) {
return ( return (
<Popconfirm trigger="click" placement="right" content={'这是第' + index + '行,内容为:' + text}> <Popconfirm trigger="click" placement="right" content={'这是第' + index + '行,内容为:' + text}>
@ -32,25 +33,9 @@ const columns16 = [
]; ];
const columns17 = [ const columns17 = [
{
title: "操作",
dataIndex: "d",
key: "d",
width:200,
render(text, record, index) {
return (
<Popconfirm trigger="click" placement="right" content={'这是第' + index + '行,内容为:' + text}>
<a href="javascript:;" tooltip={text} >
一些操作
</a>
</Popconfirm>
);
}
},
{ title: "订单编号", dataIndex: "a", key: "a", width: 100 }, { title: "订单编号", dataIndex: "a", key: "a", width: 100 },
{ id: "123", title: "单据日期", dataIndex: "b", key: "b", width: 100 }, { id: "123", title: "单据日期", dataIndex: "b", key: "b", width: 100 },
{ title: "供应商", dataIndex: "c", key: "c", width: 200 }, { title: "供应商", dataIndex: "c", key: "c", width: 200 }
]; ];
const data16 = [ const data16 = [
@ -58,7 +43,7 @@ const data16 = [
{ a: "NU0391002", b: "2018-11-02", c: "yy供应商", d: "操作", key: "2" }, { a: "NU0391002", b: "2018-11-02", c: "yy供应商", d: "操作", key: "2" },
{ a: "NU0391003", b: "2019-05-03", c: "zz供应商", d: "操作", key: "3" } { a: "NU0391003", b: "2019-05-03", c: "zz供应商", d: "操作", key: "3" }
]; ];
const MultiSelectTable = multiSelect(Table,Checkbox);
class Demo16 extends Component { class Demo16 extends Component {
constructor(props){ constructor(props){
super(props); super(props);
@ -100,6 +85,7 @@ class Demo16 extends Component {
} }
} }
} }
haveExpandIcon=(record, index)=>{ haveExpandIcon=(record, index)=>{
//控制是否显示行展开icon该参数只有在和expandedRowRender同时使用才生效 //控制是否显示行展开icon该参数只有在和expandedRowRender同时使用才生效
if(index == 0){ if(index == 0){
@ -107,15 +93,16 @@ class Demo16 extends Component {
} }
return false; return false;
} }
render() { render() {
return ( return (
<Table <MultiSelectTable
className="expanded-table" className="expanded-table"
columns={columns16} columns={columns16}
data={data16} data={data16}
onExpand={this.getData} onExpand={this.getData}
expandedRowRender={this.expandedRowRender} expandedRowRender={this.expandedRowRender}
scroll={{x:true}} expandIconAsCell={true}
collapsedIcon={<Icon type='uf-anglearrowpointingtoright'/>} collapsedIcon={<Icon type='uf-anglearrowpointingtoright'/>}
expandedIcon={<Icon type='uf-treearrow-down'/>} expandedIcon={<Icon type='uf-treearrow-down'/>}
/> />

File diff suppressed because one or more lines are too long

23
dist/demo.css vendored
View File

@ -164,6 +164,9 @@
overflow: hidden; } overflow: hidden; }
.u-table-body { .u-table-body {
position: relative; } position: relative; }
.u-table-body .u-table-row-expand-columns-in-body .expand-icon-con {
display: none;
pointer-events: none; }
.u-table-hiden-drag { .u-table-hiden-drag {
position: relative; } position: relative; }
.u-table-hiden-drag-li { .u-table-hiden-drag-li {
@ -208,12 +211,16 @@
display: flex; display: flex;
-ms-flex-direction: row-reverse; -ms-flex-direction: row-reverse;
flex-direction: row-reverse; } flex-direction: row-reverse; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body):nth-last-child(1):last-child {
border-right: none; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con { .u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con {
height: 15px; } height: 14px; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .uf { .u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .uf {
padding-left: 0; } padding: 0; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .u-table-row-expand-icon { .u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .u-table-row-expand-icon {
width: 0; } width: 2px; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .u-checkbox {
margin: 0; }
.u-table tr.tr-row-hover { .u-table tr.tr-row-hover {
background: rgb(235, 236, 240); } background: rgb(235, 236, 240); }
.u-table th, .u-table th,
@ -232,7 +239,10 @@
text-align: right; } text-align: right; }
.u-table th .expand-icon-con, .u-table th .expand-icon-con,
.u-table td .expand-icon-con { .u-table td .expand-icon-con {
cursor: pointer; } cursor: pointer;
display: inline-block;
font-size: 12px;
line-height: 12px; }
.u-table-sm td { .u-table-sm td {
padding: 8px 8px; } padding: 8px 8px; }
.u-table-lg td { .u-table-lg td {
@ -324,7 +334,7 @@
.u-table-row-expand-icon, .u-table-expanded-row-expand-icon { .u-table-row-expand-icon, .u-table-expanded-row-expand-icon {
cursor: pointer; cursor: pointer;
display: inline-block; display: inline-block;
margin-right: 0px; margin-right: 8px;
width: 14px; width: 14px;
height: 14px; height: 14px;
text-align: center; text-align: center;
@ -332,8 +342,7 @@
-webkit-user-select: none; -webkit-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none; }
margin-right: 10px; }
.u-table-row-expand-icon.uf, .u-table-expanded-row-expand-icon.uf { .u-table-row-expand-icon.uf, .u-table-expanded-row-expand-icon.uf {
font-size: 12px; font-size: 12px;
padding: 0; } padding: 0; }

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

45
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

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

View File

@ -768,7 +768,7 @@ class Table extends Component {
} }
getRows(columns, fixed) { getRows(columns, fixed) {
//统计index只有含有鼠表结构才有用,因为数表结构时,固定列的索引取值有问题 //统计index只有含有树表结构才有用,因为树表结构时,固定列的索引取值有问题
this.treeRowIndex = 0; this.treeRowIndex = 0;
let rs = this.getRowsByData(this.state.data, true, 0, columns, fixed); let rs = this.getRowsByData(this.state.data, true, 0, columns, fixed);
return rs; return rs;
@ -846,7 +846,7 @@ class Table extends Component {
getTable(options = {}) { getTable(options = {}) {
const { columns, fixed } = options; const { columns, fixed } = options;
const { clsPrefix, scroll = {}, getBodyWrapper, footerScroll,headerScroll,hideHeaderScroll = false } = this.props; const { clsPrefix, scroll = {}, getBodyWrapper, footerScroll,headerScroll,hideHeaderScroll = false,expandIconAsCell } = this.props;
let { useFixedHeader,data } = this.props; let { useFixedHeader,data } = this.props;
const bodyStyle = { ...this.props.bodyStyle }; const bodyStyle = { ...this.props.bodyStyle };
const headStyle = {}; const headStyle = {};
@ -1018,9 +1018,10 @@ class Table extends Component {
} }
const leftFixedWidth = this.columnManager.getLeftColumnsWidth(this.contentWidth); const leftFixedWidth = this.columnManager.getLeftColumnsWidth(this.contentWidth);
const rightFixedWidth = this.columnManager.getRightColumnsWidth(this.contentWidth); const rightFixedWidth = this.columnManager.getRightColumnsWidth(this.contentWidth);
let expandIconWidth = expandIconAsCell ? 33 : 0;
let parStyle = {} let parStyle = {}
if(!fixed){ if(!fixed){
parStyle = {'marginLeft':leftFixedWidth,'marginRight':rightFixedWidth} parStyle = {'marginLeft':leftFixedWidth + expandIconWidth,'marginRight':rightFixedWidth}
} }
return <div style={parStyle}>{headTable}{BodyTable}</div>; return <div style={parStyle}>{headTable}{BodyTable}</div>;
} }

View File

@ -32,6 +32,10 @@ $icon-color:#505F79;
&-body{ &-body{
// overflow: hidden!important; // overflow: hidden!important;
position: relative; position: relative;
.u-table-row-expand-columns-in-body .expand-icon-con {
display: none;
pointer-events: none;
}
} }
&-hiden-drag{ &-hiden-drag{
position: relative; position: relative;
@ -105,15 +109,21 @@ $icon-color:#505F79;
td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body){ td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body){
display: flex; display: flex;
flex-direction: row-reverse; flex-direction: row-reverse;
&:nth-last-child(1):last-child {
border-right: none;
}
.expand-icon-con { .expand-icon-con {
height: 15px; height: 14px;
.uf{ .uf{
padding-left: 0; padding: 0;
} }
.u-table-row-expand-icon { .u-table-row-expand-icon {
width: 0; width: 2px;
} }
} }
.u-checkbox {
margin: 0;
}
} }
} }
tr.tr-row-hover { tr.tr-row-hover {
@ -138,6 +148,9 @@ $icon-color:#505F79;
} }
.expand-icon-con{ .expand-icon-con{
cursor: pointer; cursor: pointer;
display: inline-block;
font-size: 12px;
line-height: 12px;
} }
} }
&-sm { &-sm {
@ -299,13 +312,12 @@ $icon-color:#505F79;
&-expand-icon { &-expand-icon {
cursor: pointer; cursor: pointer;
display: inline-block; display: inline-block;
margin-right: 0px; margin-right: 8px;
width: 14px; width: 14px;
height: 14px; height: 14px;
text-align: center; text-align: center;
line-height: 14px; line-height: 14px;
user-select: none; user-select: none;
margin-right: 10px;
&.uf{ &.uf{
font-size: 12px; font-size: 12px;
padding: 0; padding: 0;

View File

@ -444,12 +444,12 @@ class TableRow extends Component{
isHiddenExpandIcon={isHiddenExpandIcon} isHiddenExpandIcon={isHiddenExpandIcon}
/> />
); );
let isExpandIconAsCell = expandIconAsCell ? `${clsPrefix}-expand-columns-in-body` : '';
for (let i = 0; i < columns.length; i++) { for (let i = 0; i < columns.length; i++) {
if (expandIconAsCell && i === 0 && !showSum ) { if (expandIconAsCell && i === 0 && !showSum ) {
cells.push( cells.push(
<td <td
className={`${clsPrefix}-expand-icon-cell`} className={`${clsPrefix}-expand-icon-cell ${isExpandIconAsCell}`}
key={`rc-table-expand-icon-cell-${i}`} key={`rc-table-expand-icon-cell-${i}`}
> >
{expandIcon} {expandIcon}