1.逻辑代码

list.js

  1. /**
  2. * 用户列表页
  3. */
  4. import React,{ PureComponent } from 'react'
  5. import {connect} from 'react-redux'
  6. import {history} from '../../store'
  7. import styles from './index.less'
  8. import { Row, Col, Card, Form, Input, Select, Button } from 'antd';
  9.  
  10. const FormItem = Form.Item;
  11. const { Option } = Select;
  12. const statusMap = ['success', 'error'];
  13. const status = ['启用', '禁用',];
  14.  
  15. /**
  16. * 用户列表
  17. */
  18. @Form.create()
  19. class UserList extends PureComponent{
  20. state = {
  21. //
  22. };
  23.  
  24. renderAdvancedForm() {
  25. const { getFieldDecorator } = this.props.form;
  26. return (
  27. <Form onSubmit={this.handleSearch.bind(this)} layout="inline">
  28. {/*搜索条件*/}
  29. <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
  30. <Col md={8} sm={24}>
  31. <FormItem label="账号">
  32. {getFieldDecorator('username')(
  33. <Input placeholder="请输入" />
  34. )}
  35. </FormItem>
  36. </Col>
  37. <Col md={8} sm={24}>
  38. <FormItem label="姓名">
  39. {getFieldDecorator('name')(
  40. <Input placeholder="请输入" />
  41. )}
  42. </FormItem>
  43. </Col>
  44. <Col md={8} sm={24}>
  45. <FormItem label="状态">
  46. {getFieldDecorator('status')(
  47. <Select placeholder="请选择">
  48. <Option value="0">启用</Option>
  49. <Option value="1">禁用</Option>
  50. </Select>
  51. )}
  52. </FormItem>
  53. </Col>
  54. </Row>
  55. {/*按钮*/}
  56. <div style={{ marginBottom: 10 }}>
  57. <span>
  58. <Button
  59. icon="plus"
  60. type="primary"
  61. onClick={()=>(
  62. history.push("/syster/user/add")
  63. )}
  64. >
  65. 新建
  66. </Button>
  67. </span>
  68. <span style={{ float: 'right' }}>
  69. <Button
  70. icon="search"
  71. type="primary"
  72. htmlType="submit"
  73. >查询</Button>
  74. <Button
  75. icon="sync"
  76. style={{ marginLeft: 8 }}
  77. onClick={this.handleFormReset.bind(this)}
  78. >重置</Button>
  79. </span>
  80. </div>
  81. </Form>
  82. );
  83. }
  84.  
  85. // 查询
  86. handleSearch(e){
  87. // 禁止默认行为
  88. e.preventDefault();
  89. // 获取 form 表单的值
  90. console.log(this.props.form.getFieldsValue());
  91. }
  92.  
  93. // 重置
  94. handleFormReset(){
  95. this.props.form.resetFields();
  96. }
  97.  
  98. render(){
  99.  
  100. return(
  101. <Card bordered={false}>
  102. <div className={styles.tableList}>
  103. <div className={styles.tableListForm}>
  104. {this.renderAdvancedForm()}
  105. </div>
  106. </div>
  107. </Card>
  108. )
  109. }
  110. }
  111.  
  112. export default connect (({ user })=>(
  113. user
  114. ))(UserList)

2.样式

  1. @import "~antd/lib/style/themes/default.less";
  2. @import "../../utils/utils.less";
  3.  
  4. .tableList {
  5. .tableListOperator {
  6. margin-bottom: 16px;
  7. button {
  8. margin-right: 8px;
  9. }
  10. }
  11. }
  12.  
  13. .tableListForm {
  14. :global {
  15. .ant-form-item {
  16. margin-bottom: 24px !important;
  17. margin-right: 0;
  18. display: flex;
  19. > .ant-form-item-label {
  20. width: auto;
  21. line-height: 32px;
  22. padding-right: 8px;
  23. }
  24. .ant-form-item-control {
  25. line-height: 32px;
  26. }
  27. }
  28. .ant-form-item-control-wrapper {
  29. flex: 1;
  30. }
  31. }
  32. .submitButtons {
  33. white-space: nowrap;
  34. margin-bottom: 24px;
  35. }
  36. }
  37.  
  38. @media screen and (max-width: @screen-lg) {
  39. .tableListForm :global(.ant-form-item) {
  40. margin-right: 24px;
  41. }
  42. }
  43.  
  44. @media screen and (max-width: @screen-md) {
  45. .tableListForm :global(.ant-form-item) {
  46. margin-right: 8px;
  47. }
  48. }

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. mysql-5.7.15-winx64配置

    1.    配置环境变量 1.1  添加path路径 选择 控制面板>系统和安全>系统>高级系统设置>环境变量 mysql文件目录的绝对路径\bin 1.2  修改mysql ...

  2. win上使用nvm管理node版本

    win上使用nvm管理node版本 若想让nvm管理机器上所有的node版本,首先需要卸载电脑上已有的node(很重要), 然后下载nvm在win上的安装包 windows-nvm的下载地址 下载 下 ...

  3. 发布Office 365插件

    在上一篇博客<VisualStudio 2013开发Office插件>开发完成了插件后,需要将插件发布 发布前需要: Azure 应用服务,作为Office插件的发布空间,地址是:http ...

  4. python3 base64解码出现TypeError:Incorrect padding

    今天在解决爬虫对加密参数的分析时,需要使用到base64解码.但是过程中出现了TypeError:Incorrect padding的错误提示.以下是解决方法,以便查阅. 其实正常使用base64是不 ...

  5. 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 ...

  6. Express下使用formidable实现POST表单上传文件并保存

    Express下使用formidable实现POST表单上传文件并保存 在上一篇文章中使用formidable实现了上传文件,但没将它保存下来. 一开始,我也以为是只得到了文件的相关信息,需要用fs. ...

  7. sql developer 自定义快捷键

  8. [BZOJ 1801] Chess

    Link: BZOJ 1801 传送门 Solution: 一眼看过去又像是状压$dp$的经典模型…… 但此题$n,m\le 100$ ,直接跑状压只有50分 此时要发现这道题的特点:每行/列不能放置 ...

  9. codeforces 314E Sereja and Squares

    discription Sereja painted n points on the plane, point number i (1 ≤ i ≤ n) has coordinates (i, 0). ...

  10. [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 ...