yapi/client/containers/News/NewsList/NewsList.js

83 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-07-17 12:15:21 +08:00
import React, { Component } from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
2017-07-20 16:30:55 +08:00
import { Menu } from 'antd'
2017-08-07 19:34:34 +08:00
import {
2017-07-20 16:30:55 +08:00
fetchNewsData
2017-08-08 10:07:55 +08:00
} from '../../../reducer/modules/news.js'
2017-07-17 12:15:21 +08:00
2017-07-20 16:30:55 +08:00
const logList = [{
name: '用户'
},{
name: '分组'
},{
name: '接口'
},{
name: '项目'
}];
2017-07-17 12:15:21 +08:00
@connect(
state => {
2017-07-24 16:41:11 +08:00
// console.log(state);
2017-07-17 12:15:21 +08:00
return {
2017-08-09 16:08:37 +08:00
uid: state.login.uid + "",
2017-07-17 12:15:21 +08:00
newsData: state.news.newsData
}
},
{
2017-07-20 16:30:55 +08:00
fetchNewsData
2017-07-17 12:15:21 +08:00
}
)
class NewsList extends Component {
static propTypes = {
fetchNewsData: PropTypes.func,
2017-07-24 16:41:11 +08:00
setLoading: PropTypes.func,
uid: PropTypes.string
2017-07-17 12:15:21 +08:00
}
constructor(props) {
super(props)
2017-07-20 16:30:55 +08:00
this.state = {
selectedKeys: 0
2017-07-17 12:15:21 +08:00
}
}
2017-07-20 16:30:55 +08:00
getLogData(e){
// page,size,logId
// console.log(e.key);
this.setState({
selectedKeys: +e.key
})
const that = this;
this.props.setLoading(true);
2017-07-24 16:41:11 +08:00
this.props.fetchNewsData(+this.props.uid,0,5).then(function(data){
console.log(data.data);
2017-07-20 16:30:55 +08:00
that.props.setLoading(false);
})
2017-07-17 12:15:21 +08:00
}
render () {
return (
2017-07-20 16:30:55 +08:00
<div className='logList'>
<h3>日志类型</h3>
<Menu
mode='inline'
selectedKeys = {[`${this.state.selectedKeys}`]}
onClick = {this.getLogData.bind(this)}
>
{logList.map((item,i)=>{
return (
<Menu.Item key={i} className="log-item">
{item.name}
</Menu.Item>
)
})}
2017-08-07 19:34:34 +08:00
2017-07-20 16:30:55 +08:00
</Menu>
</div>
2017-07-17 12:15:21 +08:00
)
}
}
2017-08-07 19:34:34 +08:00
export default NewsList