@cqsjjb/jjb-react-admin-component 3.0.2 → 3.0.4
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 +4 -0
- package/SearchForm/index.js +111 -92
- package/SearchForm/index.mjs +23 -6
- package/package.json +1 -1
package/SearchForm/index.d.ts
CHANGED
package/SearchForm/index.js
CHANGED
|
@@ -1,93 +1,112 @@
|
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
+
const arr = [];
|
|
41
|
+
this.props.formLine.forEach(i => {
|
|
42
|
+
arr.push({
|
|
43
|
+
show: true,
|
|
44
|
+
node: i
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
if (this.props.expand && this.state.isOpen) {
|
|
48
|
+
return arr;
|
|
49
|
+
}
|
|
50
|
+
arr.forEach((i, index) => {
|
|
51
|
+
if (index > 2) {
|
|
52
|
+
i.show = false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return arr;
|
|
56
|
+
}
|
|
57
|
+
componentDidMount() {
|
|
58
|
+
if (this.props.onRef) {
|
|
59
|
+
this.props.onRef(this.form);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
render() {
|
|
63
|
+
const {
|
|
64
|
+
style,
|
|
65
|
+
colSize,
|
|
66
|
+
initialValues,
|
|
67
|
+
onFinish
|
|
68
|
+
} = this.props;
|
|
69
|
+
const formItemList = this.groupsList();
|
|
70
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
71
|
+
ref: this.form,
|
|
72
|
+
style: style,
|
|
73
|
+
initialValues: initialValues,
|
|
74
|
+
onFinish: values => onFinish(values)
|
|
75
|
+
}, /*#__PURE__*/React.createElement(Row, {
|
|
76
|
+
gutter: [16, 16]
|
|
77
|
+
}, formItemList.map((item, index) => /*#__PURE__*/React.createElement(Col, {
|
|
78
|
+
style: {
|
|
79
|
+
display: item.show ? 'block' : 'none'
|
|
80
|
+
},
|
|
81
|
+
key: index,
|
|
82
|
+
span: 24 / colSize
|
|
83
|
+
}, item.node)), /*#__PURE__*/React.createElement(Col, {
|
|
84
|
+
span: 24 / colSize
|
|
85
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
86
|
+
noStyle: true
|
|
87
|
+
}, this.getButtons()))));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
searchForm.defaultProps = {
|
|
91
|
+
style: {},
|
|
92
|
+
expand: false,
|
|
93
|
+
colSize: 3,
|
|
94
|
+
loading: false,
|
|
95
|
+
formLine: [],
|
|
96
|
+
initialValues: {},
|
|
97
|
+
onRef: () => {},
|
|
98
|
+
onReset: () => {},
|
|
99
|
+
onFinish: () => {}
|
|
100
|
+
};
|
|
101
|
+
searchForm.propTypes = {
|
|
102
|
+
style: PropTypes.object,
|
|
103
|
+
expand: PropTypes.bool,
|
|
104
|
+
colSize: PropTypes.number,
|
|
105
|
+
loading: PropTypes.bool,
|
|
106
|
+
formLine: PropTypes.array,
|
|
107
|
+
initialValues: PropTypes.object,
|
|
108
|
+
onRef: PropTypes.func,
|
|
109
|
+
onReset: PropTypes.func,
|
|
110
|
+
onFinish: PropTypes.func
|
|
111
|
+
};
|
|
93
112
|
export default searchForm;
|
package/SearchForm/index.mjs
CHANGED
|
@@ -58,10 +58,22 @@ class searchForm extends React.Component {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
groupsList () {
|
|
61
|
+
const arr = []
|
|
62
|
+
this.props.formLine.forEach(i=>{
|
|
63
|
+
arr.push({
|
|
64
|
+
show: true,
|
|
65
|
+
node: i
|
|
66
|
+
})
|
|
67
|
+
})
|
|
61
68
|
if (this.props.expand && this.state.isOpen) {
|
|
62
|
-
return
|
|
69
|
+
return arr;
|
|
63
70
|
}
|
|
64
|
-
|
|
71
|
+
arr.forEach((i,index)=> {
|
|
72
|
+
if(index>2){
|
|
73
|
+
i.show=false
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
return arr;
|
|
65
77
|
}
|
|
66
78
|
|
|
67
79
|
componentDidMount () {
|
|
@@ -72,8 +84,9 @@ class searchForm extends React.Component {
|
|
|
72
84
|
|
|
73
85
|
render () {
|
|
74
86
|
const {
|
|
75
|
-
colSize,
|
|
76
87
|
style,
|
|
88
|
+
colSize,
|
|
89
|
+
initialValues,
|
|
77
90
|
onFinish
|
|
78
91
|
} = this.props;
|
|
79
92
|
const formItemList = this.groupsList();
|
|
@@ -81,15 +94,17 @@ class searchForm extends React.Component {
|
|
|
81
94
|
<Form
|
|
82
95
|
ref={this.form}
|
|
83
96
|
style={style}
|
|
97
|
+
initialValues={initialValues}
|
|
84
98
|
onFinish={values => onFinish(values)}
|
|
85
99
|
>
|
|
86
100
|
<Row gutter={[ 16, 16 ]}>
|
|
87
101
|
{formItemList.map((item, index) => (
|
|
88
102
|
<Col
|
|
103
|
+
style={{display:item.show?'block':'none'}}
|
|
89
104
|
key={index}
|
|
90
105
|
span={24 / colSize}
|
|
91
106
|
>
|
|
92
|
-
{item}
|
|
107
|
+
{item.node}
|
|
93
108
|
</Col>
|
|
94
109
|
))}
|
|
95
110
|
<Col span={24 / colSize}>
|
|
@@ -107,8 +122,9 @@ searchForm.defaultProps = {
|
|
|
107
122
|
style: {},
|
|
108
123
|
expand: false,
|
|
109
124
|
colSize: 3,
|
|
110
|
-
formLine: [],
|
|
111
125
|
loading: false,
|
|
126
|
+
formLine: [],
|
|
127
|
+
initialValues: {},
|
|
112
128
|
onRef: () => {},
|
|
113
129
|
onReset: () => {},
|
|
114
130
|
onFinish: () => {},
|
|
@@ -117,8 +133,9 @@ searchForm.propTypes = {
|
|
|
117
133
|
style: PropTypes.object,
|
|
118
134
|
expand: PropTypes.bool,
|
|
119
135
|
colSize: PropTypes.number,
|
|
120
|
-
formLine: PropTypes.array,
|
|
121
136
|
loading: PropTypes.bool,
|
|
137
|
+
formLine: PropTypes.array,
|
|
138
|
+
initialValues: PropTypes.object,
|
|
122
139
|
onRef: PropTypes.func,
|
|
123
140
|
onReset: PropTypes.func,
|
|
124
141
|
onFinish: PropTypes.func,
|