@cqsjjb/jjb-react-admin-component 3.0.5 → 3.0.7
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/SearchForm/index.d.ts +5 -1
- package/SearchForm/index.js +10 -4
- package/SearchForm/index.mjs +57 -38
- package/package.json +1 -1
package/SearchForm/index.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import * as React from 'react';
|
|
|
3
3
|
import { ComponentProps } from '../types';
|
|
4
4
|
|
|
5
5
|
interface searchFormProps extends ComponentProps {
|
|
6
|
+
/**
|
|
7
|
+
* @description form实例
|
|
8
|
+
*/
|
|
9
|
+
form?: any,
|
|
6
10
|
/**
|
|
7
11
|
* @description 样式
|
|
8
12
|
*/
|
|
@@ -38,7 +42,7 @@ interface searchFormProps extends ComponentProps {
|
|
|
38
42
|
/**
|
|
39
43
|
* @description 重置 按钮触发
|
|
40
44
|
*/
|
|
41
|
-
onReset?: () => void;
|
|
45
|
+
onReset?: (values: { [ p: string ]: any }) => void;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
interface searchFormFc extends React.FC<searchFormProps> {
|
package/SearchForm/index.js
CHANGED
|
@@ -10,6 +10,7 @@ class searchForm extends React.Component {
|
|
|
10
10
|
};
|
|
11
11
|
getButtons() {
|
|
12
12
|
const {
|
|
13
|
+
form,
|
|
13
14
|
expand,
|
|
14
15
|
formLine,
|
|
15
16
|
colSize,
|
|
@@ -24,7 +25,10 @@ class searchForm extends React.Component {
|
|
|
24
25
|
}, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(Button, {
|
|
25
26
|
icon: /*#__PURE__*/React.createElement(UndoOutlined, null),
|
|
26
27
|
loading: loading,
|
|
27
|
-
onClick: () =>
|
|
28
|
+
onClick: () => {
|
|
29
|
+
form ? form.current.resetFields() : this.form.current.resetFields();
|
|
30
|
+
onReset(form ? form.current.getFieldsValue() : this.form.current.getFieldsValue());
|
|
31
|
+
}
|
|
28
32
|
}, "\u91CD\u7F6E"), expand && formLine.length / colSize > 1 && /*#__PURE__*/React.createElement(Button, {
|
|
29
33
|
icon: /*#__PURE__*/React.createElement(DoubleRightOutlined, {
|
|
30
34
|
style: {
|
|
@@ -64,14 +68,15 @@ class searchForm extends React.Component {
|
|
|
64
68
|
}
|
|
65
69
|
render() {
|
|
66
70
|
const {
|
|
71
|
+
form,
|
|
67
72
|
style,
|
|
68
73
|
colSize,
|
|
69
74
|
initialValues,
|
|
70
75
|
onFinish
|
|
71
76
|
} = this.props;
|
|
72
77
|
const formItemList = this.groupsList();
|
|
73
|
-
return /*#__PURE__*/React.createElement(Form, {
|
|
74
|
-
ref: this.form,
|
|
78
|
+
return formItemList.length > 0 ? /*#__PURE__*/React.createElement(Form, {
|
|
79
|
+
ref: form || this.form,
|
|
75
80
|
style: style,
|
|
76
81
|
initialValues: initialValues,
|
|
77
82
|
onFinish: values => onFinish(values)
|
|
@@ -87,7 +92,7 @@ class searchForm extends React.Component {
|
|
|
87
92
|
span: 24 / colSize
|
|
88
93
|
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
89
94
|
noStyle: true
|
|
90
|
-
}, this.getButtons()))));
|
|
95
|
+
}, this.getButtons())))) : /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
98
|
searchForm.defaultProps = {
|
|
@@ -102,6 +107,7 @@ searchForm.defaultProps = {
|
|
|
102
107
|
onFinish: () => {}
|
|
103
108
|
};
|
|
104
109
|
searchForm.propTypes = {
|
|
110
|
+
form: PropTypes.object,
|
|
105
111
|
style: PropTypes.object,
|
|
106
112
|
expand: PropTypes.bool,
|
|
107
113
|
colSize: PropTypes.number,
|
package/SearchForm/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ class searchForm extends React.Component {
|
|
|
12
12
|
|
|
13
13
|
getButtons () {
|
|
14
14
|
const {
|
|
15
|
+
form,
|
|
15
16
|
expand,
|
|
16
17
|
formLine,
|
|
17
18
|
colSize,
|
|
@@ -31,7 +32,14 @@ class searchForm extends React.Component {
|
|
|
31
32
|
<Button
|
|
32
33
|
icon={<UndoOutlined />}
|
|
33
34
|
loading={loading}
|
|
34
|
-
onClick={() =>
|
|
35
|
+
onClick={() => {
|
|
36
|
+
form
|
|
37
|
+
? form.current.resetFields()
|
|
38
|
+
: this.form.current.resetFields();
|
|
39
|
+
onReset(form
|
|
40
|
+
? form.current.getFieldsValue()
|
|
41
|
+
: this.form.current.getFieldsValue());
|
|
42
|
+
}}
|
|
35
43
|
>
|
|
36
44
|
重置
|
|
37
45
|
</Button>
|
|
@@ -58,24 +66,24 @@ class searchForm extends React.Component {
|
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
groupsList () {
|
|
61
|
-
const arr = []
|
|
62
|
-
this.props.formLine.forEach(i=>{
|
|
69
|
+
const arr = [];
|
|
70
|
+
this.props.formLine.forEach(i => {
|
|
63
71
|
arr.push({
|
|
64
72
|
show: true,
|
|
65
73
|
node: i
|
|
66
|
-
})
|
|
67
|
-
})
|
|
74
|
+
});
|
|
75
|
+
});
|
|
68
76
|
if (this.props.expand && this.state.isOpen) {
|
|
69
77
|
return arr;
|
|
70
78
|
}
|
|
71
|
-
if(!this.props.expand && arr.length>3){
|
|
79
|
+
if (!this.props.expand && arr.length > 3) {
|
|
72
80
|
return arr;
|
|
73
81
|
}
|
|
74
|
-
arr.forEach((i,index)=> {
|
|
75
|
-
if(index>2){
|
|
76
|
-
i.show=false
|
|
82
|
+
arr.forEach((i, index) => {
|
|
83
|
+
if (index > 2) {
|
|
84
|
+
i.show = false;
|
|
77
85
|
}
|
|
78
|
-
})
|
|
86
|
+
});
|
|
79
87
|
return arr;
|
|
80
88
|
}
|
|
81
89
|
|
|
@@ -87,37 +95,44 @@ class searchForm extends React.Component {
|
|
|
87
95
|
|
|
88
96
|
render () {
|
|
89
97
|
const {
|
|
98
|
+
form,
|
|
90
99
|
style,
|
|
91
100
|
colSize,
|
|
92
101
|
initialValues,
|
|
93
102
|
onFinish
|
|
94
103
|
} = this.props;
|
|
95
104
|
const formItemList = this.groupsList();
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
return formItemList.length > 0
|
|
106
|
+
? (
|
|
107
|
+
<Form
|
|
108
|
+
ref={form || this.form}
|
|
109
|
+
style={style}
|
|
110
|
+
initialValues={initialValues}
|
|
111
|
+
onFinish={values => onFinish(values)}
|
|
112
|
+
>
|
|
113
|
+
<Row gutter={[ 16, 16 ]}>
|
|
114
|
+
{formItemList.map((item, index) => (
|
|
115
|
+
<Col
|
|
116
|
+
style={{
|
|
117
|
+
display: item.show
|
|
118
|
+
? 'block'
|
|
119
|
+
: 'none'
|
|
120
|
+
}}
|
|
121
|
+
key={index}
|
|
122
|
+
span={24 / colSize}
|
|
123
|
+
>
|
|
124
|
+
{item.node}
|
|
125
|
+
</Col>
|
|
126
|
+
))}
|
|
127
|
+
<Col span={24 / colSize}>
|
|
128
|
+
<Form.Item noStyle>
|
|
129
|
+
{this.getButtons()}
|
|
130
|
+
</Form.Item>
|
|
111
131
|
</Col>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
</Form.Item>
|
|
117
|
-
</Col>
|
|
118
|
-
</Row>
|
|
119
|
-
</Form>
|
|
120
|
-
);
|
|
132
|
+
</Row>
|
|
133
|
+
</Form>
|
|
134
|
+
)
|
|
135
|
+
: <></>;
|
|
121
136
|
}
|
|
122
137
|
}
|
|
123
138
|
|
|
@@ -128,11 +143,15 @@ searchForm.defaultProps = {
|
|
|
128
143
|
loading: false,
|
|
129
144
|
formLine: [],
|
|
130
145
|
initialValues: {},
|
|
131
|
-
onRef: () => {
|
|
132
|
-
|
|
133
|
-
|
|
146
|
+
onRef: () => {
|
|
147
|
+
},
|
|
148
|
+
onReset: () => {
|
|
149
|
+
},
|
|
150
|
+
onFinish: () => {
|
|
151
|
+
}
|
|
134
152
|
};
|
|
135
153
|
searchForm.propTypes = {
|
|
154
|
+
form: PropTypes.object,
|
|
136
155
|
style: PropTypes.object,
|
|
137
156
|
expand: PropTypes.bool,
|
|
138
157
|
colSize: PropTypes.number,
|
|
@@ -141,6 +160,6 @@ searchForm.propTypes = {
|
|
|
141
160
|
initialValues: PropTypes.object,
|
|
142
161
|
onRef: PropTypes.func,
|
|
143
162
|
onReset: PropTypes.func,
|
|
144
|
-
onFinish: PropTypes.func
|
|
163
|
+
onFinish: PropTypes.func
|
|
145
164
|
};
|
|
146
165
|
export default searchForm;
|