2016-12-26 22:04:16 +08:00
|
|
|
|
|
|
|
import { Con, Row, Col } from 'bee-layout';
|
|
|
|
import { Panel } from 'bee-panel';
|
|
|
|
import Button from 'bee-button';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import Table from '../src';
|
|
|
|
import Animate from 'bee-animate';
|
2017-08-30 11:18:38 +08:00
|
|
|
import Pagination from "bee-pagination";
|
2017-01-11 17:01:50 +08:00
|
|
|
import Icon from "bee-icon";
|
2017-08-30 11:18:38 +08:00
|
|
|
import InputGroup from 'bee-input-group';
|
|
|
|
import FormControl from 'bee-form-control';
|
2017-01-11 17:01:50 +08:00
|
|
|
import Input from 'bee-form-control';
|
|
|
|
import Popconfirm from 'bee-popconfirm';
|
2016-12-26 22:04:16 +08:00
|
|
|
|
2017-01-11 17:01:50 +08:00
|
|
|
const CARET = <i className="uf uf-arrow-down"></i>;
|
2016-12-26 22:04:16 +08:00
|
|
|
|
2017-01-11 17:01:50 +08:00
|
|
|
const CARETUP = <i className="uf uf-arrow-up"></i>;
|
2016-12-26 22:04:16 +08:00
|
|
|
|
|
|
|
|
2017-08-30 13:31:26 +08:00
|
|
|
var Demo1 = require("./demolist/Demo1");var Demo10 = require("./demolist/Demo10");var Demo2 = require("./demolist/Demo2");var Demo3 = require("./demolist/Demo3");var Demo4 = require("./demolist/Demo4");var Demo5 = require("./demolist/Demo5");var Demo6 = require("./demolist/Demo6");var Demo7 = require("./demolist/Demo7");var Demo8 = require("./demolist/Demo8");var Demo9 = require("./demolist/Demo9");var DemoArray = [{"example":<Demo1 />,"title":" 简单表格","code":"/**\n*\n* @title 简单表格\n* @description\n*\n*/\n\nimport React, { Component } from 'react';\nimport ReactDOM from 'react-dom';\nimport Table from 'tinper-bee';\n\n\nconst columns = [\n { title: '用户名', dataIndex: 'a', key: 'a', width: 100 },\n { id: '123', title: '性别', dataIndex: 'b', key: 'b', width: 100 },\n { title: '年龄', dataIndex: 'c', key: 'c', width: 200 },\n {\n title: '操作', dataIndex: '', key: 'd', render() {\n return <a href=\"#\">一些操作</a>;\n },\n },\n];\n\nconst data = [\n { a: '令狐冲', b: '男', c: 41, key: '1' },\n { a: '杨过', b: '男', c: 67, key: '2' },\n { a: '郭靖', b: '男', c: 25, key: '3' },\n];\n\nclass Demo1 extends Component {\n render () {\n return (\n <Table\n columns={columns}\n data={data}\n title={currentData => <div>标题: 这是一个标题</div>}\n footer={currentData => <div>表尾: 我是小尾巴</div>}\n />\n )\n }\n}\n\n\n\n","desc":""},{"example":<Demo10 />,"title":" 无数据时显示","code":"/**\n*\n* @title 无数据时显示\n* @description 无数据时显示效果展示\n*\n*/\n\nimport React, { Component } from 'react';\nimport Table from 'tinper-bee';\n\nconst columns10 = [\n {\n title: \"Name\",\n dataIndex: \"name\",\n key: \"name\",\n width: \"40%\"\n },\n {\n title: \"Age\",\n dataIndex: \"age\",\n key: \"age\",\n width: \"30%\"\n },\n {\n title: \"Address\",\n dataIndex: \"address\",\n key: \"address\"\n }\n ];\n \n const data10 = [\n \n ];\n\n const emptyFunc = () => <span>这里没有数据!</span>\n \n class Demo10 extends Component {\n render() {\n return <Table columns={columns10} data={data10} emptyText={emptyFunc} />;\n }\n }\n\n \n\n","desc":" 无数据时显示效果展示"},{"example":<Demo2 />,"title":" 增删改表格","code":"/**\n*\n* @title 增删改表格\n* @description 这是带有增删改功能的表格\n*\n*/\n\nimport React, { Component } from 'react';\nimport Button from 'bee-button';\nimport Table from 'tinper-bee';\nimport Animate from 'bee-animate';\nimport Icon from \"bee-icon\";\nimport Input from 'bee-form-control';\nimport Popconfirm from 'bee-popconfirm';\n\nclass EditableCell extends React.Component {\n state = {\n value: this.props.value,\n editable: false,\n }\n handleChange = (e) => {\n const value = e.target.value;\n this.setState({ value });\n }\n check = () => {\n this.setState({ editable: false });\n if (this.props.onChange) {\n this.props.onChange(this.state.value);\n }\n }\n edit = () => {\n this.setState({ editable: true });\n }\n handleKeydown = (event) => {\n console.log(event.keyCode);\n if(event.keyCode == 13){\n this.check();\n }\n\n }\n render() {\n const { value, editable } = this.state;\n return (<div className=\"editable-cell\">\n {\n editable ?\n <div className=\"editable-cell-input-wrapper\">\n <Input\n value={value}\n onChange={this.handleChange}\n onKeyDown = {this.handleKeydown}\n />\n <Icon\n type=\"uf-correct\"\n className=\"editable-cell-icon-check\"\n onClick={this.check}\n />\n </div>\n :\n <div className=\"editable-cell-text-wrapper\">\n {value || ' '}\n <Icon\n type=\"uf-pencil\"\n className=\"editable-cell-icon\"\n onClick={this.edit}\n
|
2016-12-26 22:04:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
class Demo extends Component {
|
|
|
|
constructor(props){
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
open: false
|
|
|
|
}
|
|
|
|
this.handleClick = this.handleClick.bind(this);
|
|
|
|
}
|
|
|
|
handleClick() {
|
|
|
|
this.setState({ open: !this.state.open })
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { title, example, code, desc } = this.props;
|
|
|
|
let caret = this.state.open ? CARETUP : CARET;
|
|
|
|
let text = this.state.open ? "隐藏代码" : "查看代码";
|
|
|
|
|
|
|
|
const footer = (
|
|
|
|
<Button shape="block" onClick={ this.handleClick }>
|
|
|
|
{ caret }
|
|
|
|
{ text }
|
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
const header = (
|
|
|
|
<Row>
|
2017-01-11 17:01:50 +08:00
|
|
|
<Col md={12}>
|
2016-12-26 22:04:16 +08:00
|
|
|
{ example }
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
);
|
|
|
|
return (
|
|
|
|
<Col md={12} >
|
|
|
|
<h3>{ title }</h3>
|
|
|
|
<p>{ desc }</p>
|
|
|
|
<Panel collapsible headerContent expanded={ this.state.open } colors='bordered' header={ header } footer={footer} footerStyle = {{padding: 0}}>
|
|
|
|
<pre><code className="hljs javascript">{ code }</code></pre>
|
|
|
|
</Panel>
|
|
|
|
</Col>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DemoGroup extends Component {
|
|
|
|
constructor(props){
|
|
|
|
super(props)
|
|
|
|
}
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<Row>
|
|
|
|
{DemoArray.map((child,index) => {
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Demo example= {child.example} title= {child.title} code= {child.code} desc= {child.desc} key= {index}/>
|
|
|
|
)
|
|
|
|
|
|
|
|
})}
|
|
|
|
</Row>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));
|