"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"), _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")), _react = _interopRequireWildcard(require("react")), _propTypes = _interopRequireDefault(require("prop-types")), _amosAntd = require("amos-antd"), _moment = _interopRequireDefault(require("moment"));

function _createSuper(e) {
    var t = _isNativeReflectConstruct();
    return function() {
        var a, r = (0, _getPrototypeOf2.default)(e);
        if (t) {
            var i = (0, _getPrototypeOf2.default)(this).constructor;
            a = Reflect.construct(r, arguments, i);
        } else a = r.apply(this, arguments);
        return (0, _possibleConstructorReturn2.default)(this, a);
    };
}

function _isNativeReflectConstruct() {
    if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
    if (Reflect.construct.sham) return !1;
    if ("function" == typeof Proxy) return !0;
    try {
        return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))), 
        !0;
    } catch (e) {
        return !1;
    }
}

var Option = _amosAntd.Select.Option, RadioButton = _amosAntd.Radio.Button, RadioGroup = _amosAntd.Radio.Group, PropsFilter = function(e) {
    (0, _inherits2.default)(a, e);
    var t = _createSuper(a);
    function a(e) {
        var r;
        return (0, _classCallCheck2.default)(this, a), r = t.call(this, e), (0, _defineProperty2.default)((0, 
        _assertThisInitialized2.default)(r), "dateChange", (function(e) {
            r.props.changeFilters(r.props.dataIndex, e);
        })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "selectTypeFilter", (function() {
            switch (r.props.st) {
              case "text":
                return r.textContent();

              case "list":
                return r.listContent();

              case "date":
                return r.dateContent();

              case "redio":
                return r.redioContent();
            }
        })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "textContent", (function() {
            return _react.default.createElement(_amosAntd.Input, {
                id: "filterValue",
                value: r.state.textValue,
                className: "amos-filter-text",
                onChange: r.textChange,
                name: "filterValue"
            });
        })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "dateContent", (function() {
            return _react.default.createElement(_amosAntd.DatePicker, {
                className: "amos-filter-date",
                format: "YYYY-MM-DD HH:mm:ss",
                showTime: {
                    defaultValue: (0, _moment.default)("00:00:00", "HH:mm:ss")
                },
                onChange: r.dateChange,
                name: "filterValue",
                id: "filterValue"
            });
        })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "listContent", (function() {
            var e = r.props.list, t = r.state.listValue;
            return _react.default.createElement(_amosAntd.Select, {
                allowClear: !0,
                showSearch: !0,
                optionFilterProp: "children",
                onChange: r.selectChange,
                value: t,
                className: "amos-filter-list",
                dropdownStyle: {
                    maxHeight: "110px",
                    overflow: "overlay"
                }
            }, _react.default.createElement(Option, {
                key: "all",
                value: "全部"
            }, "全部"), e.map((function(e) {
                return _react.default.createElement(Option, {
                    key: e.value,
                    value: e.value
                }, e.name);
            })));
        })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "redioContent", (function() {
            var e = r.props.list;
            return _react.default.createElement(RadioGroup, {
                onChange: r.radioChange,
                defaultValue: "全部",
                className: "amos-filter-redio"
            }, _react.default.createElement(RadioButton, {
                value: "全部"
            }, "全部"), e.map((function(e) {
                return _react.default.createElement(RadioButton, {
                    key: e,
                    value: e
                }, e);
            })));
        })), r.state = {
            count: 1,
            filterValue: "",
            textValue: "",
            listValue: "全部"
        }, r.textChange = r.textChange.bind((0, _assertThisInitialized2.default)(r)), r.radioChange = r.radioChange.bind((0, 
        _assertThisInitialized2.default)(r)), r.selectChange = r.selectChange.bind((0, _assertThisInitialized2.default)(r)), 
        r;
    }
    return (0, _createClass2.default)(a, [ {
        key: "componentWillReceiveProps",
        value: function(e) {
            var t = e.st;
            if ("text" === t) {
                var a = e.defaultValue;
                1 === this.state.count && a && "" !== a && this.setState({
                    textValue: a,
                    count: 0
                });
            }
            if ("list" === t) {
                var r = e.defaultValue;
                1 === this.state.count && r && "" !== r && this.setState({
                    listValue: r,
                    count: 0
                });
            }
        }
    }, {
        key: "textChange",
        value: function(e) {
            this.setState({
                textValue: e.target.value
            }), this.props.changeFilters(this.props.dataIndex, e.target.value);
        }
    }, {
        key: "radioChange",
        value: function(e) {
            this.props.changeFilters(this.props.dataIndex, e.target.value);
        }
    }, {
        key: "selectChange",
        value: function(e) {
            this.setState({
                listValue: e
            }), this.props.changeFilters(this.props.dataIndex, e);
        }
    }, {
        key: "render",
        value: function() {
            var e = this.props.title;
            return _react.default.createElement("li", {
                className: "amos-table-filter-li"
            }, _react.default.createElement("span", {
                className: "amos-prop-filter"
            }, e), _react.default.createElement("span", {
                className: "amos-filter-value"
            }, this.selectTypeFilter()));
        }
    } ]), a;
}(_react.Component);

PropsFilter.displayName = "PropsFilter", PropsFilter.propTypes = {
    title: _propTypes.default.string,
    st: _propTypes.default.string,
    list: _propTypes.default.array,
    changeFilters: _propTypes.default.func,
    dataIndex: _propTypes.default.string
}, PropsFilter.defaultProps = {
    list: [],
    allFilter: []
};

var _default = PropsFilter;

exports.default = _default;