2018-09-27 15:24:29 +08:00
'use strict' ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
var _react = require ( 'react' ) ;
var _react2 = _interopRequireDefault ( _react ) ;
2018-11-26 20:42:18 +08:00
var _propTypes = require ( 'prop-types' ) ;
var _propTypes2 = _interopRequireDefault ( _propTypes ) ;
2018-09-27 15:24:29 +08:00
var _beeDropdown = require ( 'bee-dropdown' ) ;
var _beeDropdown2 = _interopRequireDefault ( _beeDropdown ) ;
var _beeMenus = require ( 'bee-menus' ) ;
var _beeMenus2 = _interopRequireDefault ( _beeMenus ) ;
var _beeButton = require ( 'bee-button' ) ;
var _beeButton2 = _interopRequireDefault ( _beeButton ) ;
var _beeIcon = require ( 'bee-icon' ) ;
var _beeIcon2 = _interopRequireDefault ( _beeIcon ) ;
2018-11-01 14:35:46 +08:00
var _i18n = require ( './i18n' ) ;
var _i18n2 = _interopRequireDefault ( _i18n ) ;
var _tool = require ( 'bee-locale/build/tool' ) ;
2018-09-27 15:24:29 +08:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { "default" : obj } ; }
function _defaults ( obj , defaults ) { var keys = Object . getOwnPropertyNames ( defaults ) ; for ( var i = 0 ; i < keys . length ; i ++ ) { var key = keys [ i ] ; var value = Object . getOwnPropertyDescriptor ( defaults , key ) ; if ( value && value . configurable && obj [ key ] === undefined ) { Object . defineProperty ( obj , key , value ) ; } } return obj ; }
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
function _possibleConstructorReturn ( self , call ) { if ( ! self ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return call && ( typeof call === "object" || typeof call === "function" ) ? call : self ; }
2018-11-26 20:42:18 +08:00
function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : _defaults ( subClass , superClass ) ; } / * *
* 过滤行功能内的下拉条件
* /
2018-09-27 15:24:29 +08:00
var Item = _beeMenus2 [ "default" ] . Item ;
var FilterDropDown = function ( _Component ) {
_inherits ( FilterDropDown , _Component ) ;
function FilterDropDown ( ) {
_classCallCheck ( this , FilterDropDown ) ;
var _this = _possibleConstructorReturn ( this , _Component . call ( this ) ) ;
2018-11-29 23:29:26 +08:00
_this . onSelectDropdown = function ( item ) {
var _this$props = _this . props ,
onSelectDropdown = _this$props . onSelectDropdown ,
dataText = _this$props . dataText ;
2018-09-27 15:24:29 +08:00
if ( onSelectDropdown ) {
2018-11-29 23:29:26 +08:00
if ( dataText != "" ) {
_this . setState ( {
selectValue : [ item . key ]
} , function ( ) {
onSelectDropdown ( item ) ;
} ) ;
}
2018-09-27 15:24:29 +08:00
}
} ;
_this . onClickClear = function ( ) {
var onClickClear = _this . props . onClickClear ;
if ( onClickClear ) {
_this . setState ( {
selectValue : [ ]
} , function ( ) {
onClickClear ( ) ;
} ) ;
}
} ;
2018-11-26 20:42:18 +08:00
_this . getMenu = function ( ) {
var selectValue = _this . state . selectValue ;
var filterDropdownType = _this . props . filterDropdownType ;
var locale = ( 0 , _tool . getComponentLocale ) ( _this . props , _this . context , 'Table' , function ( ) {
return _i18n2 [ "default" ] ;
} ) ;
switch ( filterDropdownType ) {
case 'string' :
return _react2 [ "default" ] . createElement (
_beeMenus2 [ "default" ] ,
{
onSelect : _this . onSelectDropdown ,
selectedKeys : selectValue
} ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'LIKE' } ,
2018-11-26 20:42:18 +08:00
locale [ 'include' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'ULIKE' } ,
2018-11-26 20:42:18 +08:00
locale [ 'exclusive' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'EQ' } ,
2018-11-26 20:42:18 +08:00
locale [ 'equal' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'UEQ' } ,
2018-11-26 20:42:18 +08:00
locale [ 'unequal' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'START' } ,
2018-11-26 20:42:18 +08:00
locale [ 'begin' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'END' } ,
2018-11-26 20:42:18 +08:00
locale [ 'end' ]
)
) ;
case 'number' :
return _react2 [ "default" ] . createElement (
_beeMenus2 [ "default" ] ,
{
onSelect : _this . onSelectDropdown ,
selectedKeys : selectValue
} ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'GT' } ,
2018-11-26 20:42:18 +08:00
locale [ 'greater_than' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'GTEQ' } ,
2018-11-26 20:42:18 +08:00
locale [ 'great_than_equal_to' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'LT' } ,
2018-11-26 20:42:18 +08:00
locale [ 'less_than' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'LTEQ' } ,
2018-11-26 20:42:18 +08:00
locale [ 'less_than_equal_to' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'EQ' } ,
2018-11-26 20:42:18 +08:00
locale [ 'be_equal_to' ]
) ,
_react2 [ "default" ] . createElement (
Item ,
2018-11-29 23:29:26 +08:00
{ key : 'UEQ' } ,
2018-11-26 20:42:18 +08:00
locale [ 'not_equal_to' ]
)
) ;
default :
return _react2 [ "default" ] . createElement ( 'div' , null ) ;
}
} ;
2018-09-27 15:24:29 +08:00
_this . state = {
2018-11-26 20:42:18 +08:00
selectValue : [ ] //选择的条件的值
2018-09-27 15:24:29 +08:00
} ;
return _this ;
}
2018-11-26 20:42:18 +08:00
/ * *
* 点击下拉菜单
*
* @ param { * } s 选中的selectRecord
* /
/ * *
* 清除事件
*
* /
/ * *
* 根据props来获得指定的Menu , 分为String和Number
*
* @ returns JSX Menu
* /
2018-09-27 15:24:29 +08:00
FilterDropDown . prototype . render = function render ( ) {
var isShowCondition = this . props . isShowCondition ;
2018-11-01 14:35:46 +08:00
2018-09-27 15:24:29 +08:00
return _react2 [ "default" ] . createElement (
'div' ,
2018-11-13 14:36:12 +08:00
{ className : 'filter-btns' } ,
2018-09-27 15:24:29 +08:00
isShowCondition == 'show' && _react2 [ "default" ] . createElement (
_beeDropdown2 [ "default" ] ,
{
2018-11-29 23:29:26 +08:00
overlayClassName : 'u-filter-dropdown-menu-wrap' ,
2018-09-27 15:24:29 +08:00
trigger : [ 'click' ] ,
2018-11-26 20:42:18 +08:00
overlay : this . getMenu ( ) ,
2018-09-27 15:24:29 +08:00
animation : 'slide-up'
} ,
_react2 [ "default" ] . createElement (
_beeButton2 [ "default" ] ,
2018-11-26 20:42:18 +08:00
{
shape : 'border' ,
style : { marginLeft : "3px" , minWidth : "0px" , width : "24px" , padding : 0 }
} ,
_react2 [ "default" ] . createElement ( _beeIcon2 [ "default" ] , { style : { padding : 0 , color : '#585858' } , type : 'uf-filter' } )
2018-09-27 15:24:29 +08:00
)
) ,
_react2 [ "default" ] . createElement (
_beeButton2 [ "default" ] ,
2018-11-26 20:42:18 +08:00
{
onClick : this . onClickClear ,
shape : 'border' ,
style : { marginLeft : "1px" , minWidth : "0px" , width : "24px" , padding : 0 , "visibility" : this . props . isShowClear || this . state . selectValue . length > 0 ? "visible" : "hidden" }
} ,
_react2 [ "default" ] . createElement ( _beeIcon2 [ "default" ] , { style : { padding : 0 , color : '#585858' , "visibility" : this . props . isShowClear || this . state . selectValue . length > 0 ? "visible" : "hidden" } , type : 'uf-filterno' } )
2018-09-27 15:24:29 +08:00
)
) ;
} ;
return FilterDropDown ;
} ( _react . Component ) ;
2018-11-26 20:42:18 +08:00
FilterDropDown . propTypes = {
isShowCondition : _propTypes2 [ "default" ] . string ,
filterDropdownType : _propTypes2 [ "default" ] . oneOf ( [ 'string' , 'number' ] )
} ;
FilterDropDown . defaultProps = {
isShowCondition : 'show' ,
filterDropdownType : 'string'
} ;
2018-09-27 15:24:29 +08:00
exports [ "default" ] = FilterDropDown ;
module . exports = exports [ 'default' ] ;