修改demo中的描述

This commit is contained in:
huyueb 2017-10-25 16:41:38 +08:00
parent 67dfe113bd
commit 69d55a12e5
10 changed files with 308 additions and 331 deletions

View File

@ -55,14 +55,32 @@ var InputRender = function (_Component) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
_this.check(); _this.check();
} }
}, _this.formatCurrency = function (money) {
if (money && money != null && !!Number(money)) {
money = String(money);
var left = money.split(".")[0],
right = money.split(".")[1];
right = right ? right.length >= 2 ? "." + right.substr(0, 2) : "." + right + "0" : ".00";
var temp = left.split("").reverse().join("").match(/(\d{1,3})/g);
return (Number(money) < 0 ? "-" : "") + temp.join(",").split("").reverse().join("") + right;
} else if (money === 0) {
//注意===在这里的使用如果传入的money为0,if中会将其判定为boolean类型故而要另外做===判断
return "0.00";
} else {
return "";
}
}, _temp), _possibleConstructorReturn(_this, _ret); }, _temp), _possibleConstructorReturn(_this, _ret);
} }
//货币的格式化方法
InputRender.prototype.render = function render() { InputRender.prototype.render = function render() {
var _state = this.state, var _state = this.state,
value = _state.value, value = _state.value,
editable = _state.editable; editable = _state.editable;
var isclickTrigger = this.props.isclickTrigger; var _props = this.props,
isclickTrigger = _props.isclickTrigger,
format = _props.format;
var cellContent = ""; var cellContent = "";
if (editable) { if (editable) {
@ -91,6 +109,9 @@ var InputRender = function (_Component) {
}) })
); );
} else { } else {
if (format && format === "Currency") {
value = this.formatCurrency(value);
}
cellContent = isclickTrigger ? _react2["default"].createElement( cellContent = isclickTrigger ? _react2["default"].createElement(
"div", "div",
{ className: "editable-cell-text-wrapper", onClick: this.edit }, { className: "editable-cell-text-wrapper", onClick: this.edit },

View File

@ -5,29 +5,40 @@
* *
*/ */
import React, { Component } from 'react'; import React, { Component } from "react";
import Table from '../../src'; import Table from "../../src";
const columns = [ const columns = [
{ 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 },
{ {
title: '操作', dataIndex: '', key: 'd', render() { title: "操作",
return <a href="#">一些操作</a>; dataIndex: "d",
}, key: "d",
}, render(text, record, index) {
return (
<a
href="#"
onClick={() => {
alert('这是第'+index+'列,内容为:'+text);
}}
>
一些操作
</a>
);
}
}
]; ];
const data = [ const data = [
{ a: '令狐冲', b: '男', c: 41, key: '1' }, { a: "令狐冲", b: "男", c: 41, d: "操作", key: "1" },
{ a: '杨过', b: '男', c: 67, key: '2' }, { a: "杨过", b: "男", c: 67, d: "操作", key: "2" },
{ a: '郭靖', b: '男', c: 25, key: '3' }, { a: "郭靖", b: "男", c: 25, d: "操作", key: "3" }
]; ];
class Demo1 extends Component { class Demo1 extends Component {
render () { render() {
return ( return (
<Table <Table
columns={columns} columns={columns}
@ -35,9 +46,8 @@ class Demo1 extends Component {
title={currentData => <div>标题: 这是一个标题</div>} title={currentData => <div>标题: 这是一个标题</div>}
footer={currentData => <div>表尾: 我是小尾巴</div>} footer={currentData => <div>表尾: 我是小尾巴</div>}
/> />
) );
} }
} }
export default Demo1; export default Demo1;

View File

@ -31,19 +31,16 @@ const columns11 = [
sorter: (a, b) => a.c - b.c sorter: (a, b) => a.c - b.c
}, },
{ {
title: "操作", title: "武功级别",
dataIndex: "", dataIndex: "d",
key: "d", key: "d"
render() {
return <a href="#">一些操作</a>;
}
} }
]; ];
const data11 = [ const data11 = [
{ a: "杨过", b: "男", c: 30, key: "2" }, { a: "杨过", b: "男", c: 30,d:'内行', key: "2" },
{ a: "令狐冲", b: "男", c: 41, key: "1" }, { a: "令狐冲", b: "男", c: 41,d:'大侠', key: "1" },
{ a: "郭靖", b: "男", c: 25, key: "3" } { a: "郭靖", b: "男", c: 25,d:'大侠', key: "3" }
]; ];
const defaultProps11 = { const defaultProps11 = {

View File

@ -31,19 +31,16 @@ const columns12 = [
sorter: (a, b) => a.c - b.c sorter: (a, b) => a.c - b.c
}, },
{ {
title: "操作", title: "武功级别",
dataIndex: "", dataIndex: "d",
key: "d", key: "d"
render() {
return <a href="#">一些操作</a>;
}
} }
]; ];
const data12 = [ const data12 = [
{ a: "杨过", b: "男", c: 30, key: "2" }, { a: "杨过", b: "男", c: 30,d:'内行', key: "2" },
{ a: "令狐冲", b: "男", c: 41, key: "1" }, { a: "令狐冲", b: "男", c: 41,d:'大侠', key: "1" },
{ a: "郭靖", b: "男", c: 25, key: "3" } { a: "郭靖", b: "男", c: 25,d:'大侠', key: "3" }
]; ];
const defaultProps12 = { const defaultProps12 = {

View File

@ -34,19 +34,16 @@ const columns13 = [
sorter: (a, b) => a.c - b.c sorter: (a, b) => a.c - b.c
}, },
{ {
title: "操作", title: "武功级别",
dataIndex: "", dataIndex: "d",
key: "d", key: "d"
render() {
return <a href="#">一些操作</a>;
}
} }
]; ];
const data13 = [ const data13 = [
{ a: "杨过", b: "男", c: 30, key: "2" }, { a: "杨过", b: "男", c: 30,d:'内行', key: "2" },
{ a: "令狐冲", b: "男", c: 41, key: "1" }, { a: "令狐冲", b: "男", c: 41,d:'大侠', key: "1" },
{ a: "郭靖", b: "男", c: 25, key: "3" } { a: "郭靖", b: "男", c: 25,d:'大侠', key: "3" }
]; ];
class Demo13 extends Component { class Demo13 extends Component {
getSelectedDataFunc = (data) =>{ getSelectedDataFunc = (data) =>{

View File

@ -42,7 +42,6 @@ class Demo14 extends React.Component {
address: "111", address: "111",
datepicker: "2017-06-12", datepicker: "2017-06-12",
MonthPicker: "2017-02", MonthPicker: "2017-02",
TimePicker: "2017-09-14 14:24:48"
}, },
{ {
key: "1", key: "1",
@ -52,7 +51,6 @@ class Demo14 extends React.Component {
address: "lucy", address: "lucy",
datepicker: "2017-06-12", datepicker: "2017-06-12",
MonthPicker: "2017-02", MonthPicker: "2017-02",
TimePicker: "2017-09-14 14:24:48"
}, },
{ {
key: "2", key: "2",
@ -62,7 +60,6 @@ class Demo14 extends React.Component {
address: "lucy", address: "lucy",
datepicker: "2017-06-12", datepicker: "2017-06-12",
MonthPicker: "2017-02", MonthPicker: "2017-02",
TimePicker: "2017-09-14 14:24:48"
}, },
{ {
key: "3", key: "3",
@ -72,7 +69,6 @@ class Demo14 extends React.Component {
address: "lucy", address: "lucy",
datepicker: "2017-06-12", datepicker: "2017-06-12",
MonthPicker: "2017-02", MonthPicker: "2017-02",
TimePicker: "2017-09-14 14:24:48"
} }
], ],
count: 4 count: 4
@ -174,23 +170,6 @@ class Demo14 extends React.Component {
/> />
); );
} }
},
{
title: "日期",
dataIndex: "TimePicker",
key: "TimePicker",
render: (text, record, index) => {
return (
<DateRender
value={text}
format={format3}
isclickTrigger={true}
onSelect={this.onDateSelect}
onChange={this.onDateChange}
placeholder={dateInputPlaceholder}
/>
);
}
} }
]; ];
} }
@ -233,8 +212,7 @@ class Demo14 extends React.Component {
age: 32, age: 32,
address: "jack", address: "jack",
datepicker: "2017-06-12", datepicker: "2017-06-12",
MonthPicker: "2017-02", MonthPicker: "2017-02"
TimePicker: "2017-09-14 14:24:48"
}; };
this.setState({ this.setState({
dataSource: [...dataSource, newData], dataSource: [...dataSource, newData],

View File

@ -5,36 +5,30 @@
* *
*/ */
import React, { Component } from "react";
import React, {Component} from 'react'; import Table from "../../src";
import Table from '../../src';
const columns7 = [ const columns7 = [
{title: "班级", dataIndex: "a", key: "a"}, { title: "班级", dataIndex: "a", key: "a" },
{title: "人数", dataIndex: "b", key: "b"}, { title: "人数", dataIndex: "b", key: "b" },
{title: "班主任", dataIndex: "c", key: "c"}, { title: "班主任", dataIndex: "c", key: "c" },
{ {
title: "操作", title: "武功级别",
dataIndex: "", dataIndex: "d",
key: "d", key: "d"
render() {
return <a href="#">一些操作</a>;
}
} }
]; ];
const data7 = [ const data7 = [
{ a: "02级一班", b: "2", c: "欧阳锋", d: "大侠", key: "1" },
{a: "02级一班", b: "2", c: "欧阳锋", key: "1"}, { a: "03级二班", b: "3", c: "归海一刀", d: "大侠", key: "2" },
{a: "03级二班", b: "3", c: "归海一刀", key: "2"}, { a: "05级三班", b: "1", c: "一拳超人", d: "愣头青", key: "3" }
{a: "05级三班", b: "1", c: "一拳超人", key: "3"}
]; ];
const columns7_1 = [ const columns7_1 = [
{title: "姓名", dataIndex: "a", key: "a"}, { title: "姓名", dataIndex: "a", key: "a" },
{title: "班级", dataIndex: "b", key: "b"}, { title: "班级", dataIndex: "b", key: "b" },
{title: "系别", dataIndex: "c", key: "c"} { title: "系别", dataIndex: "c", key: "c" }
]; ];
class Demo7 extends Component { class Demo7 extends Component {
@ -42,34 +36,31 @@ class Demo7 extends Component {
super(props); super(props);
this.state = { this.state = {
children_data: [] children_data: []
} };
} }
rowclick = (record, index) => { rowclick = (record, index) => {
if (record.a === "02级一班") {
if (record.a === '02级一班') {
this.setState({ this.setState({
children_data: [ children_data: [
{a: "郭靖", b: "02级一班", c: '文学系', key: "1"}, { a: "郭靖", b: "02级一班", c: "文学系", key: "1" },
{a: "黄蓉", b: "02级一班", c: '文学系', key: "2"}, { a: "黄蓉", b: "02级一班", c: "文学系", key: "2" }
] ]
}) });
} else if (record.a === '03级二班') { } else if (record.a === "03级二班") {
this.setState({ this.setState({
children_data: [ children_data: [
{a: "杨过", b: "03级二班", c: '外语系', key: "1"}, { a: "杨过", b: "03级二班", c: "外语系", key: "1" },
{a: "小龙女", b: "03级二班", c: '外语系', key: "2"}, { a: "小龙女", b: "03级二班", c: "外语系", key: "2" },
{a: "傻姑", b: "03级二班", c: '外语系', key: "3"}, { a: "傻姑", b: "03级二班", c: "外语系", key: "3" }
] ]
}) });
} else if (record.a === '05级三班') { } else if (record.a === "05级三班") {
this.setState({ this.setState({
children_data: [ children_data: [{ a: "金圣叹", b: "05级三班", c: "美术系", key: "1" }]
{a: "金圣叹", b: "05级三班", c: '美术系', key: "1"} });
]
})
}
} }
};
render() { render() {
return ( return (
@ -81,7 +72,7 @@ class Demo7 extends Component {
title={currentData => <div>标题: 我是主表</div>} title={currentData => <div>标题: 我是主表</div>}
/> />
<Table <Table
style={{marginTop: 40}} style={{ marginTop: 40 }}
columns={columns7_1} columns={columns7_1}
data={this.state.children_data} data={this.state.children_data}
title={currentData => <div>标题: 我是子表</div>} title={currentData => <div>标题: 我是子表</div>}
@ -91,5 +82,4 @@ class Demo7 extends Component {
} }
} }
export default Demo7; export default Demo7;

View File

@ -6,40 +6,33 @@
*import {Table} from 'tinper-bee'; *import {Table} from 'tinper-bee';
*/ */
import React, { Component } from "react";
import React, {Component} from 'react'; import Table from "../../src";
import Table from '../../src';
import Pagination from "bee-pagination"; import Pagination from "bee-pagination";
const columns8 = [ const columns8 = [
{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 },
{ {
title: "操作", title: "武功级别",
dataIndex: "", dataIndex: "d",
key: "d", key: "d"
render() {
return <a href="#">一些操作</a>;
}
} }
]; ];
const pageData = { const pageData = {
1: [ 1: [
{a: "令狐冲", b: "男", c: 41, key: "1"}, { a: "杨过", b: "男", c: 30, d: "内行", key: "2" },
{a: "杨过", b: "男", c: 67, key: "2"}, { a: "令狐冲", b: "男", c: 41, d: "大侠", key: "1" },
{a: "郭靖", b: "男", c: 25, key: "3"} { a: "郭靖", b: "男", c: 25, d: "大侠", key: "3" }
], ],
2: [ 2: [
{a: "芙蓉姐姐", b: "女", c: 23, key: "1"}, { a: "芙蓉姐姐", b: "女", c: 23, d: "大侠", key: "1" },
{a: "芙蓉姐姐", b: "女", c: 23, key: "2"} { a: "芙蓉妹妹", b: "女", c: 23, d: "内行", key: "2" }
] ]
} };
class Demo8 extends Component { class Demo8 extends Component {
constructor(props) { constructor(props) {
@ -54,13 +47,13 @@ class Demo8 extends Component {
this.setState({ this.setState({
data: pageData[eventKey], data: pageData[eventKey],
activePage: eventKey activePage: eventKey
}) });
} }
render() { render() {
return ( return (
<div> <div>
<Table columns={columns8} data={this.state.data}/> <Table columns={columns8} data={this.state.data} />
<Pagination <Pagination
first first
last last
@ -70,7 +63,8 @@ class Demo8 extends Component {
items={2} items={2}
maxButtons={5} maxButtons={5}
activePage={this.state.activePage} activePage={this.state.activePage}
onSelect={this.handleSelect.bind(this)}/> onSelect={this.handleSelect.bind(this)}
/>
</div> </div>
); );
} }

View File

@ -7,13 +7,12 @@
* import {Table} from 'tinper-bee'; * import {Table} from 'tinper-bee';
*/ */
import React, {Component} from 'react'; import React, { Component } from "react";
import Table from '../../src'; import Table from "../../src";
import Icon from "bee-icon"; import Icon from "bee-icon";
import InputGroup from 'bee-input-group'; import InputGroup from "bee-input-group";
import FormControl from 'bee-form-control'; import FormControl from "bee-form-control";
class Search extends Component { class Search extends Component {
state = { state = {
@ -25,10 +24,10 @@ class Search extends Component {
* 搜索 * 搜索
*/ */
handleSearch = () => { handleSearch = () => {
let {onSearch} = this.props; let { onSearch } = this.props;
this.setState({ this.setState({
empty: true empty: true
}) });
onSearch && onSearch(this.state.searchValue); onSearch && onSearch(this.state.searchValue);
}; };
@ -56,7 +55,7 @@ class Search extends Component {
* 清空输入框 * 清空输入框
*/ */
emptySearch = () => { emptySearch = () => {
let {onEmpty} = this.props; let { onEmpty } = this.props;
this.setState({ this.setState({
searchValue: "", searchValue: "",
empty: false empty: false
@ -74,16 +73,16 @@ class Search extends Component {
placeholder="请输入用户名" placeholder="请输入用户名"
type="text" type="text"
/> />
{this.state.empty {this.state.empty ? (
? <Icon <Icon
type="uf-close-c" type="uf-close-c"
onClick={this.emptySearch} onClick={this.emptySearch}
className="empty-search" className="empty-search"
/> />
: null} ) : null}
<InputGroup.Button onClick={this.handleSearch} shape="border"> <InputGroup.Button onClick={this.handleSearch} shape="border">
<Icon type="uf-search"/> <Icon type="uf-search" />
</InputGroup.Button> </InputGroup.Button>
</InputGroup> </InputGroup>
); );
@ -92,7 +91,7 @@ class Search extends Component {
const columns9 = [ const columns9 = [
{ {
title: "用户名", title: "姓名",
dataIndex: "a", dataIndex: "a",
key: "a", key: "a",
width: 100 width: 100
@ -110,19 +109,16 @@ const columns9 = [
width: 200 width: 200
}, },
{ {
title: "操作", title: "武功级别",
dataIndex: "", dataIndex: "d",
key: "d", key: "d"
render() {
return <a href="#">一些操作</a>;
}
} }
]; ];
const userData = [ const userData = [
{a: "令狐冲", b: "男", c: 41, key: "1"}, { a: "杨过", b: "男", c: 30, d: "内行", key: "2" },
{a: "杨过", b: "男", c: 67, key: "2"}, { a: "令狐冲", b: "男", c: 41, d: "大侠", key: "1" },
{a: "郭靖", b: "男", c: 25, key: "3"} { a: "郭靖", b: "男", c: 25, d: "大侠", key: "3" }
]; ];
class Demo9 extends Component { class Demo9 extends Component {
@ -133,35 +129,32 @@ class Demo9 extends Component {
}; };
} }
handleSearch = (value) => { handleSearch = value => {
if(value === ''){ if (value === "") {
return this.setState({ return this.setState({
data: userData data: userData
}) });
} }
let regExp = new RegExp(value, 'ig'); let regExp = new RegExp(value, "ig");
let data = userData.filter((item) => regExp.test(item.a)); let data = userData.filter(item => regExp.test(item.a));
this.setState({ this.setState({
data data
}) });
} };
handleEmpty = () => { handleEmpty = () => {
this.setState({ this.setState({
data: userData data: userData
}) });
} };
render() { render() {
return ( return (
<div> <div>
<div className="clearfix"> <div className="clearfix">
<Search <Search onSearch={this.handleSearch} onEmpty={this.handleEmpty} />
onSearch={ this.handleSearch }
onEmpty={ this.handleEmpty }
/>
</div> </div>
<Table columns={columns9} data={this.state.data}/> <Table columns={columns9} data={this.state.data} />
</div> </div>
); );
} }

File diff suppressed because one or more lines are too long