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.效果图

ant-design 实现 搜索功能的更多相关文章

  1. ant design pro (十二)advanced UI 测试

    一.概述 原文地址:https://pro.ant.design/docs/ui-test-cn UI 测试是项目研发流程中的重要一环,有效的测试用例可以梳理业务需求,保证研发的质量和进度,让工程师可 ...

  2. 使用express、react、webpack打包、socket.io、mongodb、ant.design、less、es6实现聊天室

    拿到一个项目,我们应该如何去完成这个项目呢. 是直接上手? 还是先进行分析,然后再去解决呢?毫无疑问,如果直接上手解决,那么可能会因为知道目标所在,而导致出现各种问题. 所以,我们应该系统的分析这个项 ...

  3. Ant Design 错误记录

    Ant Design 错误记录 一: 标签页Tabs 1:设置activeKey或defaultActiveKey,绑定默认值不起作用: =>    需要同时设置activeKey和defaul ...

  4. 使用Ant Design写一个仿微软ToDo

    实习期的第一份活,自己看Ant Design的官网学习,然后用Ant Design写一个仿微软ToDo. 不做教学目的,只是记录一下. 1.学习 Ant Design 是个组件库,想要会用,至少要知道 ...

  5. 使用Vue+Django+Ant Design做一个留言评论模块

    使用Vue+Django+Ant Design做一个留言评论模块 1.总览 留言的展示参考网络上参见的格式,如掘金社区: 一共分为两层,子孙留言都在第二层中 最终效果如下: 接下是数据库的表结构,如下 ...

  6. Ant Design Pro入门教程,安装,运行(V5 Typescript版)

    [前言] 找了很多Admin模板,最后还是看中了AntDesignPro这个阿里巴巴开源的Admin框架,长这样(还行吧,目前挺主流的): 官网地址:https://pro.ant.design/in ...

  7. (二)React Ant Design Pro + .Net5 WebApi:前端环境搭建

    首先,你需要先装一个Nodejs,这是基础哦.如果没有这方面知识的小伙伴可以在园子里搜索cnpm yarn等关键字,内容繁多,此不赘述,参考链接 一. 简介 1. Ant Design Pro v5 ...

  8. Ant Design Blazor 组件库的路由复用多标签页介绍

    最近,在 Ant Design Blazor 组件库中实现多标签页组件的呼声日益高涨.于是,我利用周末时间,结合 Blazor 内置路由组件实现了基于 Tabs 组件的 ReuseTabs 组件. 前 ...

  9. Vue.js高效前端开发 • 【Ant Design of Vue框架进阶】

    全部章节 >>>> 文章目录 一.栅格组件 1.栅格组件介绍 2.栅格组件使用 3.实践练习 二.输入组件 1.输入框组件使用 2.选择器组件使用 3.单选框组件使用 4.实践 ...

  10. Vue.js高效前端开发 • 【Ant Design of Vue框架基础】

    全部章节 >>>> 文章目录 一.Ant Design of Vue框架 1.Ant Design介绍 2.Ant Design of Vue安装 3.Ant Design o ...

随机推荐

  1. k8s的service

    1.service简介 本节开始学习 Service.我们不应该期望 Kubernetes Pod 是健壮的,而是要假设 Pod 中的容器很可能因为各种原因发生故障而死掉.Deployment 等 c ...

  2. window10下部署flask系统(apache和wsgi)

    公司有一个小系统,通过url和其他系统进行数据交互(有点土). 因此,利用flask写了一个小程序. 现在,考虑到并发问题(flask自身是不会并发的),准备部署在apache+wsgi环境. 网上百 ...

  3. UTF-8编码中BOM的检测与删除[linux下命令]

    Posted on 2011-05-14 所谓BOM,全称是Byte Order Mark,它是一个Unicode字符,通常出现在文本的开头,用来标识字节序(Big/Little Endian),除此 ...

  4. [libGDX游戏开发教程]使用libGDX进行游戏开发(12)-Action动画

    前文章节列表:  使用libGDX进行游戏开发(11)-高级编程技巧   使用libGDX进行游戏开发(10)-音乐音效不求人,程序员也可以DIY   使用libGDX进行游戏开发(9)-场景过渡   ...

  5. 转载] magento 产品数据表结构

    原文地址:http://blog.sina.com.cn/s/blog_9302097a010120l4.html 数据库-- 产品数据库表结构分析 product 1数据库实体表:catalog_p ...

  6. 使用Rancher管理Docker

    使用命令: sudo docker run -it -d --restart=always -p : --name docker-rancher rancher/server 为了更快速的下载应用,推 ...

  7. 8、Flask实战第8天:add_url_rule和app.route原理

    之前我们使用@app.route这个装饰器来把视图函数和url绑定 @app.route('/') def hell_world(): return 'hello world' 而且我们可以通过url ...

  8. 微信小程序开发教程(五)开发框架:MINA

    微信团队为小程序提供的框架命名为MINA应用框架.MINA框架通过封装微信客户端提供的文件系统.网络通信.任务管理.数据安全等基础功能,对上层提供一整套JavaScript API,让开发者能够非常方 ...

  9. POJ 2315:Football Game(博弈论)

    [题目链接] http://poj.org/problem?id=2315 [题目大意] 两名球员轮流从N个球中挑出不多于M个射门,每个球半径都是R,离球门S. 每次只能踢出L以内的距离.进最后一个球 ...

  10. 【点分治】【哈希表】bzoj2599 [IOI2011]Race

    给nlog2n随便过的跪了,不得已弄了个哈希表伪装成nlogn(当然随便卡,好孩子不要学)…… 不过为啥哈希表的大小开小点就RE啊……?必须得超过数据范围一大截才行……谜 #include<cs ...