From 9fa776ca5ae2657d9af28334f2c5d6f9eb834245 Mon Sep 17 00:00:00 2001 From: kvkens Date: Mon, 26 Nov 2018 21:08:20 +0800 Subject: [PATCH] =?UTF-8?q?add:=E8=BF=87=E6=BB=A4=E8=A1=8C=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=A2=9E=E5=8A=A0=E6=97=A5=E6=9C=9F=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/demolist/Demo27.js | 15 +++++- src/FilterType.js | 104 ++++++++++++++++++++++++++-------------- src/TableHeader.js | 18 +++++++ 3 files changed, 99 insertions(+), 38 deletions(-) diff --git a/demo/demolist/Demo27.js b/demo/demolist/Demo27.js index ee9a94d..71d1ad2 100644 --- a/demo/demolist/Demo27.js +++ b/demo/demolist/Demo27.js @@ -182,7 +182,20 @@ class Demo27 extends Component { }); } }, - { title: "居住地址", width: 150, dataIndex: "address", key: "address", filterType: "dropdown", filterDropdown: "hide" }, + { + title: "居住地址", + width: 350, + dataIndex: "address", + key: "address", + filterType: "daterange", + filterDropdown: "show" + }, + { + title: "操作", + width: 100, + key: "other", + dataIndex: "other" + } ]; return () diff --git a/src/FilterType.js b/src/FilterType.js index 932ccc1..7de8f4d 100644 --- a/src/FilterType.js +++ b/src/FilterType.js @@ -1,11 +1,14 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; +import zhCN from "rc-calendar/lib/locale/zh_CN"; import FormControl from 'bee-form-control'; import Select from 'bee-select'; import InputNumber from 'bee-input-number'; import DatePicker from 'bee-datepicker'; import FilterDropDown from './FilterDropDown'; +const { RangePicker } = DatePicker; + const propTypes = { filterDropdown: PropTypes.string }; @@ -108,17 +111,18 @@ class FilterType extends Component { * @returns */ renderControl = (rendertype) => { - let { filterDropdown, filterDropdownType, className, onChange, onSelectDropdown, clsPrefix, locale } = this.props; + let { filterDropdown, filterDropdownType, format, className, onChange, onSelectDropdown, clsPrefix, locale } = this.props; switch (rendertype) { case 'text': - return
this.text = el} - value={this.state.text} - className={className} - onChange={this.changeText} - onKeyDown={this.changeTextCall} - onBlur={this.changeTextCallBlur} - /> + return
+ this.text = el} + value={this.state.text} + className={className} + onChange={this.changeText} + onKeyDown={this.changeTextCall} + onBlur={this.changeTextCallBlur} + />
case 'dropdown': - return
case 'date': - return
{filterDropdown == 'show' && - } + return
+ {filterDropdown == 'show' && + } +
+ case 'daterange': + return
+ {filterDropdown == 'show' && + }
case 'bool': - return
+ return
+ {filterDropdown == 'show' && diff --git a/src/TableHeader.js b/src/TableHeader.js index dc10695..daa2254 100644 --- a/src/TableHeader.js +++ b/src/TableHeader.js @@ -417,6 +417,24 @@ class TableHeader extends Component { filterDropdownType={rows[1][index]["filterdropdowntype"]}//下拉的条件类型为string,number /> ); + //日期范围 + case "daterange": + return ( + {}} + format={rows[1][index]["format"] || "YYYY-MM-DD"} + onChange={this.handlerFilterTextChange.bind(this, dataIndex)} + onSelectDropdown={this.handlerFilterDropChange.bind( + this, + dataIndex + )} + filterDropdown={rows[1][index]["filterdropdown"]} + filterDropdownType={rows[1][index]["filterdropdowntype"]}//下拉的条件类型为string,number + /> + ); default: //不匹配类型默认文本输入 return
;