1 | import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
2 | import _createClass from "@babel/runtime/helpers/createClass";
|
3 | import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
4 | import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
5 | import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
6 | import _inherits from "@babel/runtime/helpers/inherits";
|
7 | import React, { Component } from 'react';
|
8 | import debounce from '@beisen/es6-promise-debounce';
|
9 | import CommonInput from '@beisen-platform/common-input';
|
10 | import EditFilters from './edit_Filters.js';
|
11 | import { decode, judgeBrowser } from '@beisen-platform/common-func';
|
12 | import CloseIcon from '@beisen-platform/react-icons/lib/icons/Close.js';
|
13 |
|
14 | var AutoForm_Input =
|
15 |
|
16 | function (_Component) {
|
17 | _inherits(AutoForm_Input, _Component);
|
18 |
|
19 | function AutoForm_Input(props) {
|
20 | var _this;
|
21 |
|
22 | _classCallCheck(this, AutoForm_Input);
|
23 |
|
24 | _this = _possibleConstructorReturn(this, _getPrototypeOf(AutoForm_Input).call(this, props));
|
25 |
|
26 | _this.resizeInputWidth = function () {
|
27 | var inputNode = _this.refs.autoFormInput;
|
28 |
|
29 | if (inputNode != undefined && inputNode.clientWidth != 0) {
|
30 | inputNode.clientWidth <= 270 ? _this.setState({
|
31 | isMinWidth: true
|
32 | }) : _this.setState({
|
33 | isMinWidth: false
|
34 | });
|
35 | }
|
36 | };
|
37 |
|
38 | _this.onMouseTip = function () {
|
39 | var self = _assertThisInitialized(_this);
|
40 |
|
41 |
|
42 | setTimeout(function () {
|
43 | self.setState({
|
44 | mouseTips: true
|
45 | });
|
46 | }, 100);
|
47 | };
|
48 |
|
49 | _this.tipsClick = function () {
|
50 | _this.setState({
|
51 | pointerEvent: "none",
|
52 | showHiddenTips: 'none'
|
53 | });
|
54 |
|
55 | _this.refs.autoTreeInput.focus();
|
56 | };
|
57 |
|
58 | _this.handlerOver = function () {
|
59 | _this.props.handlerOver();
|
60 | };
|
61 |
|
62 | _this.handlerOut = function (e) {
|
63 | _this.setState({
|
64 | mouseTips: false,
|
65 | hoverFocusing: false
|
66 | });
|
67 |
|
68 | clearToolTipDom();
|
69 |
|
70 | _this.props.handlerOut(e);
|
71 | };
|
72 |
|
73 | _this.state = {
|
74 | isMinWidth: false,
|
75 | pointerEvent: "auto",
|
76 | showHiddenTips: 'block',
|
77 | mouseTips: false
|
78 | };
|
79 | return _this;
|
80 | }
|
81 |
|
82 | _createClass(AutoForm_Input, [{
|
83 | key: "componentDidMount",
|
84 | value: function componentDidMount() {
|
85 | var _this$props = this.props,
|
86 | status = _this$props.status,
|
87 | showDropDown = _this$props.showDropDown;
|
88 | var self = this;
|
89 |
|
90 | if (status == 'edit' && showDropDown == true) {
|
91 | this.resizeInputWidth();
|
92 | window.addEventListener('resize', debounce(function () {
|
93 | self.resizeInputWidth();
|
94 | }, 200), false);
|
95 | }
|
96 | }
|
97 | }, {
|
98 | key: "componentWillReceiveProps",
|
99 | value: function componentWillReceiveProps(nextProps) {
|
100 | var _this$props2 = this.props,
|
101 | commmonInput_Data = _this$props2.commmonInput_Data,
|
102 | single = _this$props2.single,
|
103 | defaultValue = _this$props2.defaultValue,
|
104 | inputValue = _this$props2.inputValue,
|
105 | disabled = _this$props2.disabled;
|
106 |
|
107 | if (defaultValue != nextProps.defaultValue && single && !disabled) {
|
108 | this.refs.autoTreeInput.value = decode(nextProps.defaultValue);
|
109 | }
|
110 |
|
111 | if (inputValue != nextProps.inputValue && single && !disabled) {
|
112 | this.refs.autoTreeInput.value = decode(nextProps.inputValue);
|
113 | }
|
114 |
|
115 | if (commmonInput_Data.selectDate && nextProps.selectDate) {
|
116 | var updateSelectData = commmonInput_Data.selectDate.length != nextProps.selectDate.length ? true : false;
|
117 | if (updateSelectData) this.setState({});
|
118 | }
|
119 |
|
120 | if (commmonInput_Data.isActive && nextProps.isActive && commmonInput_Data.isActive != nextProps.isActive) {
|
121 | this.setState({});
|
122 | }
|
123 | }
|
124 | }, {
|
125 | key: "render",
|
126 | value: function render() {
|
127 | var _this$props3 = this.props,
|
128 | disabled = _this$props3.disabled,
|
129 | status = _this$props3.status,
|
130 | isShowMouseOverIcon = _this$props3.isShowMouseOverIcon,
|
131 | showDropDown = _this$props3.showDropDown,
|
132 | DropDownData = _this$props3.DropDownData,
|
133 | placeholder = _this$props3.placeholder,
|
134 | inputValue = _this$props3.inputValue,
|
135 | defaultValue = _this$props3.defaultValue,
|
136 | isFocus = _this$props3.isFocus,
|
137 | errorStatus = _this$props3.errorStatus,
|
138 | errorMsg = _this$props3.errorMsg,
|
139 | single = _this$props3.single,
|
140 | showText = _this$props3.showText,
|
141 | commmonInput_Data = _this$props3.commmonInput_Data,
|
142 | isSearchAutoTreeEdit = _this$props3.isSearchAutoTreeEdit,
|
143 | readOnly = _this$props3.readOnly;
|
144 | var _this$state = this.state,
|
145 | isMinWidth = _this$state.isMinWidth,
|
146 | pointerEvent = _this$state.pointerEvent,
|
147 | showHiddenTips = _this$state.showHiddenTips,
|
148 | mouseTips = _this$state.mouseTips;
|
149 | var isMinClass, inutClassStyle, inputClass, isDisabled, inputStyle, autoInput_class, closeBtnClass, dropDownIcon, iconOrText, erroStyle, notDropDown, baseStyle;
|
150 | var _autoTreeLeft_Class = '';
|
151 | isMinClass = isMinWidth ? 'leftInput-showDropDown isMinWidth' : 'leftInput-showDropDown notMin';
|
152 | inutClassStyle = status == 'edit' ? showDropDown ? isMinWidth ? 'auto-form-input-active-showDropDownisMin ' : 'auto-form-input-active-showDropDown ' : 'auto-form-input-active-notShowDropDown ' : 'auto-form-input-active-seach ';
|
153 | inputClass = !errorStatus && isFocus && single ? inutClassStyle : '';
|
154 | closeBtnClass = status == 'search' ? 'icon-close date-time-close-search closeBtn-search' : showDropDown ? 'icon-close date-time-close closeBtn-edit-showDropDown' : 'icon-close date-time-close closeBtn-edit-notShowDropDown';
|
155 | if (status == 'search') erroStyle = {
|
156 | 'height': '45px'
|
157 | };
|
158 | if (!errorStatus) baseStyle = {
|
159 | 'height': '0px'
|
160 | };
|
161 | var showClose = inputValue.length > 0 && (isFocus == true || isShowMouseOverIcon) ? 'block' : 'none';
|
162 |
|
163 | if (disabled == false || disabled == undefined) {
|
164 | isDisabled = '';
|
165 | inputStyle = {
|
166 | 'paddingRight': '33px'
|
167 | };
|
168 | } else {
|
169 | isDisabled = 'disabled';
|
170 | inputStyle = {
|
171 | 'background': 'rgb(245, 248, 250)',
|
172 | 'border': '1px solid rgb(228, 235, 240)',
|
173 | 'borderRadius': '5px',
|
174 | 'fontFamily': 'PingFangSC-Regular',
|
175 | 'fontSize': '12px',
|
176 | 'color': '#3E4E59',
|
177 | 'letterSpacing': '0px',
|
178 | 'lineHeight': '20px',
|
179 | 'textAlign': 'left',
|
180 | 'cursor': 'no-drop'
|
181 | };
|
182 | }
|
183 |
|
184 | if (disabled) {
|
185 | dropDownIcon = '';
|
186 | } else {
|
187 | dropDownIcon = React.createElement("span", {
|
188 | className: showDropDown ? 'autoTreeIcon-showDropDown pc-sys-arrowdown-nomal-svg' : 'autoTreeIcon-notShowDropDown pc-sys-arrowdown-nomal-svg',
|
189 | onClick: this.props.editInput_focus
|
190 | });
|
191 | }
|
192 |
|
193 | if (status == 'edit') {
|
194 | iconOrText = dropDownIcon;
|
195 | autoInput_class = single ? 'auto-input-edit' : 'auto-input-edit_muit';
|
196 | _autoTreeLeft_Class = !single ? '' : 'autoTreeLeftInput-single ';
|
197 | notDropDown = isSearchAutoTreeEdit ? ' auto-tree__input_not-dropdown' : '';
|
198 | } else {
|
199 | autoInput_class = 'auto-input-search';
|
200 | iconOrText = React.createElement("div", {
|
201 | className: "findAll"
|
202 | }, React.createElement("label", {
|
203 | onClick: this.props.findAll
|
204 | }, "\u5168\u90E8\u67E5\u627E"));
|
205 | }
|
206 |
|
207 | var decodeValue = decode(defaultValue);
|
208 | console.log(decodeValue);
|
209 | return React.createElement("div", {
|
210 | ref: "autoFormInput",
|
211 | className: "field-right auto-rightinput auto-form-input " + inputClass + autoInput_class + notDropDown,
|
212 | style: erroStyle
|
213 | }, React.createElement("div", {
|
214 | ref: "leftInput",
|
215 | className: status == 'edit' ? showDropDown && !isSearchAutoTreeEdit ? isMinClass : 'leftInput-notShowDropDown' : ''
|
216 | }, single && status == 'edit' || status == 'search' ? isDisabled ? React.createElement(CommonInput, {
|
217 | readonly: true,
|
218 | errorStatus: errorStatus,
|
219 | errorMsg: errorMsg,
|
220 | defaultValue: decodeValue
|
221 | }) : React.createElement("div", {
|
222 | onMouseOver: this.handlerOver,
|
223 | onMouseOut: this.handlerOut
|
224 | }, mouseTips ? null : React.createElement(ToolTip, {
|
225 | title: inputValue
|
226 | }, React.createElement("div", {
|
227 | className: "form-item_is-hidden-tips",
|
228 | onMouseEnter: this.onMouseTip,
|
229 | style: {
|
230 | pointerEvents: pointerEvent,
|
231 | display: showHiddenTips
|
232 | },
|
233 | onClick: this.tipsClick
|
234 | }, inputValue)), React.createElement("input", {
|
235 | className: 'autoTreeLeftInput ' + _autoTreeLeft_Class + (status == 'edit' ? '' : 'autoTree-search-input'),
|
236 | type: "text",
|
237 | ref: "autoTreeInput",
|
238 | placeholder: disabled ? '' : placeholder,
|
239 | defaultValue: decodeValue,
|
240 | onClick: this.props.addClass,
|
241 | onBlur: this.props.removeClass,
|
242 | onChange: this.props.onChange,
|
243 | onFocus: this.props.addClass,
|
244 | disabled: isDisabled,
|
245 | readOnly: readOnly,
|
246 | style: inputStyle
|
247 | }), React.createElement("span", {
|
248 | style: {
|
249 | "display": showClose,
|
250 | "top": judgeBrowser().isIe10 ? '0' : 'none'
|
251 | },
|
252 | className: closeBtnClass,
|
253 | ref: "mouseIconClose",
|
254 | onClick: this.props.clearData
|
255 | }, React.createElement(CloseIcon, null)), iconOrText, status == 'edit' ? React.createElement("div", {
|
256 | className: "base-input-show",
|
257 | style: baseStyle
|
258 | }, React.createElement("span", {
|
259 | className: 'base-input-show-text ' + (isFocus ? 'input-pFoucus ' + (errorStatus ? 'input-pError ' : 'input-pRight ') : errorStatus ? 'input-pFoucus input-pError ' : 'input-pBlur input-pRight ')
|
260 | }, errorStatus ? errorMsg : showText)) : '') : React.createElement("div", {
|
261 | ref: "autoTree_commonInput",
|
262 | className: 'autoTreeLeftInput ' + (status == 'edit' ? '' : 'autoTree-search-input')
|
263 | }, React.createElement(CommonInput, commmonInput_Data))), !isSearchAutoTreeEdit ? React.createElement(EditFilters, {
|
264 | DropDownData: DropDownData,
|
265 | isMinWidth: isMinWidth,
|
266 | status: status,
|
267 | changeFilter: this.props.changeFilter,
|
268 | showDropDown: showDropDown
|
269 | }) : '');
|
270 | }
|
271 | }]);
|
272 |
|
273 | return AutoForm_Input;
|
274 | }(Component);
|
275 |
|
276 | export { AutoForm_Input as default }; |
\ | No newline at end of file |