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

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.
@@ -23,6 +23,10 @@ interface searchFormProps extends ComponentProps {
23
23
  * @description 加载中
24
24
  */
25
25
  loading?: boolean;
26
+ /**
27
+ * @description 表单默认值,只有初始化以及重置时生效
28
+ */
29
+ initialValues?:object
26
30
  /**
27
31
  * @description 组件挂载完成 通过事件返回form实例
28
32
  */
@@ -1,93 +1,97 @@
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
- };
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
+ style,
53
+ colSize,
54
+ initialValues,
55
+ onFinish
56
+ } = this.props;
57
+ const formItemList = this.groupsList();
58
+ return /*#__PURE__*/React.createElement(Form, {
59
+ ref: this.form,
60
+ style: style,
61
+ initialValues: initialValues,
62
+ onFinish: values => onFinish(values)
63
+ }, /*#__PURE__*/React.createElement(Row, {
64
+ gutter: [16, 16]
65
+ }, formItemList.map((item, index) => /*#__PURE__*/React.createElement(Col, {
66
+ key: index,
67
+ span: 24 / colSize
68
+ }, item)), /*#__PURE__*/React.createElement(Col, {
69
+ span: 24 / colSize
70
+ }, /*#__PURE__*/React.createElement(Form.Item, {
71
+ noStyle: true
72
+ }, this.getButtons()))));
73
+ }
74
+ }
75
+ searchForm.defaultProps = {
76
+ style: {},
77
+ expand: false,
78
+ colSize: 3,
79
+ loading: false,
80
+ formLine: [],
81
+ initialValues: {},
82
+ onRef: () => {},
83
+ onReset: () => {},
84
+ onFinish: () => {}
85
+ };
86
+ searchForm.propTypes = {
87
+ style: PropTypes.object,
88
+ expand: PropTypes.bool,
89
+ colSize: PropTypes.number,
90
+ loading: PropTypes.bool,
91
+ formLine: PropTypes.array,
92
+ initialValues: PropTypes.object,
93
+ onRef: PropTypes.func,
94
+ onReset: PropTypes.func,
95
+ onFinish: PropTypes.func
96
+ };
93
97
  export default searchForm;
@@ -72,8 +72,9 @@ class searchForm extends React.Component {
72
72
 
73
73
  render () {
74
74
  const {
75
- colSize,
76
75
  style,
76
+ colSize,
77
+ initialValues,
77
78
  onFinish
78
79
  } = this.props;
79
80
  const formItemList = this.groupsList();
@@ -81,6 +82,7 @@ class searchForm extends React.Component {
81
82
  <Form
82
83
  ref={this.form}
83
84
  style={style}
85
+ initialValues={initialValues}
84
86
  onFinish={values => onFinish(values)}
85
87
  >
86
88
  <Row gutter={[ 16, 16 ]}>
@@ -107,8 +109,9 @@ searchForm.defaultProps = {
107
109
  style: {},
108
110
  expand: false,
109
111
  colSize: 3,
110
- formLine: [],
111
112
  loading: false,
113
+ formLine: [],
114
+ initialValues: {},
112
115
  onRef: () => {},
113
116
  onReset: () => {},
114
117
  onFinish: () => {},
@@ -117,8 +120,9 @@ searchForm.propTypes = {
117
120
  style: PropTypes.object,
118
121
  expand: PropTypes.bool,
119
122
  colSize: PropTypes.number,
120
- formLine: PropTypes.array,
121
123
  loading: PropTypes.bool,
124
+ formLine: PropTypes.array,
125
+ initialValues: PropTypes.object,
122
126
  onRef: PropTypes.func,
123
127
  onReset: PropTypes.func,
124
128
  onFinish: PropTypes.func,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqsjjb/jjb-react-admin-component",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "jjb-react-admin-组件库@new",
5
5
  "main": "index.js",
6
6
  "author": "jjb-front-team",