diff --git a/src/components/table.js b/src/components/table.js index 793195e..ad0f4b9 100644 --- a/src/components/table.js +++ b/src/components/table.js @@ -6,7 +6,8 @@ class FeTable extends Component { super(props) this.state = { data: [], - columns: [] + columns: [], + total: 0 } } @@ -14,7 +15,8 @@ class FeTable extends Component { if (props.data !== state.data && props.data) { return { data: props.data, - columns: props.columns + columns: props.columns, + total: props.total } } return null @@ -24,15 +26,22 @@ class FeTable extends Component { return this.props.callback(e.target.innerText, value) } + onChange = e =>{ + return this.props.pageChange(e) + } + + onShowSizeChange = (current,pageSize) =>{ + return this.props.onShowSizeChange(current,pageSize) + } + render() { return ( - { - return { +
{return { onClick: event => this.jumpRow(event, record) } - } - } /> + }} pagination={{total: this.state.total,onChange:this.onChange.bind(this),showSizeChanger:true, + onShowSizeChange:this.onShowSizeChange.bind(this)}}/> ) } diff --git a/src/pages/home/branch/dashboard/dashboard.js b/src/pages/home/branch/dashboard/dashboard.js index 8bbb7a6..bff0ce3 100644 --- a/src/pages/home/branch/dashboard/dashboard.js +++ b/src/pages/home/branch/dashboard/dashboard.js @@ -19,6 +19,7 @@ class Dashboard extends Component { rating: {}, //评价记录 industry: [], //行业分布 company: [], //新增企业 + total: 0, columns: [ { title: '企业ID', dataIndex: '企业ID', key: 0 }, { title: '企业名称', dataIndex: '企业名称', key: 1 }, @@ -53,7 +54,7 @@ class Dashboard extends Component { api.get("/admin/board/get_rating_static").then(res => { this.setState({ rating: res.result - },()=>{ + }, () => { this.initChart() }) }) @@ -62,15 +63,16 @@ class Dashboard extends Component { api.get("/admin/board/get_industry_distribute").then(res => { this.setState({ industry: res.result - },()=>{ + }, () => { this.initPie() }) }) // 新增企业 - api.get("/admin/board/get_new_companies",{page_no:1,page_size:10}).then(res => { + api.get("/admin/board/get_new_companies", { page_no: 1, page_size: 10 }).then(res => { this.setState({ - company: res.result + company: res.result.records, + total: res.result.total }) }) } @@ -210,6 +212,25 @@ class Dashboard extends Component { } } + pageChange = e =>{ + + api.get("/admin/board/get_new_companies", { page_no: e, page_size: 10 }).then(res => { + this.setState({ + company: res.result.records, + total: res.result.total + }) + }) + } + + // onShowSizeChange = (current,pageSize) =>{ + // api.get("/admin/board/get_new_companies", { page_no: current, page_size: pageSize }).then(res => { + // this.setState({ + // company: res.result.records, + // total: res.result.total + // }) + // }) + // } + render() { return ( @@ -251,7 +272,7 @@ class Dashboard extends Component { - + diff --git a/src/pages/home/side.js b/src/pages/home/side.js index 47a20f6..eb173ea 100644 --- a/src/pages/home/side.js +++ b/src/pages/home/side.js @@ -43,19 +43,23 @@ class Side extends Component { }) } - handleCurrentClick = e =>{ + handleCurrentClick = e => { this.setState({ currentKey: e.key }); } render() { - const menus = localStorage.getItem("menus").split(',') || ['Board', 'Manage', 'Model', 'Test', 'Setting'] - const menuItem = menus.map((item, i) => { - return - {this.state.data.map((ele, index) => { - return ele.category === item ? {ele.title} : null - })} - - }) + var menus,menuItem + + if (localStorage.getItem("menus")) { + menus = localStorage.getItem("menus").split(',') || ['Board', 'Manage', 'Model', 'Test', 'Setting'] + menuItem = menus.map((item, i) => { + return + {this.state.data.map((ele, index) => { + return ele.category === item ? {ele.title} : null + })} + + }) + } return (