lib/SelectRender.js
function renderSelect(Select, Icon) {
    var _class, _temp2;

    return _temp2 = _class = function (_Component) {
        _inherits(SelectRender, _Component);

        function SelectRender() {
            var _temp, _this, _ret;

            _classCallCheck(this, SelectRender);

            for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
                args[_key] = arguments[_key];
            }

            return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = {
                value: _this.props.value,
                editable: false
            }, _this.handleChange = function (e) {
                var value = e;
                if (_this.props.onChange) {
                    _this.props.onChange(value);
                }
                _this.setState({ value: value });
                setTimeout(function () {
                    _this.setState({ editable: false });
                }, 0);
            }, _this.check = function () {
                _this.setState({ editable: false });
                if (_this.props.onChange) {
                    _this.props.onChange(_this.state.value);
                }
            }, _this.edit = function () {
                _this.setState({ editable: true });
            }, _temp), _possibleConstructorReturn(_this, _ret);
        }

        SelectRender.prototype.render = function render() {
            var _this2 = this;

            var _state = this.state,
                value = _state.value,
                editable = _state.editable;
            var _props = this.props,
                isclickTrigger = _props.isclickTrigger,
                dataSource = _props.dataSource;

            var cellContent = "";
            if (editable) {
                cellContent = isclickTrigger ? _react2["default"].createElement(
                    "div",
                    { className: "editable-cell-input-wrapper" },
                    _react2["default"].createElement(
                        Select,
                        _extends({}, this.props, {
                            value: this.state.value,
                            onBlur: function onBlur(value) {
                                console.log(value);
                                // this.props.onBlur();
                            },

                            onFocus: function onFocus(value) {
                                console.log(value);
                                // this.props.onBlur();
                            },

                            onChange: this.handleChange
                        }),
                        this.props.children
                    ),
                    _react2["default"].createElement(Icon, {
                        type: "uf-correct",
                        className: "editable-cell-icon-check",
                        onClick: this.check
                    })
                ) : _react2["default"].createElement(
                    "div",
                    { className: "editable-cell-input-wrapper" },
                    _react2["default"].createElement(
                        Select,
                        _extends({}, this.props, {
                            value: this.state.value,
                            onBlur: function onBlur() {
                                _this2.setState({
                                    editable: true
                                });
                                _this2.props.onBlur();
                            },
                            onChange: this.handleChange
                        }),
                        this.props.children
                    ),
                    _react2["default"].createElement(Icon, {
                        type: "uf-correct",
                        className: "editable-cell-icon-check",
                        onClick: this.check
                    })
                );
            } else {
                if (dataSource && dataSource.length > 0) {
                    for (var index = 0; index < dataSource.length; index++) {
                        var element = dataSource[index];
                        if (element.value === value) {
                            value = element.key;
                            break;
                        }
                    }
                }
                cellContent = isclickTrigger ? _react2["default"].createElement(
                    "div",
                    { className: "editable-cell-text-wrapper", onClick: this.edit },
                    value || " "
                ) : _react2["default"].createElement(
                    "div",
                    { className: "editable-cell-text-wrapper" },
                    value || " ",
                    _react2["default"].createElement(Icon, {
                        type: "uf-pencil",
                        className: "editable-cell-icon",
                        onClick: this.edit
                    })
                );
            }
            return _react2["default"].createElement(
                "div",
                { className: "editable-cell" },
                cellContent
            );
        };

        return SelectRender;
    }(_react.Component), _class.propTypes = {
        dataSource: _propTypes2["default"].array
    }, _temp2;
}
function renderSelect(Select, Icon) {
    var _class, _temp2;

    return _temp2 = _class = function (_Component) {
        _inherits(SelectRender, _Component);

        function SelectRender() {
            var _temp, _this, _ret;

            _classCallCheck(this, SelectRender);

            for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
                args[_key] = arguments[_key];
            }

            return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = {
                value: _this.props.value,
                editable: false
            }, _this.handleChange = function (e) {
                var value = e;
                if (_this.props.onChange) {
                    _this.props.onChange(value);
                }
                _this.setState({ value: value });
                setTimeout(function () {
                    _this.setState({ editable: false });
                }, 0);
            }, _this.check = function () {
                _this.setState({ editable: false });
                if (_this.props.onChange) {
                    _this.props.onChange(_this.state.value);
                }
            }, _this.edit = function () {
                _this.setState({ editable: true });
            }, _temp), _possibleConstructorReturn(_this, _ret);
        }

        SelectRender.prototype.render = function render() {
            var _this2 = this;

            var _state = this.state,
                value = _state.value,
                editable = _state.editable;
            var _props = this.props,
                isclickTrigger = _props.isclickTrigger,
                dataSource = _props.dataSource;

            var cellContent = "";
            if (editable) {
                cellContent = isclickTrigger ? _react2["default"].createElement(
                    "div",
                    { className: "editable-cell-input-wrapper" },
                    _react2["default"].createElement(
                        Select,
                        _extends({}, this.props, {
                            value: this.state.value,
                            onBlur: function onBlur(value) {
                                console.log(value);
                                // this.props.onBlur();
                            },

                            onFocus: function onFocus(value) {
                                console.log(value);
                                // this.props.onBlur();
                            },

                            onChange: this.handleChange
                        }),
                        this.props.children
                    ),
                    _react2["default"].createElement(Icon, {
                        type: "uf-correct",
                        className: "editable-cell-icon-check",
                        onClick: this.check
                    })
                ) : _react2["default"].createElement(
                    "div",
                    { className: "editable-cell-input-wrapper" },
                    _react2["default"].createElement(
                        Select,
                        _extends({}, this.props, {
                            value: this.state.value,
                            onBlur: function onBlur() {
                                _this2.setState({
                                    editable: true
                                });
                                _this2.props.onBlur();
                            },
                            onChange: this.handleChange
                        }),
                        this.props.children
                    ),
                    _react2["default"].createElement(Icon, {
                        type: "uf-correct",
                        className: "editable-cell-icon-check",
                        onClick: this.check
                    })
                );
            } else {
                if (dataSource && dataSource.length > 0) {
                    for (var index = 0; index < dataSource.length; index++) {
                        var element = dataSource[index];
                        if (element.value === value) {
                            value = element.key;
                            break;
                        }
                    }
                }
                cellContent = isclickTrigger ? _react2["default"].createElement(
                    "div",
                    { className: "editable-cell-text-wrapper", onClick: this.edit },
                    value || " "
                ) : _react2["default"].createElement(
                    "div",
                    { className: "editable-cell-text-wrapper" },
                    value || " ",
                    _react2["default"].createElement(Icon, {
                        type: "uf-pencil",
                        className: "editable-cell-icon",
                        onClick: this.edit
                    })
                );
            }
            return _react2["default"].createElement(
                "div",
                { className: "editable-cell" },
                cellContent
            );
        };

        return SelectRender;
    }(_react.Component), _class.propTypes = {
        dataSource: _propTypes2["default"].array
    }, _temp2;
}
function renderSelect ( Select , Icon ) { var _class , _temp2 ; return _temp2 = _class = function ( _Component ) { _inherits ( SelectRender , _Component ) ; function SelectRender ( ) { var _temp , _this , _ret ; _classCallCheck ( this , SelectRender ) ; for ( var _len = arguments . length , args = Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) { args [ _key ] = arguments [ _key ] ; } return _ret = ( _temp = ( _this = _possibleConstructorReturn ( this , _Component . call . apply ( _Component , [ this ] . concat ( args ) ) ) , _this ) , _this . state = { value : _this . props . value , editable : false } , _this . handleChange = function ( e ) { var value = e ; if ( _this . props . onChange ) { _this . props . onChange ( value ) ; } _this . setState ( { value : value } ) ; setTimeout ( function ( ) { _this . setState ( { editable : false } ) ; } , 0 ) ; } , _this . check = function ( ) { _this . setState ( { editable : false } ) ; if ( _this . props . onChange ) { _this . props . onChange ( _this . state . value ) ; } } , _this . edit = function ( ) { _this . setState ( { editable : true } ) ; } , _temp ) , _possibleConstructorReturn ( _this , _ret ) ; } SelectRender . prototype . render = function render ( ) { var _this2 = this ; var _state = this . state , value = _state . value , editable = _state . editable ; var _props = this . props , isclickTrigger = _props . isclickTrigger , dataSource = _props . dataSource ; var cellContent = "" ; if ( editable ) { cellContent = isclickTrigger ? _react2 [ "default" ] . createElement ( "div" , { className : "editable-cell-input-wrapper" } , _react2 [ "default" ] . createElement ( Select , _extends ( { } , this . props , { value : this . state . value , onBlur : function onBlur ( value ) { console . log ( value ) ; // this.props.onBlur(); } , onFocus : function onFocus ( value ) { console . log ( value ) ; // this.props.onBlur(); } , onChange : this . handleChange } ) , this . props . children ) , _react2 [ "default" ] . createElement ( Icon , { type : "uf-correct" , className : "editable-cell-icon-check" , onClick : this . check } ) ) : _react2 [ "default" ] . createElement ( "div" , { className : "editable-cell-input-wrapper" } , _react2 [ "default" ] . createElement ( Select , _extends ( { } , this . props , { value : this . state . value , onBlur : function onBlur ( ) { _this2 . setState ( { editable : true } ) ; _this2 . props . onBlur ( ) ; } , onChange : this . handleChange } ) , this . props . children ) , _react2 [ "default" ] . createElement ( Icon , { type : "uf-correct" , className : "editable-cell-icon-check" , onClick : this . check } ) ) ; } else { if ( dataSource && dataSource . length > 0 ) { for ( var index = 0 ; index < dataSource . length ; index ++ ) { var element = dataSource [ index ] ; if ( element . value === value ) { value = element . key ; break ; } } } cellContent = isclickTrigger ? _react2 [ "default" ] . createElement ( "div" , { className : "editable-cell-text-wrapper" , onClick : this . edit } , value || " " ) : _react2 [ "default" ] . createElement ( "div" , { className : "editable-cell-text-wrapper" } , value || " " , _react2 [ "default" ] . createElement ( Icon , { type : "uf-pencil" , className : "editable-cell-icon" , onClick : this . edit } ) ) ; } return _react2 [ "default" ] . createElement ( "div" , { className : "editable-cell" } , cellContent ) ; } ; return SelectRender ; } ( _react . Component ) , _class . propTypes = { dataSource : _propTypes2 [ "default" ] . array } , _temp2 ; }
渲染下拉框
@param Select
@param Icon
@returns {SelectRender}
渲染下拉框