antd通过 filterDropdown 自定义--按某天时间搜索

- import React, { Component } from 'react';
- import { Table, Input, Button, Icon, DatePicker } from 'antd';
- import moment from 'moment';
- import Highlighter from 'react-highlight-words';
- export default class RpoliceRecord extends Component {
- constructor(props) {
- super(props);
- this.state = {
- searchText: '',
- }
- }
- render() {
- // 添加搜索
- this.getColumnSearchProps = (dataIndex, title) => ({
- filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
- <div style={{ padding: 8 }}>
- <Input
- ref={node => {
- this.searchInput = node;
- }}
- placeholder={`搜索 ${title}`}
- value={selectedKeys[0]}
- onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])}
- onPressEnter={() => this.handleSearch(selectedKeys, confirm)}
- style={{ width: 188, marginBottom: 8, display: 'block' }}
- />
- <Button
- type="primary"
- onClick={() => this.handleSearch(selectedKeys, confirm)}
- icon="search"
- size="small"
- style={{ width: 90, marginRight: 8 }}>
- 搜索
- </Button>
- <Button onClick={() => this.handleReset(clearFilters)} size="small" style={{ width: 90 }}>重置</Button>
- </div>
- ),
- filterIcon: filtered => (
- <Icon type="search" style={{ color: filtered ? '#1890ff' : undefined }} />
- ),
- onFilter: (value, record) =>
- record[dataIndex]
- .toString()
- .toLowerCase()
- .includes(value.toLowerCase()),
- onFilterDropdownVisibleChange: visible => {
- if (visible) {
- setTimeout(() => this.searchInput.select());
- }
- },
- render: text => (
- <Highlighter
- highlightStyle={{ backgroundColor: '#ffc069', padding: 0 }}
- searchWords={[this.state.searchText]}
- autoEscape
- textToHighlight={text.toString()}
- />
- ),
- });
- //搜索
- this.handleSearch = (selectedKeys, confirm) => {
- confirm();
- console.log(selectedKeys,confirm);
- this.setState({ searchText: selectedKeys[0] });
- };
- this.handleSearchtime = (selectedKeys, confirm) => {
- confirm();
- this.setState({ searchText: selectedKeys });
- };
- //重置
- this.handleReset = clearFilters => {
- clearFilters();
- this.setState({ searchText: '' });
- };
- const columns = [
- { title: '报警时间', dataIndex: 'time', key: 'time',
- filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
- <div style={{ padding: 8 }}>
- <DatePicker placeholder={`搜索时间`}
- value={selectedKeys[0]}
- onChange={dateString => setSelectedKeys(dateString ? [dateString] : [])}
- onPressEnter={() => this.handleSearch(selectedKeys, confirm)}
- style={{ width: 188, marginBottom: 8, display: 'block' }}/>
- <Button
- type="primary"
- onClick={() => this.handleSearchtime(moment(selectedKeys[0]._d).format('YYYY-MM-DD'), confirm)}
- icon="search"
- size="small"
- style={{ width: 90, marginRight: 8 }}>
- 搜索
- </Button>
- <Button onClick={() => this.handleReset(clearFilters)} size="small" style={{ width: 90 }}>重置</Button>
- </div>
- ),
- filterIcon: filtered => (
- <Icon type="search" style={{ color: filtered ? '#1890ff' : undefined }} />
- ),
- onFilter: (value, record) => {
- return record.time.indexOf(moment(value).format('YYYY-MM-DD')) != -1},
- render: text => (
- <Highlighter
- highlightStyle={{ backgroundColor: '#ffc069', padding: 0 }}
- searchWords={[this.state.searchText]}
- autoEscape
- textToHighlight={text.toString()}
- />
- ),
- },
- { title: '来电', key: 'callnum', dataIndex: 'callnum', ...this.getColumnSearchProps('callnum', '来电'), },
- { title: '时长', key: 'longtime', dataIndex: 'longtime', }
- ];
- const data = [
- { key: '1', time: '2019-07-30 16:31:05', callnum: '13546540218', longtime: '37秒' },
- { key: '2', time: '2019-06-24 22:08:05', callnum: '13546540218', longtime: '1分12秒' },
- { key: '3', time: '2017-08-15 12:31:05', callnum: '13546540218', longtime: '1分10秒' },
- { key: '4', time: '2016-12-30 06:15:00', callnum: '13546540218', longtime: '20秒' }
- ];
- return (
- <Table className="accidentTable" columns={columns} dataSource={data} bordered size="small" />
- )
- }
- }
antd通过 filterDropdown 自定义--按某天时间搜索的更多相关文章
- python selenium 时间搜索框查询和日期大小比较
在做selenium自动化的时候遇到 时间搜索框查询(如下图)并比较查询结果是否在输入的时间之类. 首先,第一步要做的就是选择时间,并获取到所选时间的文本信息 如上图所示,获取到的时间搜索框并没有文本 ...
- SpringJPA主键生成采用自定义ID,自定义ID采用年月日时间格式
自定义主键生成策略 在entity类上添加注解 @Id @GeneratedValue(strategy = GenerationType.AUTO, generator = "custom ...
- Sublime2 DocBlocker插件在自动补全注释时输出自定义作者和当前时间等信息
Sublime在进行前端开发时非常棒,当然也少不了众多的插件支持,DocBlocker是在Sublime平台上开发一款自动补全代码插件,支持JavaScript (including ES6), PH ...
- spring-redis-session 自定义 key 和过期时间
对于分布式应用来说,最开始遇到的问题就是 session 的存储了,解决方案大致有如下几种 使用 spring-session 它可以把 session 存储到你想存储的位置,如 redis,mysq ...
- 小程序自定义pick(日期加时间组合)
最近小程序有个需求要使用日期加时间的pick组件 翻了小程序文档似乎没有符合的 手写一个 新建组件picker.js: Component({ properties: { disabled: { t ...
- spring cache之自定义keys的过期时间
spring @cacheable注解默认不支持方法级别的缓存失效时间,只能通过配置来配置全局的失效时间 如果需要实现对方法级别的缓存支持失效时间机制,有一种比较简单的方法,spring配置文件如下: ...
- 使用vue自定义组件以及动态时间
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- react中antd的表格自定义展开
antd的表格官方案例中给出的都是固定的图表展开,在做需求的时候,需要使用点击最后一列,然后出现展开内容,实现效果图如下 在最开始设置一个全局变量 const keys = [];在设置列参数的函数中 ...
- 【antd】如何自定义antd组件form表单中Form.Item里的内容组件
需求:现有一个form表单,但是其中一个元素比较复杂,并不是简单的输入框或者下拉框之类的.但是我又希望能通过form.validateFields().then()去获得它的值,就不需要在当前页面写大 ...
随机推荐
- [Cqoi2016]K远点对 K-Dtree
4520: [Cqoi2016]K远点对 链接 bzoj 思路 用K-Dtree求点的最远距离. 求的时候顺便维护一个大小为2k的小根堆. 不知道为啥一定会对. 代码 #include <bit ...
- JVM参数笔记
Java启动参数共分为三类: 其一是标准参数(-),所有的JVM实现都必须实现这些参数的功能,而且向后兼容: 其二是非标准参数(-X),默认jvm实现这些参数的功能,但是并不保证所有jvm实现都满足, ...
- Octopus501工作站 安装记录
cmake libreadline-dev 没有运行程序,nvidia-smi查看GPU-Util 达到100% 解决方案:需要把驱动模式设置为常驻内存才可以,设置命令:nvidia-smi -pm ...
- [Gamma阶段]第九次Scrum Meeting
Scrum Meeting博客目录 [Gamma阶段]第九次Scrum Meeting 基本信息 名称 时间 地点 时长 第九次Scrum Meeting 19/06/05 大运村寝室6楼 20min ...
- dubbo源码分析之过滤器Filter-12
https://blog.csdn.net/luoyang_java/article/details/86682668 Dubbo 是阿里巴巴开源的一个高性能优秀的服务框架,使得应用可通过高性能的 R ...
- JVM探究之 —— 类加载器-双亲委派模型
虚拟机设计团队把类加载阶段中的“通过一个类的全限定名来获取描述此类的二进制字节流”这个动作放到Java虚拟机外部去实现,以便让应用程序自己决定如何去获取所需要的类.实现这个动作的代码模块称为“类加载器 ...
- pdf怎么转换成word
在线转换:https://app.xunjiepdf.com/pdf2word
- vs开启,Windows 10磁盘占用100%解决办法
https://www.cnblogs.com/time-is-life/p/8888441.html 最后把Home Group相关的服务都改成禁用. 注意: 即使这两个服务没有启动也不行, 一定要 ...
- session与getSession()用法总结
一.session 1.session的过期时间是从什么时候开始计算的?是从一登录就开始计算还是说从停止活动开始计算? 从session不活动的时候开始计算,如果session一直活动,session ...
- kotlin基础 字符串模板
${变量名} var tmp="字符串模板” print("今天学习${tmp}这个知识点")