@cqsjjb/jjb-react-admin-component 3.0.0 → 3.0.2

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.
@@ -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,268 @@
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
+ },
38
+ value: this.props.value,
39
+ maxLength: this.props.maxLength,
40
+ allowClear: this.props.allowClear,
41
+ placeholder: this.props.placeholder,
42
+ onChange: e => this.props.onChange(e.target.value || undefined)
43
+ }))));
44
+ }
45
+ }
46
+ Input.propTypes = {
47
+ value: PropTypes.any,
48
+ label: PropTypes.string,
49
+ labelSpan: PropTypes.number,
50
+ maxLength: PropTypes.number,
51
+ allowClear: PropTypes.bool,
52
+ placeholder: PropTypes.string,
53
+ onChange: PropTypes.func
54
+ };
55
+ class Select extends React.Component {
56
+ get algorithm() {
57
+ return algorithm();
58
+ }
59
+ render() {
60
+ return /*#__PURE__*/React.createElement("div", {
61
+ style: this.props.style,
62
+ 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`])
63
+ }, /*#__PURE__*/React.createElement(Row, {
64
+ align: "middle",
65
+ wrap: false
66
+ }, this.props.label && /*#__PURE__*/React.createElement(Col, {
67
+ span: this.props.labelSpan,
68
+ className: `${prefixCls}-form-item-control-label-span`
69
+ }, this.props.label), /*#__PURE__*/React.createElement(Col, {
70
+ flex: 1
71
+ }, /*#__PURE__*/React.createElement(OriginSelect, {
72
+ mode: this.props.mode,
73
+ style: {
74
+ width: '100%'
75
+ },
76
+ value: this.props.value,
77
+ allowClear: this.props.allowClear,
78
+ maxTagCount: this.props.maxTagCount || 3,
79
+ placeholder: this.props.placeholder,
80
+ onChange: value => this.props.onChange(value || undefined)
81
+ }, this.props.options ? this.props.options : this.props.children))));
82
+ }
83
+ }
84
+ Select.propTypes = {
85
+ mode: PropTypes.string,
86
+ value: PropTypes.any,
87
+ label: PropTypes.string,
88
+ labelSpan: PropTypes.number,
89
+ allowClear: PropTypes.bool,
90
+ maxTagCount: PropTypes.number,
91
+ placeholder: PropTypes.string,
92
+ onChange: PropTypes.func
93
+ };
94
+ class Cascader extends React.Component {
95
+ get algorithm() {
96
+ return algorithm();
97
+ }
98
+ render() {
99
+ return /*#__PURE__*/React.createElement("div", {
100
+ style: this.props.style,
101
+ 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`])
102
+ }, /*#__PURE__*/React.createElement(Row, {
103
+ align: "middle",
104
+ wrap: false
105
+ }, this.props.label && /*#__PURE__*/React.createElement(Col, {
106
+ span: this.props.labelSpan,
107
+ className: `${prefixCls}-form-item-control-label-span`
108
+ }, this.props.label), /*#__PURE__*/React.createElement(Col, {
109
+ flex: 1
110
+ }, /*#__PURE__*/React.createElement(OriginCascader, {
111
+ style: {
112
+ width: '100%'
113
+ },
114
+ value: this.props.value,
115
+ options: this.props.options,
116
+ multiple: this.props.multiple,
117
+ allowClear: this.props.allowClear,
118
+ fieldNames: this.props.fieldNames,
119
+ maxTagCount: this.props.maxTagCount || 3,
120
+ placeholder: this.props.placeholder,
121
+ showCheckedStrategy: this.props.showCheckedStrategy,
122
+ onChange: value => this.props.onChange(value || undefined)
123
+ }))));
124
+ }
125
+ }
126
+ Cascader.propTypes = {
127
+ mode: PropTypes.string,
128
+ value: PropTypes.any,
129
+ label: PropTypes.string,
130
+ options: PropTypes.array,
131
+ multiple: PropTypes.bool,
132
+ labelSpan: PropTypes.number,
133
+ allowClear: PropTypes.bool,
134
+ fieldNames: PropTypes.object,
135
+ maxTagCount: PropTypes.number,
136
+ placeholder: PropTypes.string,
137
+ showCheckedStrategy: PropTypes.string,
138
+ onChange: PropTypes.func
139
+ };
140
+ class RangePicker extends React.Component {
141
+ get algorithm() {
142
+ return algorithm();
143
+ }
144
+ render() {
145
+ return /*#__PURE__*/React.createElement("div", {
146
+ style: this.props.style,
147
+ 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`])
148
+ }, /*#__PURE__*/React.createElement(Row, {
149
+ align: "middle",
150
+ wrap: false
151
+ }, this.props.label && /*#__PURE__*/React.createElement(Col, {
152
+ span: this.props.labelSpan,
153
+ className: `${prefixCls}-form-item-control-label-span`
154
+ }, this.props.label), /*#__PURE__*/React.createElement(Col, {
155
+ style: {
156
+ flex: 1
157
+ }
158
+ }, /*#__PURE__*/React.createElement(OriginDatePicker.RangePicker, {
159
+ style: {
160
+ width: '100%'
161
+ },
162
+ value: this.props.value,
163
+ format: this.props.format,
164
+ showTime: this.props.showTime || undefined,
165
+ placeholder: this.props.placeholder,
166
+ onChange: value => this.props.onChange(value || undefined)
167
+ }))));
168
+ }
169
+ }
170
+ RangePicker.propTypes = {
171
+ value: PropTypes.any,
172
+ label: PropTypes.string,
173
+ format: PropTypes.string,
174
+ labelSpan: PropTypes.number,
175
+ placeholder: PropTypes.string,
176
+ onChange: PropTypes.func
177
+ };
178
+ class DatePicker extends React.Component {
179
+ static RangePicker = RangePicker;
180
+ get algorithm() {
181
+ return algorithm();
182
+ }
183
+ render() {
184
+ return /*#__PURE__*/React.createElement("div", {
185
+ style: this.props.style,
186
+ 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`])
187
+ }, /*#__PURE__*/React.createElement(Row, {
188
+ align: "middle",
189
+ wrap: false
190
+ }, this.props.label && /*#__PURE__*/React.createElement(Col, {
191
+ span: this.props.labelSpan,
192
+ className: `${prefixCls}-form-item-control-label-span`
193
+ }, this.props.label), /*#__PURE__*/React.createElement(Col, {
194
+ flex: 1
195
+ }, /*#__PURE__*/React.createElement(OriginDatePicker, {
196
+ style: {
197
+ width: '100%'
198
+ },
199
+ value: this.props.value,
200
+ format: this.props.format,
201
+ picker: this.props.picker || undefined,
202
+ showTime: this.props.showTime || undefined,
203
+ placeholder: this.props.placeholder,
204
+ onChange: value => this.props.onChange(value || undefined)
205
+ }))));
206
+ }
207
+ }
208
+ DatePicker.propTypes = {
209
+ value: PropTypes.any,
210
+ label: PropTypes.string,
211
+ format: PropTypes.string,
212
+ labelSpan: PropTypes.number,
213
+ placeholder: PropTypes.string,
214
+ onChange: PropTypes.func
215
+ };
216
+ class TreeSelect extends React.Component {
217
+ get algorithm() {
218
+ return algorithm();
219
+ }
220
+ render() {
221
+ return /*#__PURE__*/React.createElement("div", {
222
+ style: this.props.style,
223
+ 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`])
224
+ }, /*#__PURE__*/React.createElement(Row, {
225
+ align: "middle",
226
+ wrap: false
227
+ }, this.props.label && /*#__PURE__*/React.createElement(Col, {
228
+ span: this.props.labelSpan,
229
+ className: `${prefixCls}-form-item-control-label-span`
230
+ }, this.props.label), /*#__PURE__*/React.createElement(Col, {
231
+ flex: 1
232
+ }, /*#__PURE__*/React.createElement(OriginTreeSelect, {
233
+ showSearch: true,
234
+ allowClear: true,
235
+ style: {
236
+ width: '100%'
237
+ },
238
+ treeData: this.props.treeData,
239
+ fieldNames: this.props.fieldNames,
240
+ dropdownStyle: this.props.dropdownStyle,
241
+ maxTagCount: 2,
242
+ value: this.props.value,
243
+ placeholder: this.props.placeholder ? this.props.placeholder : '请选择分类',
244
+ defaultValue: this.props.defaultValue ? this.props.defaultValue : undefined,
245
+ treeCheckable: this.props.checkbox,
246
+ treeNodeFilterProp: "title",
247
+ showCheckedStrategy: OriginTreeSelect.SHOW_PARENT,
248
+ onChange: value => this.props.onChange(value)
249
+ }))));
250
+ }
251
+ }
252
+ TreeSelect.propTypes = {
253
+ label: PropTypes.string,
254
+ checkbox: PropTypes.bool,
255
+ treeData: PropTypes.array,
256
+ labelSpan: PropTypes.number,
257
+ fieldNames: PropTypes.object,
258
+ defaultValue: PropTypes.array,
259
+ dropdownStyle: PropTypes.object,
260
+ onChange: PropTypes.func
261
+ };
262
+ export default {
263
+ Input,
264
+ Select,
265
+ Cascader,
266
+ DatePicker,
267
+ TreeSelect
268
+ };
@@ -0,0 +1,38 @@
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 2px 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
+ border-left-color: transparent !important;
21
+ &:hover, &:focus, &:focus-within{
22
+ border-left-color: @colorPrimary !important;
23
+ }
24
+ }
25
+ }
26
+
27
+ &-default {
28
+ .@{com-prefix-cls}-form-item-control-label-span {
29
+ border-color: #d9d9d9;
30
+ }
31
+ }
32
+
33
+ &-dark {
34
+ .@{com-prefix-cls}-form-item-control-label-span {
35
+ border-color: #424242;
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,399 @@
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
+ }}
65
+ value={this.props.value}
66
+ maxLength={this.props.maxLength}
67
+ allowClear={this.props.allowClear}
68
+ placeholder={this.props.placeholder}
69
+ onChange={e => this.props.onChange(e.target.value || undefined)}
70
+ />
71
+ </Col>
72
+ </Row>
73
+ </div>
74
+ );
75
+ }
76
+ }
77
+
78
+ Input.propTypes = {
79
+ value: PropTypes.any,
80
+ label: PropTypes.string,
81
+ labelSpan: PropTypes.number,
82
+ maxLength: PropTypes.number,
83
+ allowClear: PropTypes.bool,
84
+ placeholder: PropTypes.string,
85
+ onChange: PropTypes.func
86
+ };
87
+
88
+ class Select extends React.Component {
89
+ get algorithm () {
90
+ return algorithm();
91
+ }
92
+
93
+ render () {
94
+ return (
95
+ <div
96
+ style={this.props.style}
97
+ className={classnames([
98
+ `${prefixCls}-form-item-control-label-wrapper`,
99
+ `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
100
+ this.props.label && `${prefixCls}-form-item-control-label-has`
101
+ ])}
102
+ >
103
+ <Row
104
+ align="middle"
105
+ wrap={false}
106
+ >
107
+ {this.props.label && (
108
+ <Col
109
+ span={this.props.labelSpan}
110
+ className={`${prefixCls}-form-item-control-label-span`}
111
+ >
112
+ {this.props.label}
113
+ </Col>
114
+ )}
115
+ <Col flex={1}>
116
+ <OriginSelect
117
+ mode={this.props.mode}
118
+ style={{
119
+ width: '100%'
120
+ }}
121
+ value={this.props.value}
122
+ allowClear={this.props.allowClear}
123
+ maxTagCount={this.props.maxTagCount || 3}
124
+ placeholder={this.props.placeholder}
125
+ onChange={value => this.props.onChange(value || undefined)}
126
+ >
127
+ {this.props.options
128
+ ? this.props.options
129
+ : this.props.children}
130
+ </OriginSelect>
131
+ </Col>
132
+ </Row>
133
+ </div>
134
+ );
135
+ }
136
+ }
137
+
138
+ Select.propTypes = {
139
+ mode: PropTypes.string,
140
+ value: PropTypes.any,
141
+ label: PropTypes.string,
142
+ labelSpan: PropTypes.number,
143
+ allowClear: PropTypes.bool,
144
+ maxTagCount: PropTypes.number,
145
+ placeholder: PropTypes.string,
146
+ onChange: PropTypes.func
147
+ };
148
+
149
+ class Cascader extends React.Component {
150
+ get algorithm () {
151
+ return algorithm();
152
+ }
153
+
154
+ render () {
155
+ return (
156
+ <div
157
+ style={this.props.style}
158
+ className={classnames([
159
+ `${prefixCls}-form-item-control-label-wrapper`,
160
+ `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
161
+ this.props.label && `${prefixCls}-form-item-control-label-has`
162
+ ])}
163
+ >
164
+ <Row
165
+ align="middle"
166
+ wrap={false}
167
+ >
168
+ {this.props.label && (
169
+ <Col
170
+ span={this.props.labelSpan}
171
+ className={`${prefixCls}-form-item-control-label-span`}
172
+ >
173
+ {this.props.label}
174
+ </Col>
175
+ )}
176
+ <Col flex={1}>
177
+ <OriginCascader
178
+ style={{
179
+ width: '100%'
180
+ }}
181
+ value={this.props.value}
182
+ options={this.props.options}
183
+ multiple={this.props.multiple}
184
+ allowClear={this.props.allowClear}
185
+ fieldNames={this.props.fieldNames}
186
+ maxTagCount={this.props.maxTagCount || 3}
187
+ placeholder={this.props.placeholder}
188
+ showCheckedStrategy={this.props.showCheckedStrategy}
189
+ onChange={value => this.props.onChange(value || undefined)}
190
+ />
191
+ </Col>
192
+ </Row>
193
+ </div>
194
+ );
195
+ }
196
+ }
197
+
198
+ Cascader.propTypes = {
199
+ mode: PropTypes.string,
200
+ value: PropTypes.any,
201
+ label: PropTypes.string,
202
+ options: PropTypes.array,
203
+ multiple: PropTypes.bool,
204
+ labelSpan: PropTypes.number,
205
+ allowClear: PropTypes.bool,
206
+ fieldNames: PropTypes.object,
207
+ maxTagCount: PropTypes.number,
208
+ placeholder: PropTypes.string,
209
+ showCheckedStrategy: PropTypes.string,
210
+ onChange: PropTypes.func
211
+ };
212
+
213
+
214
+ class RangePicker extends React.Component {
215
+ get algorithm () {
216
+ return algorithm();
217
+ }
218
+
219
+ render () {
220
+ return (
221
+ <div
222
+ style={this.props.style}
223
+ className={classnames([
224
+ `${prefixCls}-form-item-control-label-wrapper`,
225
+ `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
226
+ this.props.label && `${prefixCls}-form-item-control-label-has`
227
+ ])}
228
+ >
229
+ <Row
230
+ align="middle"
231
+ wrap={false}
232
+ >
233
+ {this.props.label && (
234
+ <Col
235
+ span={this.props.labelSpan}
236
+ className={`${prefixCls}-form-item-control-label-span`}
237
+ >
238
+ {this.props.label}
239
+ </Col>
240
+ )}
241
+ <Col style={{ flex: 1 }}>
242
+ <OriginDatePicker.RangePicker
243
+ style={{
244
+ width: '100%'
245
+ }}
246
+ value={this.props.value}
247
+ format={this.props.format}
248
+ showTime={this.props.showTime || undefined}
249
+ placeholder={this.props.placeholder}
250
+ onChange={value => this.props.onChange(value || undefined)}
251
+ />
252
+ </Col>
253
+ </Row>
254
+ </div>
255
+ );
256
+ }
257
+ }
258
+
259
+ RangePicker.propTypes = {
260
+ value: PropTypes.any,
261
+ label: PropTypes.string,
262
+ format: PropTypes.string,
263
+ labelSpan: PropTypes.number,
264
+ placeholder: PropTypes.string,
265
+ onChange: PropTypes.func
266
+ };
267
+
268
+ class DatePicker extends React.Component {
269
+ static RangePicker = RangePicker;
270
+
271
+ get algorithm () {
272
+ return algorithm();
273
+ }
274
+
275
+ render () {
276
+ return (
277
+ <div
278
+ style={this.props.style}
279
+ className={classnames([
280
+ `${prefixCls}-form-item-control-label-wrapper`,
281
+ `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
282
+ this.props.label && `${prefixCls}-form-item-control-label-has`
283
+ ])}
284
+ >
285
+ <Row
286
+ align="middle"
287
+ wrap={false}
288
+ >
289
+ {this.props.label && (
290
+ <Col
291
+ span={this.props.labelSpan}
292
+ className={`${prefixCls}-form-item-control-label-span`}
293
+ >
294
+ {this.props.label}
295
+ </Col>
296
+ )}
297
+ <Col flex={1}>
298
+ <OriginDatePicker
299
+ style={{
300
+ width: '100%'
301
+ }}
302
+ value={this.props.value}
303
+ format={this.props.format}
304
+ picker={this.props.picker || undefined}
305
+ showTime={this.props.showTime || undefined}
306
+ placeholder={this.props.placeholder}
307
+ onChange={value => this.props.onChange(value || undefined)}
308
+ />
309
+ </Col>
310
+ </Row>
311
+ </div>
312
+ );
313
+ }
314
+ }
315
+
316
+ DatePicker.propTypes = {
317
+ value: PropTypes.any,
318
+ label: PropTypes.string,
319
+ format: PropTypes.string,
320
+ labelSpan: PropTypes.number,
321
+ placeholder: PropTypes.string,
322
+ onChange: PropTypes.func
323
+ };
324
+
325
+ class TreeSelect extends React.Component {
326
+ get algorithm () {
327
+ return algorithm();
328
+ }
329
+
330
+ render () {
331
+ return (
332
+ <div
333
+ style={this.props.style}
334
+ className={classnames([
335
+ `${prefixCls}-form-item-control-label-wrapper`,
336
+ `${prefixCls}-form-item-control-label-wrapper-${this.algorithm}`,
337
+ this.props.label && `${prefixCls}-form-item-control-label-has`
338
+ ])}
339
+ >
340
+ <Row
341
+ align="middle"
342
+ wrap={false}
343
+ >
344
+ {this.props.label && (
345
+ <Col
346
+ span={this.props.labelSpan}
347
+ className={`${prefixCls}-form-item-control-label-span`}
348
+ >
349
+ {this.props.label}
350
+ </Col>
351
+ )}
352
+ <Col flex={1}>
353
+ <OriginTreeSelect
354
+ showSearch
355
+ allowClear
356
+ style={{
357
+ width: '100%'
358
+ }}
359
+ treeData={this.props.treeData}
360
+ fieldNames={this.props.fieldNames}
361
+ dropdownStyle={this.props.dropdownStyle}
362
+ maxTagCount={2}
363
+ value={this.props.value}
364
+ placeholder={this.props.placeholder
365
+ ? this.props.placeholder
366
+ : '请选择分类'}
367
+ defaultValue={this.props.defaultValue
368
+ ? this.props.defaultValue
369
+ : undefined}
370
+ treeCheckable={this.props.checkbox}
371
+ treeNodeFilterProp="title"
372
+ showCheckedStrategy={OriginTreeSelect.SHOW_PARENT}
373
+ onChange={value => this.props.onChange(value)}
374
+ />
375
+ </Col>
376
+ </Row>
377
+ </div>
378
+ );
379
+ }
380
+ }
381
+
382
+ TreeSelect.propTypes = {
383
+ label: PropTypes.string,
384
+ checkbox: PropTypes.bool,
385
+ treeData: PropTypes.array,
386
+ labelSpan: PropTypes.number,
387
+ fieldNames: PropTypes.object,
388
+ defaultValue: PropTypes.array,
389
+ dropdownStyle: PropTypes.object,
390
+ onChange: PropTypes.func
391
+ };
392
+
393
+ export default {
394
+ Input,
395
+ Select,
396
+ Cascader,
397
+ DatePicker,
398
+ TreeSelect
399
+ };
@@ -0,0 +1,44 @@
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 加载中
24
+ */
25
+ loading?: boolean;
26
+ /**
27
+ * @description 组件挂载完成 通过事件返回form实例
28
+ */
29
+ onRef?: (ref: React.Ref<any>) => void;
30
+ /**
31
+ * @description 搜索 按钮触发,返回表单字段
32
+ */
33
+ onFinish?: (values: { [ p: string ]: any }) => void;
34
+ /**
35
+ * @description 重置 按钮触发
36
+ */
37
+ onReset?: () => void;
38
+ }
39
+
40
+ interface searchFormFc extends React.FC<searchFormProps> {
41
+ }
42
+
43
+ declare const searchForm: searchFormFc;
44
+ export default searchForm;
@@ -0,0 +1,93 @@
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
+ loading,
17
+ onReset
18
+ } = this.props;
19
+ return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
20
+ type: "primary",
21
+ icon: /*#__PURE__*/React.createElement(SearchOutlined, null),
22
+ htmlType: "submit",
23
+ loading: loading
24
+ }, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(Button, {
25
+ icon: /*#__PURE__*/React.createElement(UndoOutlined, null),
26
+ loading: loading,
27
+ onClick: () => onReset()
28
+ }, "\u91CD\u7F6E"), expand && formLine.length / colSize > 1 && /*#__PURE__*/React.createElement(Button, {
29
+ icon: /*#__PURE__*/React.createElement(DoubleRightOutlined, {
30
+ style: {
31
+ transform: this.state.isOpen ? 'rotate(-90deg)' : 'rotate(90deg)'
32
+ }
33
+ }),
34
+ onClick: () => this.setState({
35
+ isOpen: !this.state.isOpen
36
+ })
37
+ }, this.state.isOpen ? '收起' : '展开'));
38
+ }
39
+ groupsList() {
40
+ if (this.props.expand && this.state.isOpen) {
41
+ return this.props.formLine;
42
+ }
43
+ return this.props.formLine.slice(0, this.props.colSize);
44
+ }
45
+ componentDidMount() {
46
+ if (this.props.onRef) {
47
+ this.props.onRef(this.form);
48
+ }
49
+ }
50
+ render() {
51
+ const {
52
+ colSize,
53
+ style,
54
+ onFinish
55
+ } = this.props;
56
+ const formItemList = this.groupsList();
57
+ return /*#__PURE__*/React.createElement(Form, {
58
+ ref: this.form,
59
+ style: style,
60
+ onFinish: values => onFinish(values)
61
+ }, /*#__PURE__*/React.createElement(Row, {
62
+ gutter: [16, 16]
63
+ }, formItemList.map((item, index) => /*#__PURE__*/React.createElement(Col, {
64
+ key: index,
65
+ span: 24 / colSize
66
+ }, item)), /*#__PURE__*/React.createElement(Col, {
67
+ span: 24 / colSize
68
+ }, /*#__PURE__*/React.createElement(Form.Item, {
69
+ noStyle: true
70
+ }, this.getButtons()))));
71
+ }
72
+ }
73
+ searchForm.defaultProps = {
74
+ style: {},
75
+ expand: false,
76
+ colSize: 3,
77
+ formLine: [],
78
+ loading: false,
79
+ onRef: () => {},
80
+ onReset: () => {},
81
+ onFinish: () => {}
82
+ };
83
+ searchForm.propTypes = {
84
+ style: PropTypes.object,
85
+ expand: PropTypes.bool,
86
+ colSize: PropTypes.number,
87
+ formLine: PropTypes.array,
88
+ loading: PropTypes.bool,
89
+ onRef: PropTypes.func,
90
+ onReset: PropTypes.func,
91
+ onFinish: PropTypes.func
92
+ };
93
+ export default searchForm;
File without changes
@@ -0,0 +1,126 @@
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
+ loading,
19
+ onReset
20
+ } = this.props;
21
+ return (
22
+ <Space>
23
+ <Button
24
+ type="primary"
25
+ icon={<SearchOutlined />}
26
+ htmlType="submit"
27
+ loading={loading}
28
+ >
29
+ 查询
30
+ </Button>
31
+ <Button
32
+ icon={<UndoOutlined />}
33
+ loading={loading}
34
+ onClick={() => onReset()}
35
+ >
36
+ 重置
37
+ </Button>
38
+ {expand && formLine.length / colSize > 1 && (
39
+ <Button
40
+ icon={(
41
+ <DoubleRightOutlined
42
+ style={{
43
+ transform: this.state.isOpen
44
+ ? 'rotate(-90deg)'
45
+ : 'rotate(90deg)'
46
+ }}
47
+ />
48
+ )}
49
+ onClick={() => this.setState({ isOpen: !this.state.isOpen })}
50
+ >
51
+ {this.state.isOpen
52
+ ? '收起'
53
+ : '展开'}
54
+ </Button>
55
+ )}
56
+ </Space>
57
+ );
58
+ }
59
+
60
+ groupsList () {
61
+ if (this.props.expand && this.state.isOpen) {
62
+ return this.props.formLine;
63
+ }
64
+ return this.props.formLine.slice(0, this.props.colSize);
65
+ }
66
+
67
+ componentDidMount () {
68
+ if (this.props.onRef) {
69
+ this.props.onRef(this.form);
70
+ }
71
+ }
72
+
73
+ render () {
74
+ const {
75
+ colSize,
76
+ style,
77
+ onFinish
78
+ } = this.props;
79
+ const formItemList = this.groupsList();
80
+ return (
81
+ <Form
82
+ ref={this.form}
83
+ style={style}
84
+ onFinish={values => onFinish(values)}
85
+ >
86
+ <Row gutter={[ 16, 16 ]}>
87
+ {formItemList.map((item, index) => (
88
+ <Col
89
+ key={index}
90
+ span={24 / colSize}
91
+ >
92
+ {item}
93
+ </Col>
94
+ ))}
95
+ <Col span={24 / colSize}>
96
+ <Form.Item noStyle>
97
+ {this.getButtons()}
98
+ </Form.Item>
99
+ </Col>
100
+ </Row>
101
+ </Form>
102
+ );
103
+ }
104
+ }
105
+
106
+ searchForm.defaultProps = {
107
+ style: {},
108
+ expand: false,
109
+ colSize: 3,
110
+ formLine: [],
111
+ loading: false,
112
+ onRef: () => {},
113
+ onReset: () => {},
114
+ onFinish: () => {},
115
+ };
116
+ searchForm.propTypes = {
117
+ style: PropTypes.object,
118
+ expand: PropTypes.bool,
119
+ colSize: PropTypes.number,
120
+ formLine: PropTypes.array,
121
+ loading: PropTypes.bool,
122
+ onRef: PropTypes.func,
123
+ onReset: PropTypes.func,
124
+ onFinish: PropTypes.func,
125
+ };
126
+ export default searchForm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqsjjb/jjb-react-admin-component",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "jjb-react-admin-组件库@new",
5
5
  "main": "index.js",
6
6
  "author": "jjb-front-team",