import React, { Component } from 'react'; import moment from 'moment'; import { connect } from 'dva'; import { routerRedux } from 'dva/router'; import { Form, Card, Select, List, Tag, Icon, Avatar, Row, Col } from 'antd'; import PageHeaderLayout from '../../layouts/PageHeaderLayout'; import StandardFormRow from '../../components/StandardFormRow'; import TagSelect from '../../components/TagSelect'; import SearchInput from '../../components/SearchInput'; import styles from './SearchList.less'; const Option = Select.Option; const FormItem = Form.Item; const TagOption = TagSelect.Option; const TagExpand = TagSelect.Expand; @Form.create() @connect(state => ({ list: state.list, })) export default class SearchList extends Component { state = { count: 3, showLoadMore: true, loadingMore: false, } componentDidMount() { const { count } = this.state; this.props.dispatch({ type: 'list/fetch', payload: { count, }, }); } setOwner = () => { const { form } = this.props; form.setFieldsValue({ owner: ['wzj'], }); } handleLoadMore = () => { const { count } = this.state; const nextCount = count + 5; this.setState({ count: nextCount, loadingMore: true, }); this.props.dispatch({ type: 'list/fetch', payload: { count: nextCount, }, callback: () => { this.setState({ loadingMore: false, }); // fack count if (nextCount < 10) { this.setState({ showLoadMore: false, }); } }, }); } handleTabChange = (key) => { const { dispatch } = this.props; switch (key) { case 'docs': dispatch(routerRedux.push('/list/search')); break; case 'app': dispatch(routerRedux.push('/list/filter-card-list')); break; case 'project': dispatch(routerRedux.push('/list/cover-card-list')); break; default: break; } } render() { const { showLoadMore, loadingMore } = this.state; const { form, list: { list } } = this.props; const { getFieldDecorator } = form; const owners = [ { id: 'wzj', name: '我自己', }, { id: 'wjh', name: '吴家豪', }, { id: 'zxx', name: '周星星', }, { id: 'zly', name: '赵丽颖', }, { id: 'ym', name: '姚明', }, ]; const tabList = [ { key: 'doc', tab: '文章', }, { key: 'app', tab: '应用', }, { key: 'project', tab: '项目', }, ]; const IconText = ({ type, text }) => ( {text} ); const ListContent = ({ data: { content, updatedAt, avatar, owner, href } }) => (

{content}

{owner} 发布在 {href} {moment(updatedAt).format('YYYY-MM-DD hh:mm')}
); const pageHeaderContent = (
); const formItemLayout = { wrapperCol: { xs: { span: 24 }, sm: { span: 16 }, }, }; return (
{getFieldDecorator('category')( 类目一 类目二 类目三 类目四 类目五 类目六 )} {getFieldDecorator('owner', { initialValue: ['wjh', 'zxx'], })( )} 只看自己的 {getFieldDecorator('user', {})( )} {getFieldDecorator('rate', {})( {getFieldDecorator('rate', {})( )} )}
0) && showLoadMore} onLoadMore={this.handleLoadMore} itemLayout="vertical" > { list && list.map(item => ( , , ]} extra={
} > {item.title}} description={Ant Design设计语言蚂蚁金服} /> )) }
); } }