@cqsjjb/jjb-react-admin-component 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ControlWrapper/index.d.ts +74 -0
- package/ControlWrapper/index.js +274 -0
- package/ControlWrapper/index.less +34 -0
- package/ControlWrapper/index.mjs +405 -0
- package/SearchForm/index.d.ts +40 -0
- package/SearchForm/index.js +88 -0
- package/SearchForm/index.less +0 -0
- package/SearchForm/index.mjs +121 -0
- package/package.json +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { Moment } from 'moment';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import { DefaultOptionType, FieldNamesType } from 'antd/es/cascader';
|
|
7
|
+
import { ComponentProps } from '../types';
|
|
8
|
+
|
|
9
|
+
interface BaseProps<T> extends ComponentProps {
|
|
10
|
+
// 输入内容
|
|
11
|
+
value?: T;
|
|
12
|
+
// 标签
|
|
13
|
+
label?: string;
|
|
14
|
+
// 标签宽度
|
|
15
|
+
labelSpan?: number;
|
|
16
|
+
// 内容清空
|
|
17
|
+
allowClear?: boolean;
|
|
18
|
+
// 占位符
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
// 输出事件
|
|
21
|
+
onChange?: (value: T) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface InputProps<T> extends BaseProps<T> {
|
|
25
|
+
// 文本长度
|
|
26
|
+
maxLength?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface SelectProps<T> extends BaseProps<T> {
|
|
30
|
+
// 设置 Select 的模式为多选或标签
|
|
31
|
+
mode?: 'multiple' | 'tags';
|
|
32
|
+
// 最多显示多少个tag
|
|
33
|
+
maxTagCount?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface CascaderProps<T> extends BaseProps<T> {
|
|
37
|
+
// 可选项数据源
|
|
38
|
+
options?: DefaultOptionType[];
|
|
39
|
+
// 支持多选节点
|
|
40
|
+
multiple?: boolean;
|
|
41
|
+
// 自定义 options 中 label value children 的字段
|
|
42
|
+
fieldNames?: FieldNamesType;
|
|
43
|
+
// 最多显示多少个tag
|
|
44
|
+
maxTagCount?: number;
|
|
45
|
+
// 定义选中项回填的方式
|
|
46
|
+
showCheckedStrategy?: 'SHOW_CHILD' | 'SHOW_PARENT';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface DatePickerProps<T> {
|
|
50
|
+
// 标签
|
|
51
|
+
label?: string;
|
|
52
|
+
// 输入
|
|
53
|
+
value?: T;
|
|
54
|
+
// 格式日期
|
|
55
|
+
format?: string;
|
|
56
|
+
// 输出事件
|
|
57
|
+
onChange?: (value: T) => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare const ControlWrapper: {
|
|
61
|
+
// 输入
|
|
62
|
+
Input: React.FC<InputProps<string | number>>;
|
|
63
|
+
// 选择
|
|
64
|
+
Select: React.FC<SelectProps<string | number>>;
|
|
65
|
+
// 级联选择
|
|
66
|
+
Cascader: React.FC<CascaderProps<string[] | number[]>>;
|
|
67
|
+
// 日期选择
|
|
68
|
+
DatePicker: React.FC<DatePickerProps<Moment>> & {
|
|
69
|
+
// 日期范围选择
|
|
70
|
+
RangePicker: React.FC<DatePickerProps<Moment[]>>
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default ControlWrapper;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Cascader as OriginCascader, Col, DatePicker as OriginDatePicker, Input as OriginInput, Row, Select as OriginSelect, TreeSelect as OriginTreeSelect } from 'antd';
|
|
4
|
+
import './index.less';
|
|
5
|
+
const prefixCls = process?.env?.app?.antd['ant-prefix'] || 'ant';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param classList {string[]}
|
|
9
|
+
* @return {string}
|
|
10
|
+
*/
|
|
11
|
+
function classnames(classList) {
|
|
12
|
+
return classList.filter(i => i).join(' ');
|
|
13
|
+
}
|
|
14
|
+
function algorithm() {
|
|
15
|
+
const value = document.documentElement.style.getPropertyValue('--saas-algorithm');
|
|
16
|
+
return value ? value === '#FFF' ? 'default' : 'dark' : 'default';
|
|
17
|
+
}
|
|
18
|
+
class Input extends React.Component {
|
|
19
|
+
get algorithm() {
|
|
20
|
+
return algorithm();
|
|
21
|
+
}
|
|
22
|
+
render() {
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
style: this.props.style,
|
|
25
|
+
className: classnames([`${prefixCls}-form-item-control-label-wrapper`, `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`, this.props.label && `${prefixCls}-form-item-control-label-has`])
|
|
26
|
+
}, /*#__PURE__*/React.createElement(Row, {
|
|
27
|
+
align: "middle",
|
|
28
|
+
wrap: false
|
|
29
|
+
}, this.props.label && /*#__PURE__*/React.createElement(Col, {
|
|
30
|
+
span: this.props.labelSpan,
|
|
31
|
+
className: `${prefixCls}-form-item-control-label-span`
|
|
32
|
+
}, this.props.label), /*#__PURE__*/React.createElement(Col, {
|
|
33
|
+
flex: 1
|
|
34
|
+
}, /*#__PURE__*/React.createElement(OriginInput, {
|
|
35
|
+
style: {
|
|
36
|
+
width: '100%',
|
|
37
|
+
borderLeft: 'none'
|
|
38
|
+
},
|
|
39
|
+
value: this.props.value,
|
|
40
|
+
maxLength: this.props.maxLength,
|
|
41
|
+
allowClear: this.props.allowClear,
|
|
42
|
+
placeholder: this.props.placeholder,
|
|
43
|
+
onChange: e => this.props.onChange(e.target.value || undefined)
|
|
44
|
+
}))));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
Input.propTypes = {
|
|
48
|
+
value: PropTypes.any,
|
|
49
|
+
label: PropTypes.string,
|
|
50
|
+
labelSpan: PropTypes.number,
|
|
51
|
+
maxLength: PropTypes.number,
|
|
52
|
+
allowClear: PropTypes.bool,
|
|
53
|
+
placeholder: PropTypes.string,
|
|
54
|
+
onChange: PropTypes.func
|
|
55
|
+
};
|
|
56
|
+
class Select extends React.Component {
|
|
57
|
+
get algorithm() {
|
|
58
|
+
return algorithm();
|
|
59
|
+
}
|
|
60
|
+
render() {
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
style: this.props.style,
|
|
63
|
+
className: classnames([`${prefixCls}-form-item-control-label-wrapper`, `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`, this.props.label && `${prefixCls}-form-item-control-label-has`])
|
|
64
|
+
}, /*#__PURE__*/React.createElement(Row, {
|
|
65
|
+
align: "middle",
|
|
66
|
+
wrap: false
|
|
67
|
+
}, this.props.label && /*#__PURE__*/React.createElement(Col, {
|
|
68
|
+
span: this.props.labelSpan,
|
|
69
|
+
className: `${prefixCls}-form-item-control-label-span`
|
|
70
|
+
}, this.props.label), /*#__PURE__*/React.createElement(Col, {
|
|
71
|
+
flex: 1
|
|
72
|
+
}, /*#__PURE__*/React.createElement(OriginSelect, {
|
|
73
|
+
mode: this.props.mode,
|
|
74
|
+
style: {
|
|
75
|
+
width: '100%',
|
|
76
|
+
borderLeft: 'none'
|
|
77
|
+
},
|
|
78
|
+
value: this.props.value,
|
|
79
|
+
allowClear: this.props.allowClear,
|
|
80
|
+
maxTagCount: this.props.maxTagCount || 3,
|
|
81
|
+
placeholder: this.props.placeholder,
|
|
82
|
+
onChange: value => this.props.onChange(value || undefined)
|
|
83
|
+
}, this.props.options ? this.props.options : this.props.children))));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
Select.propTypes = {
|
|
87
|
+
mode: PropTypes.string,
|
|
88
|
+
value: PropTypes.any,
|
|
89
|
+
label: PropTypes.string,
|
|
90
|
+
labelSpan: PropTypes.number,
|
|
91
|
+
allowClear: PropTypes.bool,
|
|
92
|
+
maxTagCount: PropTypes.number,
|
|
93
|
+
placeholder: PropTypes.string,
|
|
94
|
+
onChange: PropTypes.func
|
|
95
|
+
};
|
|
96
|
+
class Cascader extends React.Component {
|
|
97
|
+
get algorithm() {
|
|
98
|
+
return algorithm();
|
|
99
|
+
}
|
|
100
|
+
render() {
|
|
101
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
style: this.props.style,
|
|
103
|
+
className: classnames([`${prefixCls}-form-item-control-label-wrapper`, `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`, this.props.label && `${prefixCls}-form-item-control-label-has`])
|
|
104
|
+
}, /*#__PURE__*/React.createElement(Row, {
|
|
105
|
+
align: "middle",
|
|
106
|
+
wrap: false
|
|
107
|
+
}, this.props.label && /*#__PURE__*/React.createElement(Col, {
|
|
108
|
+
span: this.props.labelSpan,
|
|
109
|
+
className: `${prefixCls}-form-item-control-label-span`
|
|
110
|
+
}, this.props.label), /*#__PURE__*/React.createElement(Col, {
|
|
111
|
+
flex: 1
|
|
112
|
+
}, /*#__PURE__*/React.createElement(OriginCascader, {
|
|
113
|
+
style: {
|
|
114
|
+
width: '100%',
|
|
115
|
+
borderLeft: 'none'
|
|
116
|
+
},
|
|
117
|
+
value: this.props.value,
|
|
118
|
+
options: this.props.options,
|
|
119
|
+
multiple: this.props.multiple,
|
|
120
|
+
allowClear: this.props.allowClear,
|
|
121
|
+
fieldNames: this.props.fieldNames,
|
|
122
|
+
maxTagCount: this.props.maxTagCount || 3,
|
|
123
|
+
placeholder: this.props.placeholder,
|
|
124
|
+
showCheckedStrategy: this.props.showCheckedStrategy,
|
|
125
|
+
onChange: value => this.props.onChange(value || undefined)
|
|
126
|
+
}))));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
Cascader.propTypes = {
|
|
130
|
+
mode: PropTypes.string,
|
|
131
|
+
value: PropTypes.any,
|
|
132
|
+
label: PropTypes.string,
|
|
133
|
+
options: PropTypes.array,
|
|
134
|
+
multiple: PropTypes.bool,
|
|
135
|
+
labelSpan: PropTypes.number,
|
|
136
|
+
allowClear: PropTypes.bool,
|
|
137
|
+
fieldNames: PropTypes.object,
|
|
138
|
+
maxTagCount: PropTypes.number,
|
|
139
|
+
placeholder: PropTypes.string,
|
|
140
|
+
showCheckedStrategy: PropTypes.string,
|
|
141
|
+
onChange: PropTypes.func
|
|
142
|
+
};
|
|
143
|
+
class RangePicker extends React.Component {
|
|
144
|
+
get algorithm() {
|
|
145
|
+
return algorithm();
|
|
146
|
+
}
|
|
147
|
+
render() {
|
|
148
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
149
|
+
style: this.props.style,
|
|
150
|
+
className: classnames([`${prefixCls}-form-item-control-label-wrapper`, `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`, this.props.label && `${prefixCls}-form-item-control-label-has`])
|
|
151
|
+
}, /*#__PURE__*/React.createElement(Row, {
|
|
152
|
+
align: "middle",
|
|
153
|
+
wrap: false
|
|
154
|
+
}, this.props.label && /*#__PURE__*/React.createElement(Col, {
|
|
155
|
+
span: this.props.labelSpan,
|
|
156
|
+
className: `${prefixCls}-form-item-control-label-span`
|
|
157
|
+
}, this.props.label), /*#__PURE__*/React.createElement(Col, {
|
|
158
|
+
style: {
|
|
159
|
+
flex: 1
|
|
160
|
+
}
|
|
161
|
+
}, /*#__PURE__*/React.createElement(OriginDatePicker.RangePicker, {
|
|
162
|
+
style: {
|
|
163
|
+
width: '100%',
|
|
164
|
+
borderLeft: 'none'
|
|
165
|
+
},
|
|
166
|
+
value: this.props.value,
|
|
167
|
+
format: this.props.format,
|
|
168
|
+
showTime: this.props.showTime || undefined,
|
|
169
|
+
placeholder: this.props.placeholder,
|
|
170
|
+
onChange: value => this.props.onChange(value || undefined)
|
|
171
|
+
}))));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
RangePicker.propTypes = {
|
|
175
|
+
value: PropTypes.any,
|
|
176
|
+
label: PropTypes.string,
|
|
177
|
+
format: PropTypes.string,
|
|
178
|
+
labelSpan: PropTypes.number,
|
|
179
|
+
placeholder: PropTypes.string,
|
|
180
|
+
onChange: PropTypes.func
|
|
181
|
+
};
|
|
182
|
+
class DatePicker extends React.Component {
|
|
183
|
+
static RangePicker = RangePicker;
|
|
184
|
+
get algorithm() {
|
|
185
|
+
return algorithm();
|
|
186
|
+
}
|
|
187
|
+
render() {
|
|
188
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
189
|
+
style: this.props.style,
|
|
190
|
+
className: classnames([`${prefixCls}-form-item-control-label-wrapper`, `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`, this.props.label && `${prefixCls}-form-item-control-label-has`])
|
|
191
|
+
}, /*#__PURE__*/React.createElement(Row, {
|
|
192
|
+
align: "middle",
|
|
193
|
+
wrap: false
|
|
194
|
+
}, this.props.label && /*#__PURE__*/React.createElement(Col, {
|
|
195
|
+
span: this.props.labelSpan,
|
|
196
|
+
className: `${prefixCls}-form-item-control-label-span`
|
|
197
|
+
}, this.props.label), /*#__PURE__*/React.createElement(Col, {
|
|
198
|
+
flex: 1
|
|
199
|
+
}, /*#__PURE__*/React.createElement(OriginDatePicker, {
|
|
200
|
+
style: {
|
|
201
|
+
width: '100%',
|
|
202
|
+
borderLeft: 'none'
|
|
203
|
+
},
|
|
204
|
+
value: this.props.value,
|
|
205
|
+
format: this.props.format,
|
|
206
|
+
picker: this.props.picker || undefined,
|
|
207
|
+
showTime: this.props.showTime || undefined,
|
|
208
|
+
placeholder: this.props.placeholder,
|
|
209
|
+
onChange: value => this.props.onChange(value || undefined)
|
|
210
|
+
}))));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
DatePicker.propTypes = {
|
|
214
|
+
value: PropTypes.any,
|
|
215
|
+
label: PropTypes.string,
|
|
216
|
+
format: PropTypes.string,
|
|
217
|
+
labelSpan: PropTypes.number,
|
|
218
|
+
placeholder: PropTypes.string,
|
|
219
|
+
onChange: PropTypes.func
|
|
220
|
+
};
|
|
221
|
+
class TreeSelect extends React.Component {
|
|
222
|
+
get algorithm() {
|
|
223
|
+
return algorithm();
|
|
224
|
+
}
|
|
225
|
+
render() {
|
|
226
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
227
|
+
style: this.props.style,
|
|
228
|
+
className: classnames([`${prefixCls}-form-item-control-label-wrapper`, `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`, this.props.label && `${prefixCls}-form-item-control-label-has`])
|
|
229
|
+
}, /*#__PURE__*/React.createElement(Row, {
|
|
230
|
+
align: "middle",
|
|
231
|
+
wrap: false
|
|
232
|
+
}, this.props.label && /*#__PURE__*/React.createElement(Col, {
|
|
233
|
+
span: this.props.labelSpan,
|
|
234
|
+
className: `${prefixCls}-form-item-control-label-span`
|
|
235
|
+
}, this.props.label), /*#__PURE__*/React.createElement(Col, {
|
|
236
|
+
flex: 1
|
|
237
|
+
}, /*#__PURE__*/React.createElement(OriginTreeSelect, {
|
|
238
|
+
showSearch: true,
|
|
239
|
+
allowClear: true,
|
|
240
|
+
style: {
|
|
241
|
+
width: '100%',
|
|
242
|
+
borderLeft: 'none'
|
|
243
|
+
},
|
|
244
|
+
treeData: this.props.treeData,
|
|
245
|
+
fieldNames: this.props.fieldNames,
|
|
246
|
+
dropdownStyle: this.props.dropdownStyle,
|
|
247
|
+
maxTagCount: 2,
|
|
248
|
+
value: this.props.value,
|
|
249
|
+
placeholder: this.props.placeholder ? this.props.placeholder : '请选择分类',
|
|
250
|
+
defaultValue: this.props.defaultValue ? this.props.defaultValue : undefined,
|
|
251
|
+
treeCheckable: this.props.checkbox,
|
|
252
|
+
treeNodeFilterProp: "title",
|
|
253
|
+
showCheckedStrategy: OriginTreeSelect.SHOW_PARENT,
|
|
254
|
+
onChange: value => this.props.onChange(value)
|
|
255
|
+
}))));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
TreeSelect.propTypes = {
|
|
259
|
+
label: PropTypes.string,
|
|
260
|
+
checkbox: PropTypes.bool,
|
|
261
|
+
treeData: PropTypes.array,
|
|
262
|
+
labelSpan: PropTypes.number,
|
|
263
|
+
fieldNames: PropTypes.object,
|
|
264
|
+
defaultValue: PropTypes.array,
|
|
265
|
+
dropdownStyle: PropTypes.object,
|
|
266
|
+
onChange: PropTypes.func
|
|
267
|
+
};
|
|
268
|
+
export default {
|
|
269
|
+
Input,
|
|
270
|
+
Select,
|
|
271
|
+
Cascader,
|
|
272
|
+
DatePicker,
|
|
273
|
+
TreeSelect
|
|
274
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@com-prefix-cls: if(isdefined(@ant-prefix), @ant-prefix, ant);
|
|
2
|
+
|
|
3
|
+
.@{com-prefix-cls}-form-item-control-label-wrapper {
|
|
4
|
+
.@{com-prefix-cls}-form-item-control-label-span {
|
|
5
|
+
border: 1px solid #d9d9d9;
|
|
6
|
+
height: 32px;
|
|
7
|
+
line-height: 30px;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
margin-right: -1px;
|
|
10
|
+
padding: 0 8px;
|
|
11
|
+
border-top-left-radius: 4px;
|
|
12
|
+
border-bottom-left-radius: 4px;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&.@{com-prefix-cls}-form-item-control-label-has {
|
|
17
|
+
.@{com-prefix-cls}-select-selector, .@{com-prefix-cls}-picker, .@{com-prefix-cls}-input, .@{com-prefix-cls}-input-affix-wrapper {
|
|
18
|
+
border-top-left-radius: 0;
|
|
19
|
+
border-bottom-left-radius: 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-default {
|
|
24
|
+
.@{com-prefix-cls}-form-item-control-label-span {
|
|
25
|
+
border-color: #d9d9d9;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&-dark {
|
|
30
|
+
.@{com-prefix-cls}-form-item-control-label-span {
|
|
31
|
+
border-color: #424242;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import {
|
|
4
|
+
Cascader as OriginCascader,
|
|
5
|
+
Col,
|
|
6
|
+
DatePicker as OriginDatePicker,
|
|
7
|
+
Input as OriginInput,
|
|
8
|
+
Row,
|
|
9
|
+
Select as OriginSelect,
|
|
10
|
+
TreeSelect as OriginTreeSelect
|
|
11
|
+
} from 'antd';
|
|
12
|
+
import './index.less';
|
|
13
|
+
|
|
14
|
+
const prefixCls = process?.env?.app?.antd[ 'ant-prefix' ] || 'ant';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param classList {string[]}
|
|
18
|
+
* @return {string}
|
|
19
|
+
*/
|
|
20
|
+
function classnames (classList) {
|
|
21
|
+
return classList.filter(i => i).join(' ');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function algorithm () {
|
|
25
|
+
const value = document.documentElement.style.getPropertyValue('--saas-algorithm');
|
|
26
|
+
return value
|
|
27
|
+
? value === '#FFF'
|
|
28
|
+
? 'default'
|
|
29
|
+
: 'dark'
|
|
30
|
+
: 'default';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class Input extends React.Component {
|
|
34
|
+
get algorithm () {
|
|
35
|
+
return algorithm();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
render () {
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
style={this.props.style}
|
|
42
|
+
className={classnames([
|
|
43
|
+
`${prefixCls}-form-item-control-label-wrapper`,
|
|
44
|
+
`${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
|
|
45
|
+
this.props.label && `${prefixCls}-form-item-control-label-has`
|
|
46
|
+
])}
|
|
47
|
+
>
|
|
48
|
+
<Row
|
|
49
|
+
align="middle"
|
|
50
|
+
wrap={false}
|
|
51
|
+
>
|
|
52
|
+
{this.props.label && (
|
|
53
|
+
<Col
|
|
54
|
+
span={this.props.labelSpan}
|
|
55
|
+
className={`${prefixCls}-form-item-control-label-span`}
|
|
56
|
+
>
|
|
57
|
+
{this.props.label}
|
|
58
|
+
</Col>
|
|
59
|
+
)}
|
|
60
|
+
<Col flex={1}>
|
|
61
|
+
<OriginInput
|
|
62
|
+
style={{
|
|
63
|
+
width: '100%',
|
|
64
|
+
borderLeft: 'none'
|
|
65
|
+
}}
|
|
66
|
+
value={this.props.value}
|
|
67
|
+
maxLength={this.props.maxLength}
|
|
68
|
+
allowClear={this.props.allowClear}
|
|
69
|
+
placeholder={this.props.placeholder}
|
|
70
|
+
onChange={e => this.props.onChange(e.target.value || undefined)}
|
|
71
|
+
/>
|
|
72
|
+
</Col>
|
|
73
|
+
</Row>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Input.propTypes = {
|
|
80
|
+
value: PropTypes.any,
|
|
81
|
+
label: PropTypes.string,
|
|
82
|
+
labelSpan: PropTypes.number,
|
|
83
|
+
maxLength: PropTypes.number,
|
|
84
|
+
allowClear: PropTypes.bool,
|
|
85
|
+
placeholder: PropTypes.string,
|
|
86
|
+
onChange: PropTypes.func
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
class Select extends React.Component {
|
|
90
|
+
get algorithm () {
|
|
91
|
+
return algorithm();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
render () {
|
|
95
|
+
return (
|
|
96
|
+
<div
|
|
97
|
+
style={this.props.style}
|
|
98
|
+
className={classnames([
|
|
99
|
+
`${prefixCls}-form-item-control-label-wrapper`,
|
|
100
|
+
`${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
|
|
101
|
+
this.props.label && `${prefixCls}-form-item-control-label-has`
|
|
102
|
+
])}
|
|
103
|
+
>
|
|
104
|
+
<Row
|
|
105
|
+
align="middle"
|
|
106
|
+
wrap={false}
|
|
107
|
+
>
|
|
108
|
+
{this.props.label && (
|
|
109
|
+
<Col
|
|
110
|
+
span={this.props.labelSpan}
|
|
111
|
+
className={`${prefixCls}-form-item-control-label-span`}
|
|
112
|
+
>
|
|
113
|
+
{this.props.label}
|
|
114
|
+
</Col>
|
|
115
|
+
)}
|
|
116
|
+
<Col flex={1}>
|
|
117
|
+
<OriginSelect
|
|
118
|
+
mode={this.props.mode}
|
|
119
|
+
style={{
|
|
120
|
+
width: '100%',
|
|
121
|
+
borderLeft: 'none'
|
|
122
|
+
}}
|
|
123
|
+
value={this.props.value}
|
|
124
|
+
allowClear={this.props.allowClear}
|
|
125
|
+
maxTagCount={this.props.maxTagCount || 3}
|
|
126
|
+
placeholder={this.props.placeholder}
|
|
127
|
+
onChange={value => this.props.onChange(value || undefined)}
|
|
128
|
+
>
|
|
129
|
+
{this.props.options
|
|
130
|
+
? this.props.options
|
|
131
|
+
: this.props.children}
|
|
132
|
+
</OriginSelect>
|
|
133
|
+
</Col>
|
|
134
|
+
</Row>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
Select.propTypes = {
|
|
141
|
+
mode: PropTypes.string,
|
|
142
|
+
value: PropTypes.any,
|
|
143
|
+
label: PropTypes.string,
|
|
144
|
+
labelSpan: PropTypes.number,
|
|
145
|
+
allowClear: PropTypes.bool,
|
|
146
|
+
maxTagCount: PropTypes.number,
|
|
147
|
+
placeholder: PropTypes.string,
|
|
148
|
+
onChange: PropTypes.func
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
class Cascader extends React.Component {
|
|
152
|
+
get algorithm () {
|
|
153
|
+
return algorithm();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
render () {
|
|
157
|
+
return (
|
|
158
|
+
<div
|
|
159
|
+
style={this.props.style}
|
|
160
|
+
className={classnames([
|
|
161
|
+
`${prefixCls}-form-item-control-label-wrapper`,
|
|
162
|
+
`${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
|
|
163
|
+
this.props.label && `${prefixCls}-form-item-control-label-has`
|
|
164
|
+
])}
|
|
165
|
+
>
|
|
166
|
+
<Row
|
|
167
|
+
align="middle"
|
|
168
|
+
wrap={false}
|
|
169
|
+
>
|
|
170
|
+
{this.props.label && (
|
|
171
|
+
<Col
|
|
172
|
+
span={this.props.labelSpan}
|
|
173
|
+
className={`${prefixCls}-form-item-control-label-span`}
|
|
174
|
+
>
|
|
175
|
+
{this.props.label}
|
|
176
|
+
</Col>
|
|
177
|
+
)}
|
|
178
|
+
<Col flex={1}>
|
|
179
|
+
<OriginCascader
|
|
180
|
+
style={{
|
|
181
|
+
width: '100%',
|
|
182
|
+
borderLeft: 'none'
|
|
183
|
+
}}
|
|
184
|
+
value={this.props.value}
|
|
185
|
+
options={this.props.options}
|
|
186
|
+
multiple={this.props.multiple}
|
|
187
|
+
allowClear={this.props.allowClear}
|
|
188
|
+
fieldNames={this.props.fieldNames}
|
|
189
|
+
maxTagCount={this.props.maxTagCount || 3}
|
|
190
|
+
placeholder={this.props.placeholder}
|
|
191
|
+
showCheckedStrategy={this.props.showCheckedStrategy}
|
|
192
|
+
onChange={value => this.props.onChange(value || undefined)}
|
|
193
|
+
/>
|
|
194
|
+
</Col>
|
|
195
|
+
</Row>
|
|
196
|
+
</div>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
Cascader.propTypes = {
|
|
202
|
+
mode: PropTypes.string,
|
|
203
|
+
value: PropTypes.any,
|
|
204
|
+
label: PropTypes.string,
|
|
205
|
+
options: PropTypes.array,
|
|
206
|
+
multiple: PropTypes.bool,
|
|
207
|
+
labelSpan: PropTypes.number,
|
|
208
|
+
allowClear: PropTypes.bool,
|
|
209
|
+
fieldNames: PropTypes.object,
|
|
210
|
+
maxTagCount: PropTypes.number,
|
|
211
|
+
placeholder: PropTypes.string,
|
|
212
|
+
showCheckedStrategy: PropTypes.string,
|
|
213
|
+
onChange: PropTypes.func
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class RangePicker extends React.Component {
|
|
218
|
+
get algorithm () {
|
|
219
|
+
return algorithm();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
render () {
|
|
223
|
+
return (
|
|
224
|
+
<div
|
|
225
|
+
style={this.props.style}
|
|
226
|
+
className={classnames([
|
|
227
|
+
`${prefixCls}-form-item-control-label-wrapper`,
|
|
228
|
+
`${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
|
|
229
|
+
this.props.label && `${prefixCls}-form-item-control-label-has`
|
|
230
|
+
])}
|
|
231
|
+
>
|
|
232
|
+
<Row
|
|
233
|
+
align="middle"
|
|
234
|
+
wrap={false}
|
|
235
|
+
>
|
|
236
|
+
{this.props.label && (
|
|
237
|
+
<Col
|
|
238
|
+
span={this.props.labelSpan}
|
|
239
|
+
className={`${prefixCls}-form-item-control-label-span`}
|
|
240
|
+
>
|
|
241
|
+
{this.props.label}
|
|
242
|
+
</Col>
|
|
243
|
+
)}
|
|
244
|
+
<Col style={{ flex: 1 }}>
|
|
245
|
+
<OriginDatePicker.RangePicker
|
|
246
|
+
style={{
|
|
247
|
+
width: '100%',
|
|
248
|
+
borderLeft: 'none'
|
|
249
|
+
}}
|
|
250
|
+
value={this.props.value}
|
|
251
|
+
format={this.props.format}
|
|
252
|
+
showTime={this.props.showTime || undefined}
|
|
253
|
+
placeholder={this.props.placeholder}
|
|
254
|
+
onChange={value => this.props.onChange(value || undefined)}
|
|
255
|
+
/>
|
|
256
|
+
</Col>
|
|
257
|
+
</Row>
|
|
258
|
+
</div>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
RangePicker.propTypes = {
|
|
264
|
+
value: PropTypes.any,
|
|
265
|
+
label: PropTypes.string,
|
|
266
|
+
format: PropTypes.string,
|
|
267
|
+
labelSpan: PropTypes.number,
|
|
268
|
+
placeholder: PropTypes.string,
|
|
269
|
+
onChange: PropTypes.func
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
class DatePicker extends React.Component {
|
|
273
|
+
static RangePicker = RangePicker;
|
|
274
|
+
|
|
275
|
+
get algorithm () {
|
|
276
|
+
return algorithm();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
render () {
|
|
280
|
+
return (
|
|
281
|
+
<div
|
|
282
|
+
style={this.props.style}
|
|
283
|
+
className={classnames([
|
|
284
|
+
`${prefixCls}-form-item-control-label-wrapper`,
|
|
285
|
+
`${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
|
|
286
|
+
this.props.label && `${prefixCls}-form-item-control-label-has`
|
|
287
|
+
])}
|
|
288
|
+
>
|
|
289
|
+
<Row
|
|
290
|
+
align="middle"
|
|
291
|
+
wrap={false}
|
|
292
|
+
>
|
|
293
|
+
{this.props.label && (
|
|
294
|
+
<Col
|
|
295
|
+
span={this.props.labelSpan}
|
|
296
|
+
className={`${prefixCls}-form-item-control-label-span`}
|
|
297
|
+
>
|
|
298
|
+
{this.props.label}
|
|
299
|
+
</Col>
|
|
300
|
+
)}
|
|
301
|
+
<Col flex={1}>
|
|
302
|
+
<OriginDatePicker
|
|
303
|
+
style={{
|
|
304
|
+
width: '100%',
|
|
305
|
+
borderLeft: 'none'
|
|
306
|
+
}}
|
|
307
|
+
value={this.props.value}
|
|
308
|
+
format={this.props.format}
|
|
309
|
+
picker={this.props.picker || undefined}
|
|
310
|
+
showTime={this.props.showTime || undefined}
|
|
311
|
+
placeholder={this.props.placeholder}
|
|
312
|
+
onChange={value => this.props.onChange(value || undefined)}
|
|
313
|
+
/>
|
|
314
|
+
</Col>
|
|
315
|
+
</Row>
|
|
316
|
+
</div>
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
DatePicker.propTypes = {
|
|
322
|
+
value: PropTypes.any,
|
|
323
|
+
label: PropTypes.string,
|
|
324
|
+
format: PropTypes.string,
|
|
325
|
+
labelSpan: PropTypes.number,
|
|
326
|
+
placeholder: PropTypes.string,
|
|
327
|
+
onChange: PropTypes.func
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
class TreeSelect extends React.Component {
|
|
331
|
+
get algorithm () {
|
|
332
|
+
return algorithm();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
render () {
|
|
336
|
+
return (
|
|
337
|
+
<div
|
|
338
|
+
style={this.props.style}
|
|
339
|
+
className={classnames([
|
|
340
|
+
`${prefixCls}-form-item-control-label-wrapper`,
|
|
341
|
+
`${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
|
|
342
|
+
this.props.label && `${prefixCls}-form-item-control-label-has`
|
|
343
|
+
])}
|
|
344
|
+
>
|
|
345
|
+
<Row
|
|
346
|
+
align="middle"
|
|
347
|
+
wrap={false}
|
|
348
|
+
>
|
|
349
|
+
{this.props.label && (
|
|
350
|
+
<Col
|
|
351
|
+
span={this.props.labelSpan}
|
|
352
|
+
className={`${prefixCls}-form-item-control-label-span`}
|
|
353
|
+
>
|
|
354
|
+
{this.props.label}
|
|
355
|
+
</Col>
|
|
356
|
+
)}
|
|
357
|
+
<Col flex={1}>
|
|
358
|
+
<OriginTreeSelect
|
|
359
|
+
showSearch
|
|
360
|
+
allowClear
|
|
361
|
+
style={{
|
|
362
|
+
width: '100%',
|
|
363
|
+
borderLeft: 'none'
|
|
364
|
+
}}
|
|
365
|
+
treeData={this.props.treeData}
|
|
366
|
+
fieldNames={this.props.fieldNames}
|
|
367
|
+
dropdownStyle={this.props.dropdownStyle}
|
|
368
|
+
maxTagCount={2}
|
|
369
|
+
value={this.props.value}
|
|
370
|
+
placeholder={this.props.placeholder
|
|
371
|
+
? this.props.placeholder
|
|
372
|
+
: '请选择分类'}
|
|
373
|
+
defaultValue={this.props.defaultValue
|
|
374
|
+
? this.props.defaultValue
|
|
375
|
+
: undefined}
|
|
376
|
+
treeCheckable={this.props.checkbox}
|
|
377
|
+
treeNodeFilterProp="title"
|
|
378
|
+
showCheckedStrategy={OriginTreeSelect.SHOW_PARENT}
|
|
379
|
+
onChange={value => this.props.onChange(value)}
|
|
380
|
+
/>
|
|
381
|
+
</Col>
|
|
382
|
+
</Row>
|
|
383
|
+
</div>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
TreeSelect.propTypes = {
|
|
389
|
+
label: PropTypes.string,
|
|
390
|
+
checkbox: PropTypes.bool,
|
|
391
|
+
treeData: PropTypes.array,
|
|
392
|
+
labelSpan: PropTypes.number,
|
|
393
|
+
fieldNames: PropTypes.object,
|
|
394
|
+
defaultValue: PropTypes.array,
|
|
395
|
+
dropdownStyle: PropTypes.object,
|
|
396
|
+
onChange: PropTypes.func
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
export default {
|
|
400
|
+
Input,
|
|
401
|
+
Select,
|
|
402
|
+
Cascader,
|
|
403
|
+
DatePicker,
|
|
404
|
+
TreeSelect
|
|
405
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ComponentProps } from '../types';
|
|
4
|
+
|
|
5
|
+
interface searchFormProps extends ComponentProps {
|
|
6
|
+
/**
|
|
7
|
+
* @description 样式
|
|
8
|
+
*/
|
|
9
|
+
style?: React.CSSProperties,
|
|
10
|
+
/**
|
|
11
|
+
* @description 是否显示展开按钮
|
|
12
|
+
*/
|
|
13
|
+
expand?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @description 每行列数,默认3
|
|
16
|
+
*/
|
|
17
|
+
colSize?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @description 表单内容列表 [<Form.Item>...</Form.Item>,...]
|
|
20
|
+
*/
|
|
21
|
+
formLine: Array<React.ReactNode>;
|
|
22
|
+
/**
|
|
23
|
+
* @description 组件挂载完成 通过事件返回form实例
|
|
24
|
+
*/
|
|
25
|
+
onRef?: (ref: React.Ref<any>) => void;
|
|
26
|
+
/**
|
|
27
|
+
* @description 搜索 按钮触发,返回表单字段
|
|
28
|
+
*/
|
|
29
|
+
onFinish?: (values: { [ p: string ]: any }) => void;
|
|
30
|
+
/**
|
|
31
|
+
* @description 重置 按钮触发
|
|
32
|
+
*/
|
|
33
|
+
onReset?: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface searchFormFc extends React.FC<searchFormProps> {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare const searchForm: searchFormFc;
|
|
40
|
+
export default searchForm;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Form, Button, Space, Row, Col } from 'antd';
|
|
4
|
+
import { SearchOutlined, DoubleRightOutlined, UndoOutlined } from '@ant-design/icons';
|
|
5
|
+
import './index.less';
|
|
6
|
+
class searchForm extends React.Component {
|
|
7
|
+
form = /*#__PURE__*/React.createRef();
|
|
8
|
+
state = {
|
|
9
|
+
isOpen: false
|
|
10
|
+
};
|
|
11
|
+
getButtons() {
|
|
12
|
+
const {
|
|
13
|
+
expand,
|
|
14
|
+
formLine,
|
|
15
|
+
colSize,
|
|
16
|
+
onReset
|
|
17
|
+
} = this.props;
|
|
18
|
+
return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
|
|
19
|
+
type: "primary",
|
|
20
|
+
icon: /*#__PURE__*/React.createElement(SearchOutlined, null),
|
|
21
|
+
htmlType: "submit"
|
|
22
|
+
}, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(Button, {
|
|
23
|
+
icon: /*#__PURE__*/React.createElement(UndoOutlined, null),
|
|
24
|
+
onClick: () => onReset()
|
|
25
|
+
}, "\u91CD\u7F6E"), expand && formLine.length / colSize > 1 && /*#__PURE__*/React.createElement(Button, {
|
|
26
|
+
icon: /*#__PURE__*/React.createElement(DoubleRightOutlined, {
|
|
27
|
+
style: {
|
|
28
|
+
transform: this.state.isOpen ? 'rotate(-90deg)' : 'rotate(90deg)'
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
onClick: () => this.setState({
|
|
32
|
+
isOpen: !this.state.isOpen
|
|
33
|
+
})
|
|
34
|
+
}, this.state.isOpen ? '收起' : '展开'));
|
|
35
|
+
}
|
|
36
|
+
groupsList() {
|
|
37
|
+
if (this.props.expand && this.state.isOpen) {
|
|
38
|
+
return this.props.formLine;
|
|
39
|
+
}
|
|
40
|
+
return this.props.formLine.slice(0, this.props.colSize);
|
|
41
|
+
}
|
|
42
|
+
componentDidMount() {
|
|
43
|
+
if (this.props.onRef) {
|
|
44
|
+
this.props.onRef(this.form);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
const {
|
|
49
|
+
colSize,
|
|
50
|
+
style,
|
|
51
|
+
onFinish
|
|
52
|
+
} = this.props;
|
|
53
|
+
const formItemList = this.groupsList();
|
|
54
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
55
|
+
ref: this.form,
|
|
56
|
+
style: style,
|
|
57
|
+
onFinish: values => onFinish(values)
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Row, {
|
|
59
|
+
gutter: [16, 16]
|
|
60
|
+
}, formItemList.map((item, index) => /*#__PURE__*/React.createElement(Col, {
|
|
61
|
+
key: index,
|
|
62
|
+
span: 24 / colSize
|
|
63
|
+
}, item)), /*#__PURE__*/React.createElement(Col, {
|
|
64
|
+
span: 24 / colSize
|
|
65
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
66
|
+
noStyle: true
|
|
67
|
+
}, this.getButtons()))));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
searchForm.defaultProps = {
|
|
71
|
+
style: {},
|
|
72
|
+
expand: false,
|
|
73
|
+
colSize: 3,
|
|
74
|
+
formLine: [],
|
|
75
|
+
onRef: () => {},
|
|
76
|
+
onReset: () => {},
|
|
77
|
+
onFinish: () => {}
|
|
78
|
+
};
|
|
79
|
+
searchForm.propTypes = {
|
|
80
|
+
style: PropTypes.object,
|
|
81
|
+
expand: PropTypes.bool,
|
|
82
|
+
colSize: PropTypes.number,
|
|
83
|
+
formLine: PropTypes.array,
|
|
84
|
+
onRef: PropTypes.func,
|
|
85
|
+
onReset: PropTypes.func,
|
|
86
|
+
onFinish: PropTypes.func
|
|
87
|
+
};
|
|
88
|
+
export default searchForm;
|
|
File without changes
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Form, Button, Space, Row, Col } from 'antd';
|
|
4
|
+
import { SearchOutlined, DoubleRightOutlined, UndoOutlined } from '@ant-design/icons';
|
|
5
|
+
import './index.less';
|
|
6
|
+
|
|
7
|
+
class searchForm extends React.Component {
|
|
8
|
+
form = React.createRef();
|
|
9
|
+
state = {
|
|
10
|
+
isOpen: false
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
getButtons () {
|
|
14
|
+
const {
|
|
15
|
+
expand,
|
|
16
|
+
formLine,
|
|
17
|
+
colSize,
|
|
18
|
+
onReset
|
|
19
|
+
} = this.props;
|
|
20
|
+
return (
|
|
21
|
+
<Space>
|
|
22
|
+
<Button
|
|
23
|
+
type="primary"
|
|
24
|
+
icon={<SearchOutlined />}
|
|
25
|
+
htmlType="submit"
|
|
26
|
+
>
|
|
27
|
+
查询
|
|
28
|
+
</Button>
|
|
29
|
+
<Button
|
|
30
|
+
icon={<UndoOutlined />}
|
|
31
|
+
onClick={() => onReset()}
|
|
32
|
+
>
|
|
33
|
+
重置
|
|
34
|
+
</Button>
|
|
35
|
+
{expand && formLine.length / colSize > 1 && (
|
|
36
|
+
<Button
|
|
37
|
+
icon={(
|
|
38
|
+
<DoubleRightOutlined
|
|
39
|
+
style={{
|
|
40
|
+
transform: this.state.isOpen
|
|
41
|
+
? 'rotate(-90deg)'
|
|
42
|
+
: 'rotate(90deg)'
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
)}
|
|
46
|
+
onClick={() => this.setState({ isOpen: !this.state.isOpen })}
|
|
47
|
+
>
|
|
48
|
+
{this.state.isOpen
|
|
49
|
+
? '收起'
|
|
50
|
+
: '展开'}
|
|
51
|
+
</Button>
|
|
52
|
+
)}
|
|
53
|
+
</Space>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
groupsList () {
|
|
58
|
+
if (this.props.expand && this.state.isOpen) {
|
|
59
|
+
return this.props.formLine;
|
|
60
|
+
}
|
|
61
|
+
return this.props.formLine.slice(0, this.props.colSize);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
componentDidMount () {
|
|
65
|
+
if (this.props.onRef) {
|
|
66
|
+
this.props.onRef(this.form);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
render () {
|
|
71
|
+
const {
|
|
72
|
+
colSize,
|
|
73
|
+
style,
|
|
74
|
+
onFinish
|
|
75
|
+
} = this.props;
|
|
76
|
+
const formItemList = this.groupsList();
|
|
77
|
+
return (
|
|
78
|
+
<Form
|
|
79
|
+
ref={this.form}
|
|
80
|
+
style={style}
|
|
81
|
+
onFinish={values => onFinish(values)}
|
|
82
|
+
>
|
|
83
|
+
<Row gutter={[ 16, 16 ]}>
|
|
84
|
+
{formItemList.map((item, index) => (
|
|
85
|
+
<Col
|
|
86
|
+
key={index}
|
|
87
|
+
span={24 / colSize}
|
|
88
|
+
>
|
|
89
|
+
{item}
|
|
90
|
+
</Col>
|
|
91
|
+
))}
|
|
92
|
+
<Col span={24 / colSize}>
|
|
93
|
+
<Form.Item noStyle>
|
|
94
|
+
{this.getButtons()}
|
|
95
|
+
</Form.Item>
|
|
96
|
+
</Col>
|
|
97
|
+
</Row>
|
|
98
|
+
</Form>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
searchForm.defaultProps = {
|
|
104
|
+
style: {},
|
|
105
|
+
expand: false,
|
|
106
|
+
colSize: 3,
|
|
107
|
+
formLine: [],
|
|
108
|
+
onRef: () => {},
|
|
109
|
+
onReset: () => {},
|
|
110
|
+
onFinish: () => {},
|
|
111
|
+
};
|
|
112
|
+
searchForm.propTypes = {
|
|
113
|
+
style: PropTypes.object,
|
|
114
|
+
expand: PropTypes.bool,
|
|
115
|
+
colSize: PropTypes.number,
|
|
116
|
+
formLine: PropTypes.array,
|
|
117
|
+
onRef: PropTypes.func,
|
|
118
|
+
onReset: PropTypes.func,
|
|
119
|
+
onFinish: PropTypes.func,
|
|
120
|
+
};
|
|
121
|
+
export default searchForm;
|