feat: 条件过滤,输入框输入即查询[#605]

This commit is contained in:
yangchch6 2020-07-17 14:37:35 +08:00
parent a0565cc3b1
commit 2a06e5fa8f
8 changed files with 88 additions and 77 deletions

View File

@ -83,15 +83,21 @@ var FilterType = function (_Component) {
}; };
_this.changeText = function (val) { _this.changeText = function (val) {
var _this$props2 = _this.props,
onFilterChange = _this$props2.onFilterChange,
dataIndex = _this$props2.dataIndex;
_this.setState({ _this.setState({
value: val value: val
}, function () {
onFilterChange(dataIndex, val, _this.state.condition);
}); });
}; };
_this.changeTextCall = function (e) { _this.changeTextCall = function (e) {
var _this$props2 = _this.props, var _this$props3 = _this.props,
onFilterChange = _this$props2.onFilterChange, onFilterChange = _this$props3.onFilterChange,
dataIndex = _this$props2.dataIndex; dataIndex = _this$props3.dataIndex;
if (e.keyCode == 13) { if (e.keyCode == 13) {
e.target.value !== "" && onFilterChange(dataIndex, e.target.value, _this.state.condition); e.target.value !== "" && onFilterChange(dataIndex, e.target.value, _this.state.condition);
@ -105,9 +111,9 @@ var FilterType = function (_Component) {
}; };
_this.onSelectDropdown = function (item) { _this.onSelectDropdown = function (item) {
var _this$props3 = _this.props, var _this$props4 = _this.props,
onFilterChange = _this$props3.onFilterChange, onFilterChange = _this$props4.onFilterChange,
dataIndex = _this$props3.dataIndex; dataIndex = _this$props4.dataIndex;
_this.setState({ _this.setState({
condition: item.key condition: item.key
@ -117,9 +123,9 @@ var FilterType = function (_Component) {
}; };
_this.changeNumber = function (value) { _this.changeNumber = function (value) {
var _this$props4 = _this.props, var _this$props5 = _this.props,
onFilterChange = _this$props4.onFilterChange, onFilterChange = _this$props5.onFilterChange,
dataIndex = _this$props4.dataIndex; dataIndex = _this$props5.dataIndex;
_this.setState({ _this.setState({
value: value value: value
@ -144,9 +150,9 @@ var FilterType = function (_Component) {
}; };
_this.changeSelect = function (value) { _this.changeSelect = function (value) {
var _this$props5 = _this.props, var _this$props6 = _this.props,
onFilterChange = _this$props5.onFilterChange, onFilterChange = _this$props6.onFilterChange,
dataIndex = _this$props5.dataIndex; dataIndex = _this$props6.dataIndex;
if (onFilterChange) { if (onFilterChange) {
onFilterChange(dataIndex, value, _this.state.condition); onFilterChange(dataIndex, value, _this.state.condition);
@ -173,9 +179,9 @@ var FilterType = function (_Component) {
}; };
_this.changeDate = function (value) { _this.changeDate = function (value) {
var _this$props6 = _this.props, var _this$props7 = _this.props,
onFilterChange = _this$props6.onFilterChange, onFilterChange = _this$props7.onFilterChange,
dataIndex = _this$props6.dataIndex; dataIndex = _this$props7.dataIndex;
if (onFilterChange) { if (onFilterChange) {
onFilterChange(dataIndex, value, _this.state.condition); onFilterChange(dataIndex, value, _this.state.condition);
@ -187,18 +193,18 @@ var FilterType = function (_Component) {
}; };
_this.renderControl = function (rendertype) { _this.renderControl = function (rendertype) {
var _this$props7 = _this.props, var _this$props8 = _this.props,
filterInputNumberOptions = _this$props7.filterInputNumberOptions, filterInputNumberOptions = _this$props8.filterInputNumberOptions,
filterDropdownIncludeKeys = _this$props7.filterDropdownIncludeKeys, filterDropdownIncludeKeys = _this$props8.filterDropdownIncludeKeys,
dataIndex = _this$props7.dataIndex, dataIndex = _this$props8.dataIndex,
filterDropdown = _this$props7.filterDropdown, filterDropdown = _this$props8.filterDropdown,
filterDropdownType = _this$props7.filterDropdownType, filterDropdownType = _this$props8.filterDropdownType,
format = _this$props7.format, format = _this$props8.format,
className = _this$props7.className, className = _this$props8.className,
onChange = _this$props7.onChange, onChange = _this$props8.onChange,
onSelectDropdown = _this$props7.onSelectDropdown, onSelectDropdown = _this$props8.onSelectDropdown,
clsPrefix = _this$props7.clsPrefix, clsPrefix = _this$props8.clsPrefix,
locale = _this$props7.locale; locale = _this$props8.locale;
switch (rendertype) { switch (rendertype) {
case 'text': case 'text':

View File

@ -880,7 +880,7 @@ var _initialiseProps = function _initialiseProps() {
, clsPrefix: clsPrefix //css前缀 , clsPrefix: clsPrefix //css前缀
, className: clsPrefix + " filter-text", , className: clsPrefix + " filter-text",
dataIndex: dataIndex //字段 dataIndex: dataIndex //字段
, onFilterChange: _this8.handlerFilterChange //输入框回调 , onFilterChange: (0, _throttleDebounce.debounce)(filterDelay || 300, _this8.handlerFilterChange) //输入框回调
, onFilterClear: _this8.handlerFilterClear //清除回调 , onFilterClear: _this8.handlerFilterClear //清除回调
, filterDropdown: rows[1][index]["filterdropdown"] //是否显示下拉条件 , filterDropdown: rows[1][index]["filterdropdown"] //是否显示下拉条件
, filterDropdownType: rows[1][index]["filterdropdowntype"] //下拉的条件类型为string,number , filterDropdownType: rows[1][index]["filterdropdowntype"] //下拉的条件类型为string,number

View File

@ -6,8 +6,6 @@
* demo1001 * demo1001
*/ */
import React, { Component } from 'react'; import React, { Component } from 'react';
import {Icon} from "tinper-bee";
import Table from '../../src'; import Table from '../../src';
import dragColumn from '../../src/lib/dragColumn'; import dragColumn from '../../src/lib/dragColumn';
@ -55,11 +53,11 @@ const data = [
const DragColumnTable = dragColumn(Table); const DragColumnTable = dragColumn(Table);
const defaultProps22 = { const defaultProps29 = {
prefixCls: "bee-table" prefixCls: "bee-table"
}; };
class Demo22 extends Component { class Demo29 extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -88,5 +86,5 @@ class Demo22 extends Component {
} }
} }
Demo22.defaultProps = defaultProps22; Demo29.defaultProps = defaultProps29;
export default Demo22; export default Demo29;

File diff suppressed because one or more lines are too long

84
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -49,8 +49,11 @@ class FilterType extends Component {
* *
*/ */
changeText = (val) => { changeText = (val) => {
let { onFilterChange, dataIndex } = this.props;
this.setState({ this.setState({
value: val value: val
}, () => {
onFilterChange(dataIndex, val, this.state.condition);
}); });
} }

View File

@ -657,7 +657,7 @@ class TableHeader extends Component {
clsPrefix={clsPrefix}//css前缀 clsPrefix={clsPrefix}//css前缀
className={`${clsPrefix} filter-text`} className={`${clsPrefix} filter-text`}
dataIndex={dataIndex}//字段 dataIndex={dataIndex}//字段
onFilterChange={this.handlerFilterChange}//输入框回调 onFilterChange={debounce(filterDelay || 300, this.handlerFilterChange)}//输入框回调
onFilterClear={this.handlerFilterClear}//清除回调 onFilterClear={this.handlerFilterClear}//清除回调
filterDropdown={rows[1][index]["filterdropdown"]}//是否显示下拉条件 filterDropdown={rows[1][index]["filterdropdown"]}//是否显示下拉条件
filterDropdownType={rows[1][index]["filterdropdowntype"]}//下拉的条件类型为string,number filterDropdownType={rows[1][index]["filterdropdowntype"]}//下拉的条件类型为string,number