@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.
@@ -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,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
- 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
+ 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;
@@ -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 this.props.formLine;
69
+ return arr;
63
70
  }
64
- return this.props.formLine.slice(0, this.props.colSize);
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,
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.4",
4
4
  "description": "jjb-react-admin-组件库@new",
5
5
  "main": "index.js",
6
6
  "author": "jjb-front-team",