1.逻辑代码

list.js

/**
* 用户列表页
*/
import React,{ PureComponent } from 'react'
import {connect} from 'react-redux'
import {history} from '../../store'
import styles from './index.less'
import { Row, Col, Card, Form, Input, Select, Button } from 'antd'; const FormItem = Form.Item;
const { Option } = Select;
const statusMap = ['success', 'error'];
const status = ['启用', '禁用',]; /**
* 用户列表
*/
@Form.create()
class UserList extends PureComponent{
state = {
//
}; renderAdvancedForm() {
const { getFieldDecorator } = this.props.form;
return (
<Form onSubmit={this.handleSearch.bind(this)} layout="inline">
{/*搜索条件*/}
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
<Col md={8} sm={24}>
<FormItem label="账号">
{getFieldDecorator('username')(
<Input placeholder="请输入" />
)}
</FormItem>
</Col>
<Col md={8} sm={24}>
<FormItem label="姓名">
{getFieldDecorator('name')(
<Input placeholder="请输入" />
)}
</FormItem>
</Col>
<Col md={8} sm={24}>
<FormItem label="状态">
{getFieldDecorator('status')(
<Select placeholder="请选择">
<Option value="0">启用</Option>
<Option value="1">禁用</Option>
</Select>
)}
</FormItem>
</Col>
</Row>
{/*按钮*/}
<div style={{ marginBottom: 10 }}>
<span>
<Button
icon="plus"
type="primary"
onClick={()=>(
history.push("/syster/user/add")
)}
>
新建
</Button>
</span>
<span style={{ float: 'right' }}>
<Button
icon="search"
type="primary"
htmlType="submit"
>查询</Button>
<Button
icon="sync"
style={{ marginLeft: 8 }}
onClick={this.handleFormReset.bind(this)}
>重置</Button>
</span>
</div>
</Form>
);
} // 查询
handleSearch(e){
// 禁止默认行为
e.preventDefault();
// 获取 form 表单的值
console.log(this.props.form.getFieldsValue());
} // 重置
handleFormReset(){
this.props.form.resetFields();
} render(){ return(
<Card bordered={false}>
<div className={styles.tableList}>
<div className={styles.tableListForm}>
{this.renderAdvancedForm()}
</div>
</div>
</Card>
)
}
} export default connect (({ user })=>(
user
))(UserList)

2.样式

@import "~antd/lib/style/themes/default.less";
@import "../../utils/utils.less"; .tableList {
.tableListOperator {
margin-bottom: 16px;
button {
margin-right: 8px;
}
}
} .tableListForm {
:global {
.ant-form-item {
margin-bottom: 24px !important;
margin-right: 0;
display: flex;
> .ant-form-item-label {
width: auto;
line-height: 32px;
padding-right: 8px;
}
.ant-form-item-control {
line-height: 32px;
}
}
.ant-form-item-control-wrapper {
flex: 1;
}
}
.submitButtons {
white-space: nowrap;
margin-bottom: 24px;
}
} @media screen and (max-width: @screen-lg) {
.tableListForm :global(.ant-form-item) {
margin-right: 24px;
}
} @media screen and (max-width: @screen-md) {
.tableListForm :global(.ant-form-item) {
margin-right: 8px;
}
}

3.效果图

最新文章

  1. assert_option()可以用来对assert()进行一些约束和控制
  2. Windows Phone 十四、磁贴通知
  3. R语言基础绘图
  4. MFC中控制COMBOBOX控件的下拉框高度
  5. oracle.jbo.JboException: JBO-29000: JBO-29000: Bad version number in .class file
  6. Sqli-labs less 41
  7. BestCoder Round #36 (hdu5198)Strange Class(水题)
  8. Network Saboteur(搜索)
  9. (转)eclipse 启动参数介绍(如添加插件时,如果不显示,则使用eclipse -clean启动)
  10. cannot run program "git.exe":CreateProcess error=2
  11. Scroll View 控件以Thumbnail的方式显示一个目录的全部图片,相似图片浏览器
  12. 11-散列4 Hashing - Hard Version
  13. 移动App,AJAX异步请求,实现简单的增、删、改、查
  14. 学习笔记—HTML基础标签
  15. FreeBSD常用操作
  16. $Django Paginator分页器 批量创建数据
  17. 2018/7/26号碰到了个奇怪的问题(http有问题,但是ftp没毛病)
  18. 17mysql2█▓
  19. django-QueryDict 对象
  20. pyobjc-framework-Cocoa 5.1.2

热门文章

  1. 前段基础HTML
  2. go语言多态接口样例
  3. C#调用耗时函数时显示进度条浅探
  4. centos 命令行修改主机名
  5. Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes
  6. 浙南联合训练赛 B-Laptops
  7. java读写文件及保留指定位小数
  8. pythonGUI编程用Canvas模拟画板
  9. Douglas Peucker算法的C#实现
  10. OpenDigg - 挖掘优质开源项目库