fix: 删除多余demo,修改样式和优化合计功能代码

This commit is contained in:
huyueb 2017-09-28 16:35:24 +08:00
parent 3d4a4002f7
commit b01d24d102
4 changed files with 13 additions and 106 deletions

View File

@ -1,82 +0,0 @@
/**
*
* @title 合计表格
* @description
*
*/
import React, { Component } from "react";
import Table from "../../src";
const columns14 = [
{ title: "用户名", dataIndex: "a", key: "a", width: 100 },
{ id: "123", title: "性别", dataIndex: "b", key: "b", width: 100 },
{
title: "年龄",
dataIndex: "c",
key: "c",
width: 200,
heji: true,
render(data) {
return <a href="#">一些操作</a>;
}
},
{
title: "操作",
dataIndex: "d",
key: "d",
render(data) {
return <a href="#">一些操作</a>;
}
}
];
const columns14_ = [
{ title: "用户名", dataIndex: "a", key: "a", width: 100 },
{ id: "123", title: "性别", dataIndex: "b", key: "b", width: 100 },
{
title: "年龄",
dataIndex: "c",
key: "c",
width: 200,
heji: true
},
{
title: "操作",
dataIndex: "d",
key: "d"
}
];
const data14 = [
{ a: "令狐冲", b: "男", c: 41, key: "1" },
{ a: "杨过", b: "男", c: 67, key: "2" },
{ a: "郭靖", b: "男", c: 25, key: "3" },
{ a: "合计", d: "11", key: "31" }
];
const data14_ = [
{ a: "郭靖", b: "男", c: 25,d:11, key: "3" }
];
class Demo14 extends Component {
render() {
return (
<Table
columns={columns14}
data={data14}
heji={true}
title={currentData => <div>标题: 这是一个标题</div>}
footer={currentData => (
<Table
showHeader={false}
columns={columns14_}
data={data14_}
heji={true}
/>
)}
/>
);
}
}
export default Demo14;

File diff suppressed because one or more lines are too long

View File

@ -93,8 +93,11 @@ $table-move-in-color: $bg-color-base;
}
&-footer {
// padding: $vertical-padding $horizontal-padding;
// border-bottom: 1px solid $table-border-color;
padding: $vertical-padding $horizontal-padding;
border-bottom: 1px solid $table-border-color;
}
&-footer &{
margin: (-$vertical-padding) (-$horizontal-padding);
}
&-placeholder {

View File

@ -13,9 +13,6 @@ let Sum = Table => {
constructor(props) {
super(props);
}
currentTitle = () => {
return <div>{this.props.title}</div>;
};
//合计数字列,并将计算所得数据存储到一个obj对象中
currentFooter = () => {
let data_2 = this.props.data;
@ -39,7 +36,11 @@ let Sum = Table => {
obj.showSum = "合计";
obj = [obj];
//将设置的和用户传入的合并属性
columns_sum[0] = Object.assign({}, columns_sum[0], columns2);
// if (columns_sum[0].dataIndex === "checkbox") {
// columns_sum[1] = Object.assign({}, columns_sum[1], columns2);
// } else {
columns_sum[0] = Object.assign({}, columns_sum[0], columns2);
// }
//除去列为特殊渲染的避免像a标签这种html代码写入到合计中
columns_sum = columns_sum.map((item, index) => {
if (typeof item.render == "function") {
@ -47,25 +48,10 @@ let Sum = Table => {
}
return item;
});
return (
<Table
showHeader={false}
columns={columns_sum}
data={obj}
heji={true}
/>
);
return <Table showHeader={false} columns={columns_sum} data={obj} />;
};
render() {
return (
<Table
columns={this.props.columns}
data={this.props.data}
heji={true}
title={this.currentTitle}
footer={this.currentFooter}
/>
);
return <Table {...this.props} footer={this.currentFooter} />;
}
};
};