ant-design 实现 搜索功能
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 实现 搜索功能的更多相关文章
- ant design pro (十二)advanced UI 测试
一.概述 原文地址:https://pro.ant.design/docs/ui-test-cn UI 测试是项目研发流程中的重要一环,有效的测试用例可以梳理业务需求,保证研发的质量和进度,让工程师可 ...
- 使用express、react、webpack打包、socket.io、mongodb、ant.design、less、es6实现聊天室
拿到一个项目,我们应该如何去完成这个项目呢. 是直接上手? 还是先进行分析,然后再去解决呢?毫无疑问,如果直接上手解决,那么可能会因为知道目标所在,而导致出现各种问题. 所以,我们应该系统的分析这个项 ...
- Ant Design 错误记录
Ant Design 错误记录 一: 标签页Tabs 1:设置activeKey或defaultActiveKey,绑定默认值不起作用: => 需要同时设置activeKey和defaul ...
- 使用Ant Design写一个仿微软ToDo
实习期的第一份活,自己看Ant Design的官网学习,然后用Ant Design写一个仿微软ToDo. 不做教学目的,只是记录一下. 1.学习 Ant Design 是个组件库,想要会用,至少要知道 ...
- 使用Vue+Django+Ant Design做一个留言评论模块
使用Vue+Django+Ant Design做一个留言评论模块 1.总览 留言的展示参考网络上参见的格式,如掘金社区: 一共分为两层,子孙留言都在第二层中 最终效果如下: 接下是数据库的表结构,如下 ...
- Ant Design Pro入门教程,安装,运行(V5 Typescript版)
[前言] 找了很多Admin模板,最后还是看中了AntDesignPro这个阿里巴巴开源的Admin框架,长这样(还行吧,目前挺主流的): 官网地址:https://pro.ant.design/in ...
- (二)React Ant Design Pro + .Net5 WebApi:前端环境搭建
首先,你需要先装一个Nodejs,这是基础哦.如果没有这方面知识的小伙伴可以在园子里搜索cnpm yarn等关键字,内容繁多,此不赘述,参考链接 一. 简介 1. Ant Design Pro v5 ...
- Ant Design Blazor 组件库的路由复用多标签页介绍
最近,在 Ant Design Blazor 组件库中实现多标签页组件的呼声日益高涨.于是,我利用周末时间,结合 Blazor 内置路由组件实现了基于 Tabs 组件的 ReuseTabs 组件. 前 ...
- Vue.js高效前端开发 • 【Ant Design of Vue框架进阶】
全部章节 >>>> 文章目录 一.栅格组件 1.栅格组件介绍 2.栅格组件使用 3.实践练习 二.输入组件 1.输入框组件使用 2.选择器组件使用 3.单选框组件使用 4.实践 ...
- Vue.js高效前端开发 • 【Ant Design of Vue框架基础】
全部章节 >>>> 文章目录 一.Ant Design of Vue框架 1.Ant Design介绍 2.Ant Design of Vue安装 3.Ant Design o ...
随机推荐
- mysql-5.7.15-winx64配置
1. 配置环境变量 1.1 添加path路径 选择 控制面板>系统和安全>系统>高级系统设置>环境变量 mysql文件目录的绝对路径\bin 1.2 修改mysql ...
- win上使用nvm管理node版本
win上使用nvm管理node版本 若想让nvm管理机器上所有的node版本,首先需要卸载电脑上已有的node(很重要), 然后下载nvm在win上的安装包 windows-nvm的下载地址 下载 下 ...
- 发布Office 365插件
在上一篇博客<VisualStudio 2013开发Office插件>开发完成了插件后,需要将插件发布 发布前需要: Azure 应用服务,作为Office插件的发布空间,地址是:http ...
- python3 base64解码出现TypeError:Incorrect padding
今天在解决爬虫对加密参数的分析时,需要使用到base64解码.但是过程中出现了TypeError:Incorrect padding的错误提示.以下是解决方法,以便查阅. 其实正常使用base64是不 ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - J CONTINUE...?
CONTINUE...? Time Limit: 1 Second Memory Limit: 65536 KB Special Judge DreamGrid has clas ...
- Express下使用formidable实现POST表单上传文件并保存
Express下使用formidable实现POST表单上传文件并保存 在上一篇文章中使用formidable实现了上传文件,但没将它保存下来. 一开始,我也以为是只得到了文件的相关信息,需要用fs. ...
- sql developer 自定义快捷键
- [BZOJ 1801] Chess
Link: BZOJ 1801 传送门 Solution: 一眼看过去又像是状压$dp$的经典模型…… 但此题$n,m\le 100$ ,直接跑状压只有50分 此时要发现这道题的特点:每行/列不能放置 ...
- codeforces 314E Sereja and Squares
discription Sereja painted n points on the plane, point number i (1 ≤ i ≤ n) has coordinates (i, 0). ...
- [Contest20180318]求和
题意:求$\sum\limits_{i=1}^n\sum\limits_{j=1}^i\sum\limits_{k=1}^i(i,j,k)$ 先令$f(n)=\sum\limits_{i=1}^n\s ...