This commit is contained in:
izbz wh 2019-04-18 11:19:28 +08:00
commit 08d4836850
45 changed files with 1056 additions and 814 deletions

View File

@ -94,7 +94,7 @@ class Demo extends Component {
| title | 表格标题 | Function | - |
| footer | 表格尾部 | Function | - |
| emptyText | 无数据时显示的内容 | Function | () => 'No Data' |
| scroll | 横向或纵向支持滚动,也可用于指定滚动区域的宽高度{ x: true, y: 300 } | object | {} |
| scroll | 横向或纵向支持滚动,也可用于指定滚动区域的宽高度| `{ x: number | true | 百分比, y: number }` | {} |
| rowRef | 获取行的ref | Function(record, index, indent):string | () => null |
| getBodyWrapper | 添加对table body的包装 | Function(body) | body => body |
| expandedRowRender | 额外的展开行 | Function(record, index, indent):node | - |
@ -115,6 +115,8 @@ class Demo extends Component {
| onTableKeyDown | 触发table的快捷键 | function| -
| tabIndex | 设置焦点顺序 | number | 0
| loadBuffer | 使用BigData高阶组件实现大数据加载时上下加载的缓存 | number| 5
| height | 自定义表格行高 | number | - |
| headerHeight | 自定义表头行高 | number | - |
> 快捷键部分参考示例 (快捷键在table中的简单使用应用)

View File

@ -33,3 +33,9 @@
}
}
.opt-btns .u-button{
background: #505F79;
&:hover, &:active{
background: #344563;
}
}

View File

@ -1,7 +1,7 @@
/**
*
* @title 基本表格
* Tooltip
* @parent 基础 Basic
* @description 鼠标hover行时呼出操作按钮
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 默认无数据展示
* @parent 基础 Basic
* @description 无数据时显示效果展示可自定义
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 固定表头
* @parent 基础 Basic
* @description 设置`scroll.y`指定滚动区域的高度添加纵向滚动条达到固定表头效果
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 隔行换色
* @parent 基础 Basic
* @description 可自定义斑马线颜色
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 表格 Loading 加载
* @parent 基础 Basic
* @description loading可以传boolean或者object对象object为bee-loading组件的参数类型
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 嵌套子表格
* @parent 扩展行 Expanded Row
* @description 通过expandedRowRender参数来实现子表格
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 层级树型展示
* @parent 扩展行 Expanded Row
* @description 通过在data中配置children数据来自动生成树形表格
*
*/

View File

@ -1,7 +1,8 @@
/**
*
* @title 选中行颜色自定义表格标题和表尾
* @description
* @parent 扩展行 Expanded Row
* @description 选中行的样式可自定义
*/
import React, { Component } from "react";

View File

@ -1,6 +1,7 @@
/**
*
* @title 自定义行高
* @parent 扩展行 Expanded Row
* @description 设置`height`属性自定义表格行高设置`headerHeight`属性自定义表头高度
*/

View File

@ -1,122 +1,120 @@
/**
*
* @title 自定义行列合并
* @description 表头只支持列合并使用 column 里的 colSpan 进行设置表格支持行/列合并使用 render 里的单元格属性 colSpan 或者 rowSpan 设值为 0 设置的表格不会渲染
*
* @title 根据内容自动撑开行高
* @parent 扩展行 Expanded Row
* @description 表格行含有图片时的展示
*/
import React, { Component } from "react";
import {Button,Tooltip} from "tinper-bee";
import Table from "../../src";
const renderContent = (value, row, index) => {
const obj = {
children: value,
props: {},
};
if (index === 4) {
obj.props.colSpan = 0;
const columns = [
{
title: "序号",
dataIndex: "index",
key: "index",
width: 80,
render(record, text, index) {
return index + 1;
}
return obj;
};
const columns = [{
title: 'Name',
key: "name",
dataIndex: 'name',
render: (text, row, index) => {
if (index < 4) {
return <a href="#">{text}</a>;
}
return {
children: <a href="#">{text}</a>,
props: {
colSpan: 5,
},
};
{
title: "组织部门",
dataIndex: "orgDept",
key: "orgDept",
width: 100,
},
}, {
title: 'Age',
key: "Age",
dataIndex: 'age',
render: renderContent,
}, {
title: 'Home phone',
colSpan: 2,
key: "tel",
dataIndex: 'tel',
render: (value, row, index) => {
const obj = {
children: value,
props: {},
};
if (index === 2) {
obj.props.rowSpan = 2;
}
if (index === 3) {
obj.props.rowSpan = 0;
}
if (index === 4) {
obj.props.colSpan = 0;
}
return obj;
{
title: "设施管理部门",
dataIndex: "facilityManageUnit",
key: "facilityManageUnit",
width: 100,
},
}, {
title: 'Phone',
colSpan: 0,
key: "phone",
dataIndex: 'phone',
render: renderContent,
}, {
title: 'Address',
key: "address",
dataIndex: 'address',
render: renderContent,
}];
{
title: "案卷编号",
dataIndex: "docketnum",
key: "docketnum",
width: 100,
},
{
title: "数量",
dataIndex: "num",
key: "num",
width: 100,
},
{
title: "首次发现时间",
dataIndex: "discoveryTime",
key: "discoveryTime",
width: 100,
},
{
title: "实际修复时间",
dataIndex: "repairTime",
key: "repairTime",
width: 100,
},
{
title: "图样",
dataIndex: "picture",
key: "picture",
width: 100,
},
{
title: "申请单号",
dataIndex: "billcode",
key: "billcode",
width: 100,
},
{
title: "设施名称",
dataIndex: "facilityName",
key: "facilityName",
width: 100,
}
];
const data = [{
key: '1',
name: 'John Brown',
age: 32,
tel: '0571-22098909',
phone: 18889898989,
address: 'New York No. 1 Lake Park',
}, {
key: '2',
name: 'Jim Green',
tel: '0571-22098333',
phone: 18889898888,
age: 42,
address: 'London No. 1 Lake Park',
}, {
key: '3',
name: 'Joe Black',
age: 32,
tel: '0575-22098909',
phone: 18900010002,
address: 'Sidney No. 1 Lake Park',
}, {
key: '4',
name: 'Jim Red',
age: 18,
tel: '0575-22098909',
phone: 18900010002,
address: 'London No. 2 Lake Park',
}, {
key: '5',
name: 'Jake White',
age: 18,
tel: '0575-22098909',
phone: 18900010002,
address: 'Dublin No. 2 Lake Park',
}];
const data = [
{ orgDept: "", facilityManageUnit: "", docketnum: 41, num: "1", discoveryTime: "", repairTime: "", picture: "", billcode: "", facilityName:""},
{ orgDept: "", facilityManageUnit: "", docketnum: 41, num: "1", discoveryTime: "", repairTime: "", picture: "", billcode: "", facilityName:""},
{ orgDept: "", facilityManageUnit: "", docketnum: 41, num: "1", discoveryTime: "", repairTime: "", picture: "", billcode: "", facilityName:""}
];
class Demo105 extends Component {
constructor(props) {
super(props);
this.state = {
data: data,
selectedRowIndex: 0
}
}
handleClick = () => {
console.log('这是第' , this.currentIndex , '行');
console.log('内容:' , this.currentRecord);
}
onRowHover=(index,record)=>{
this.currentIndex = index;
this.currentRecord = record;
}
getHoverContent=()=>{
return <div className="opt-btns"><Button size="sm" onClick={this.handleClick}>一些操作</Button> </div>
}
class Demo15 extends Component {
render() {
return (
<Table columns={columns} data={data}/>
<Table
columns={columns}
data={data}
parentNodeId='parent'
hoverContent={this.getHoverContent}
onRowHover={this.onRowHover}
/>
);
}
}
export default Demo15;
export default Demo105;

123
demo/demolist/Demo106.js Normal file
View File

@ -0,0 +1,123 @@
/**
*
* @title 自定义行列合并
* @parent 扩展行 Expanded Row
* @description 表头只支持列合并使用 column 里的 colSpan 进行设置表格支持行/列合并使用 render 里的单元格属性 colSpan 或者 rowSpan 设值为 0 设置的表格不会渲染
*
*/
import React, { Component } from "react";
import Table from "../../src";
const renderContent = (value, row, index) => {
const obj = {
children: value,
props: {},
};
if (index === 4) {
obj.props.colSpan = 0;
}
return obj;
};
const columns = [{
title: 'Name',
key: "name",
dataIndex: 'name',
render: (text, row, index) => {
if (index < 4) {
return <a href="#">{text}</a>;
}
return {
children: <a href="#">{text}</a>,
props: {
colSpan: 5,
},
};
},
}, {
title: 'Age',
key: "Age",
dataIndex: 'age',
render: renderContent,
}, {
title: 'Home phone',
colSpan: 2,
key: "tel",
dataIndex: 'tel',
render: (value, row, index) => {
const obj = {
children: value,
props: {},
};
if (index === 2) {
obj.props.rowSpan = 2;
}
if (index === 3) {
obj.props.rowSpan = 0;
}
if (index === 4) {
obj.props.colSpan = 0;
}
return obj;
},
}, {
title: 'Phone',
colSpan: 0,
key: "phone",
dataIndex: 'phone',
render: renderContent,
}, {
title: 'Address',
key: "address",
dataIndex: 'address',
render: renderContent,
}];
const data = [{
key: '1',
name: 'John Brown',
age: 32,
tel: '0571-22098909',
phone: 18889898989,
address: 'New York No. 1 Lake Park',
}, {
key: '2',
name: 'Jim Green',
tel: '0571-22098333',
phone: 18889898888,
age: 42,
address: 'London No. 1 Lake Park',
}, {
key: '3',
name: 'Joe Black',
age: 32,
tel: '0575-22098909',
phone: 18900010002,
address: 'Sidney No. 1 Lake Park',
}, {
key: '4',
name: 'Jim Red',
age: 18,
tel: '0575-22098909',
phone: 18900010002,
address: 'London No. 2 Lake Park',
}, {
key: '5',
name: 'Jake White',
age: 18,
tel: '0575-22098909',
phone: 18900010002,
address: 'Dublin No. 2 Lake Park',
}];
class Demo15 extends Component {
render() {
return (
<Table columns={columns} data={data}/>
);
}
}
export default Demo15;

View File

@ -1,6 +1,7 @@
/**
*
* @title 横向滚动条
* @parent 滚动 Scroll View
* @description 设置`scroll`属性支持横向或纵向滚动x/y的取值可以是正整数百分比布尔值
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 纵向滚动条
* @parent 滚动 Scroll View
* @description 设置`scroll`属性支持横向或纵向滚动x/y的取值可以是正整数百分比布尔值
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 多选表格
* @parent 行操作-选择
* @description 点击表格左列按钮即可选中并且在选中的回调函数中能获取到选中的数据支持多选全选和禁止选择
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 滚动加载
* @title 万行以上数据渲染
* @parent 无限滚动 Infinite-scroll
* @description 万行数据渲染
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 嵌套子表格滚动加载
* @parent 无限滚动 Infinite-scroll
* @description 通过expandedRowRender参数来实现子表格
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 多功能表格滚动加载
* @parent 无限滚动 Infinite-scroll
* @description
*/

View File

@ -1,3 +1,8 @@
/**
* @title 层级树大数据场景
* @parent 无限滚动 Infinite-scroll
* @description
*/
import React, { Component } from "react";
import {Tooltip} from "tinper-bee";

View File

@ -1,6 +1,6 @@
/**
*
* @title 表格+分页
* @parent 分页 Pagination
* @description 点击分页联动表格
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 表格+搜索
* @parent 搜索 search
* @description 搜索刷新表格数据
*
*/

View File

@ -1,96 +0,0 @@
/**
*
* @title 主子表
* @description 点击主表行子表联动切换
*
*/
import React, { Component } from "react";
import Table from "../../src";
const columns7 = [
{ title: "班级", dataIndex: "a", key: "a" },
{ title: "人数", dataIndex: "b", key: "b" },
{ title: "班主任", dataIndex: "c", key: "c" },
{
title: "武功级别",
dataIndex: "d",
key: "d"
}
];
const data7 = [
{ a: "02级一班", b: "2", c: "欧阳锋", d: "大侠", key: "1" },
{ a: "03级二班", b: "3", c: "归海一刀", d: "大侠", key: "2" },
{ a: "05级三班", b: "1", c: "一拳超人", d: "愣头青", key: "3" }
];
const columns7_1 = [
{ title: "姓名", dataIndex: "a", key: "a" },
{ title: "班级", dataIndex: "b", key: "b" },
{ title: "系别", dataIndex: "c", key: "c" }
];
class Demo7 extends Component {
constructor(props) {
super(props);
this.state = {
children_data: [],
selectedRowIndex: -1
};
}
rowclick = (record, index) => {
if (record.a === "02级一班") {
this.setState({
children_data: [
{ a: "郭靖", b: "02级一班", c: "文学系", key: "1" },
{ a: "黄蓉", b: "02级一班", c: "文学系", key: "2" }
],
selectedRowIndex: index
});
} else if (record.a === "03级二班") {
this.setState({
children_data: [
{ a: "杨过", b: "03级二班", c: "外语系", key: "1" },
{ a: "小龙女", b: "03级二班", c: "外语系", key: "2" },
{ a: "傻姑", b: "03级二班", c: "外语系", key: "3" }
],
selectedRowIndex: index
});
} else if (record.a === "05级三班") {
this.setState({
children_data: [{ a: "金圣叹", b: "05级三班", c: "美术系", key: "1" }],
selectedRowIndex: index
});
}
};
render() {
return (
<div>
<Table
columns={columns7}
data={data7}
onRowClick={this.rowclick}
rowClassName={(record,index,indent)=>{
if (this.state.selectedRowIndex == index) {
return 'selected';
} else {
return '';
}
}}
title={currentData => <div>标题: 我是主表</div>}
/>
<Table
style={{ marginTop: 40 }}
columns={columns7_1}
data={this.state.children_data}
title={currentData => <div>标题: 我是子表</div>}
/>
</div>
);
}
}
export default Demo7;

60
demo/demolist/Demo21.js Normal file
View File

@ -0,0 +1,60 @@
/**
*
* @title 渲染本地数据
* @parent 数据操作 Data Opetation
* @description
*/
import React, { Component } from "react";
import {Button,Tooltip} from "tinper-bee";
import Table from "../../src";
const columns = [
{
title: "用户名", dataIndex: "a", key: "a", width: 300, className: "rowClassName",
fixed:'left',
render: (text, record, index) => {
return (
<Tooltip inverse overlay={text}>
<span tootip={text} style={{
display: "inline-block",
width: "60px",
textOverflow: "ellipsis",
overflow: "hidden",
whiteSpace: "nowrap",
verticalAlign: "middle",
}}>{text}</span>
</Tooltip>
);
}
},
{ id: "123", title: "性别", dataIndex: "b", key: "b", width: 500},
{ title: "年龄", dataIndex: "c", key: "c", width: 200 }
];
const data = [
{ a: "令狐冲", b: "男", c: 41, key: "1" },
{ a: "杨过叔叔的女儿黄蓉", b: "男", c: 67, key: "2" },
{ a: "郭靖", b: "男", c: 25, key: "3" }
];
class Demo21 extends Component {
constructor(props) {
super(props);
this.state = {
data: data
}
}
render() {
return (
<Table
columns={columns}
data={data}
/>
);
}
}
export default Demo21;

View File

@ -1,6 +1,7 @@
/**
*
* @title 多列表头
* @parent 列渲染 Custom Render
* @description columns[n] 可以内嵌 children以渲染分组表头
* 自定义表头高度需要传headerHeight修改th的padding top和bottom置为0否则会有影响
*

View File

@ -1,6 +1,7 @@
/**
*
* @title 合并列后合计
* @parent 列渲染 Custom Render
* @description 合并标题后的合计,且支持多字段统计通过使用的封装好的功能方法实现复杂功能简单易用
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 编辑态表格
* @parent 编辑 Editor
* @description 这是带有多种不同格式的编辑态表格编辑态是通过使用不同的render来达到不同编辑格式
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 左侧固定列
* @parent 列操作-锁定 Fixed
* @description 固定列到表格的左侧
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 右侧固定列
* @parent 列操作-锁定 Fixed
* @description 固定列到表格的右侧
*
*/

View File

@ -1,8 +1,8 @@
/**
*
* @title 动态设置列锁定解除锁定
* @description 动态设置固取消固定列
* @description 动态固定列设置 一个table动态设置一个方向fixed: "left"fixed: "right"
* @parent 列操作-锁定 Fixed
* @description 动态设置columns中数据的fixed属性值fixed: "left"fixed: "right"
*
*/
import React, { Component } from 'react';
@ -11,25 +11,6 @@ import {Icon,Menu,Dropdown} from "tinper-bee";
import Table from '../../src';
const { Item } = Menu;
// const columns24 = [
// {
// title: "Full Name",
// width: 100,
// dataIndex: "name",
// key: "name",
// fixed: "left",
// },
// { title: "Age", width: 100, dataIndex: "age", key: "age", fixed: "left" },
// { title: "Column 1", dataIndex: "address", key: "1" },
// { title: "Column 2", dataIndex: "address2", key: "2" },
// { title: "Column 3", dataIndex: "address", key: "3" },
// { title: "Column 4", dataIndex: "address", key: "4" },
// { title: "Column 24", dataIndex: "address", key: "24" },
// { title: "Column 6", dataIndex: "address", key: "6" },
// { title: "Column 7", dataIndex: "address", key: "7" },
// { title: "Column 8", dataIndex: "address", key: "8" }
// ];
const columns24 = [
{
@ -106,7 +87,6 @@ class Demo24 extends Component {
}
}
onSelect = ({key,item})=>{
console.log(`${key} selected`); //获取key
let currentObject = item.props.data; //获取选中对象的数据
@ -167,9 +147,11 @@ class Demo24 extends Component {
render() {
let {columns} = this.state;
columns = this.renderColumnsDropdown(columns);
return <div className="demo24">
return(
<div className="demo24">
<Table columns={columns} data={data24} scroll={{ x: "110%", y: 240 }}/>
</div>;
</div>
)
}
}

View File

@ -1,6 +1,7 @@
/**
*
* @title 按条件值过滤
* @parent 列操作-过滤 Filter
* @description 可以根据输入项目以及判断条件对表格内的数据进行过滤
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 复杂表格中行过滤
* @parent 列操作-过滤 Filter
* @description 在过滤数据行的基础上增加列拖拽动态菜单显示下拉条件动态传入自定义等
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 列过滤面板
* @parent 列操作-隐藏 Hide
* @description 点击表格右侧按钮进行表格列的数据过滤可以自定义设置显示某列通过ifshow属性控制默认为true都显示afterFilter为过滤之后的回调函数
*
*/

View File

@ -1,5 +1,6 @@
/**
* @title 列排序
* @parent 列操作-排序 Sort
* @description column中增加sorter: (a, b) => a.c - b.c 这里的a,b代表前后两个数据c代表比较当前对象的字段名称
*
*/

View File

@ -1,6 +1,7 @@
/**
* @title 后端列排序
*
* @parent 列操作-排序 Sort
* @description 将控制台打印的参数传递给后端即可进行列排序
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 多列排序
* @parent 列操作-排序 Sort
* @description 多列排序全选功能合计通过使用的封装好的功能方法实现复杂功能简单易用新增回调函数(sorterClick)
*
*/

View File

@ -1,6 +1,7 @@
/**
*
* @title 拖拽改变列顺序
* @parent 列操作-拖拽 Drag
* @description 点击列的表头进行左右拖拽注意固定列不可以交换
*/
import React, { Component } from 'react';

View File

@ -1,6 +1,7 @@
/**
*
* @title 拖拽改变列宽度
* @parent 列操作-拖拽 Drag
* @description 不支持tree结构的表头合并表头的table
*/
import React, { Component } from 'react';

File diff suppressed because one or more lines are too long

8
dist/demo.css vendored
View File

@ -349,7 +349,8 @@
line-height: 14px;
margin: 0px; }
.u-table .u-checkbox .u-checkbox-label {
line-height: 14px; }
line-height: 14px;
padding-left: 16px; }
.u-table .u-checkbox .u-checkbox-label:before, .u-table .u-checkbox .u-checkbox-label:after {
width: 14px;
height: 14px; }
@ -597,6 +598,11 @@
.demo25 .u-table-filter-column-filter-icon {
right: 15px; }
.opt-btns .u-button {
background: #505F79; }
.opt-btns .u-button:hover, .opt-btns .u-button:active {
background: #344563; }
.demo02 .u-table-placeholder i {
font-size: 60px; }

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

570
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

@ -45,7 +45,7 @@ import 'bee-table/build/Table.css';
| title | 表格标题 | Function | - |
| footer | 表格尾部 | Function | - |
| emptyText | 无数据时显示的内容 | Function | () => 'No Data' |
| scroll | 横向或纵向支持滚动,也可用于指定滚动区域的宽高度{ x: true, y: 300 } | object | {} |
| scroll | 横向或纵向支持滚动,也可用于指定滚动区域的宽高度 | ` { x: number | true | 百分比 , y: number }` | {} |
| rowRef | 获取行的ref | Function(record, index, indent):string | () => null |
| getBodyWrapper | 添加对table body的包装 | Function(body) | body => body |
| expandedRowRender | 额外的展开行 | Function(record, index, indent):node | - |
@ -66,6 +66,8 @@ import 'bee-table/build/Table.css';
| hoverContent | hover某行时动态渲染行菜单元素此方法需返回行菜单元素的内容 | Function|
| onRowHover | 行hover时的回调函数 | Function|
| heightConsistent | 当固定列内容高度超出非固定列时,内容互错行,当此属性为true会将高度同步当行过多时会有性能影响,所以建议非固定高度如果过高时,超出内容可以显示成省略号 | bool|false
| height | 自定义表格行高 | number | - |
| headerHeight | 自定义表头行高 | number | - |
> 快捷键部分参考示例 (快捷键在table中的简单使用应用)

View File

@ -76,7 +76,9 @@
"bee-clipboard": "^2.0.0",
"bee-drawer": "0.0.2",
"bee-layout": "latest",
"bee-pagination": "^2.0.5",
"bee-panel": "latest",
"bee-popover": "^2.0.0",
"chai": "^3.5.0",
"console-polyfill": "~0.2.1",
"cz-conventional-changelog": "^2.1.0",
@ -86,8 +88,6 @@
"react": "^16.6.3",
"react-addons-test-utils": "^15.5.0",
"react-dom": "^16.6.3",
"tinper-bee": "latest",
"bee-pagination": "^2.0.5",
"bee-popover": "^2.0.0"
"tinper-bee": "latest"
}
}