knk-react
Version:
react components based on react
96 lines (87 loc) • 3.17 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
/**
* 关键字搜索
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Select, Input, Row, Col } from 'antd';
var Option = Select.Option;
var style = {
width: '97%'
};
var SelectKeyWord = /*#__PURE__*/function (_Component) {
_inherits(SelectKeyWord, _Component);
var _super = _createSuper(SelectKeyWord);
function SelectKeyWord(props) {
var _this;
_classCallCheck(this, SelectKeyWord);
_this = _super.call(this, props);
_this.handleChangeKeyWord = _this.handleChangeKeyWord.bind(_assertThisInitialized(_this));
_this.handleInput = _this.handleInput.bind(_assertThisInitialized(_this));
return _this;
}
_createClass(SelectKeyWord, [{
key: "render",
value: function render() {
var _this$props = this.props,
keyWord = _this$props.keyWord,
value = _this$props.value,
isDefaultOption = _this$props.isDefaultOption,
defaultval = _this$props.defaultval,
defaultStr = _this$props.defaultStr;
return /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, {
span: 11
}, /*#__PURE__*/React.createElement(Select, {
allowClear: true,
placeholder: "\u8BF7\u9009\u62E9",
style: style,
value: value && value[0] ? value[0] : [],
onChange: this.handleChangeKeyWord
}, isDefaultOption ? null : /*#__PURE__*/React.createElement(Option, {
value: defaultval || ''
}, defaultStr || '请选择'), keyWord.map(function (item) {
return /*#__PURE__*/React.createElement(Option, {
key: item.value,
value: item.value
}, item.text);
}))), /*#__PURE__*/React.createElement(Col, {
span: 13
}, /*#__PURE__*/React.createElement(Input, {
style: style,
value: value && value[1] ? value[1] : '',
onChange: this.handleInput,
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD"
})));
}
}, {
key: "handleChangeKeyWord",
value: function handleChangeKeyWord(data) {
var _this$props2 = this.props,
onChange = _this$props2.onChange,
value = _this$props2.value;
onChange([data, value && value[1] ? value[1] : '']);
}
}, {
key: "handleInput",
value: function handleInput(e) {
var _this$props3 = this.props,
value = _this$props3.value,
onChange = _this$props3.onChange;
onChange([value[0], e.target.value]);
}
}]);
return SelectKeyWord;
}(Component);
SelectKeyWord.propTypes = {
keyWord: PropTypes.array.isRequired,
onChange: PropTypes.func,
value: PropTypes.array,
isDefaultOption: PropTypes.bool,
defaultStr: PropTypes.string,
defaultval: PropTypes.string
};
export default SelectKeyWord;