import React, { Component } from 'react'; import './index.less'; import { Icon } from 'antd'; import Assets from '@src/components/Assets'; import Select from '../Select'; import CheckboxItem from '../CheckboxItem'; import { Icon as GIcon } from '../Icon'; import { Button } from '../Button'; export default class UserAction extends Component { constructor(props) { super(props); this.state = { showInput: false, searchText: '' }; } onAction(key) { const { onAction } = this.props; if (onAction) onAction(key); } onAll(checked) { const { onAll } = this.props; if (onAll) onAll(checked); } onSearchKey(e) { if (e.keyCode === 13) { const { onSearch } = this.props; if (onSearch) onSearch(this.state.searchText); } } onSearch(value) { this.setState({ searchText: value, showInput: true }); } onFilter(key, value) { const { filterMap = {}, onFilter } = this.props; filterMap[key] = value; if (onFilter) onFilter(filterMap); } onSort(key, value) { const { onSort, sortMap = {} } = this.props; sortMap[key] = value; if (onSort) onSort(sortMap); } render() { const { allCheckbox, allChecked, defaultSearch, help, btnList = [], search, selectList = [], sortList = [], sortMap = [], right, left, } = this.props; const { showInput, searchText } = this.state; return (
{left &&
{left}
} {allCheckbox && (
this.onAll(value)} /> 全选
)} {search && (
{(showInput || defaultSearch) && ( this.onSearch(e.target.value)} onKeyUp={e => this.onSearchKey(e)} /> )} {!showInput && !defaultSearch && this.setState({ showInput: true })} />}
)} {right && (
{right}
)}
); } renderSelect(item) { const { filterMap = {} } = this.props; return (