@cqsjjb/jjb-react-admin-component 3.3.0-beta.1 → 3.3.0-beta.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.
- package/ListDataContainer/index.js +24 -18
- package/package.json +1 -1
|
@@ -2,8 +2,8 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
import React, { useState, useEffect, useCallback, useImperativeHandle, forwardRef } from 'react';
|
|
3
3
|
import { Table, Row, Col, Form } from 'antd';
|
|
4
4
|
import { isEqual } from 'lodash';
|
|
5
|
-
import SearchForm from '
|
|
6
|
-
import ProTable from '
|
|
5
|
+
import SearchForm from '@cqsjjb/jjb-react-admin-component/SearchForm';
|
|
6
|
+
import ProTable from '@cqsjjb/jjb-react-admin-component/Table';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @component ListDataContainer
|
|
@@ -53,11 +53,10 @@ const ListDataContainer = /*#__PURE__*/forwardRef(({
|
|
|
53
53
|
searchFormConfig = [],
|
|
54
54
|
rowKey = 'id',
|
|
55
55
|
initialPagination = {
|
|
56
|
-
|
|
56
|
+
pageIndex: 1,
|
|
57
57
|
pageSize: 10,
|
|
58
58
|
showSizeChanger: true,
|
|
59
|
-
showQuickJumper: true
|
|
60
|
-
showTotal: total => `共 ${total} 条记录`
|
|
59
|
+
showQuickJumper: true
|
|
61
60
|
},
|
|
62
61
|
tableProps = {},
|
|
63
62
|
proTable = false
|
|
@@ -85,7 +84,7 @@ const ListDataContainer = /*#__PURE__*/forwardRef(({
|
|
|
85
84
|
|
|
86
85
|
// 2. 构造基础参数:分页参数 + 表单参数
|
|
87
86
|
const baseParams = {
|
|
88
|
-
|
|
87
|
+
pageIndex: pagination.pageIndex,
|
|
89
88
|
pageSize: pagination.pageSize,
|
|
90
89
|
...formValues
|
|
91
90
|
};
|
|
@@ -98,8 +97,8 @@ const ListDataContainer = /*#__PURE__*/forwardRef(({
|
|
|
98
97
|
|
|
99
98
|
// 4. 发起请求
|
|
100
99
|
const response = await fetchDataApi(requestParams);
|
|
101
|
-
setTableData(response.data
|
|
102
|
-
setTotalCount(response.
|
|
100
|
+
setTableData(response.data || []);
|
|
101
|
+
setTotalCount(response.totalCount || 0);
|
|
103
102
|
} catch (error) {
|
|
104
103
|
console.error('列表数据请求失败:', error);
|
|
105
104
|
setTableData([]);
|
|
@@ -118,9 +117,12 @@ const ListDataContainer = /*#__PURE__*/forwardRef(({
|
|
|
118
117
|
// 搜索时重置到第一页,并用表单值覆盖(values会合并到baseParams中)
|
|
119
118
|
setPagination(prev => ({
|
|
120
119
|
...prev,
|
|
121
|
-
|
|
120
|
+
pageIndex: 1
|
|
122
121
|
}));
|
|
123
|
-
loadDataSource(
|
|
122
|
+
loadDataSource({
|
|
123
|
+
...values,
|
|
124
|
+
pageIndex: 1
|
|
125
|
+
});
|
|
124
126
|
};
|
|
125
127
|
const handleReset = () => {
|
|
126
128
|
// 清空表单
|
|
@@ -133,17 +135,20 @@ const ListDataContainer = /*#__PURE__*/forwardRef(({
|
|
|
133
135
|
loadDataSource();
|
|
134
136
|
};
|
|
135
137
|
const handlePaginationChange = newPagination => {
|
|
138
|
+
console.warn("ssssssssssss", newPagination);
|
|
136
139
|
// 更新分页后,用新分页参数查询
|
|
137
|
-
setPagination(
|
|
140
|
+
setPagination({
|
|
141
|
+
...newPagination,
|
|
142
|
+
pageIndex: newPagination.current
|
|
143
|
+
});
|
|
144
|
+
loadDataSource({
|
|
145
|
+
pageIndex: newPagination.current,
|
|
146
|
+
pageSize: newPagination.pageSize
|
|
147
|
+
});
|
|
138
148
|
};
|
|
139
|
-
|
|
140
|
-
// 分页变化时自动重新加载
|
|
141
149
|
useEffect(() => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
loadDataSource();
|
|
145
|
-
}
|
|
146
|
-
}, [pagination, loadDataSource]);
|
|
150
|
+
loadDataSource();
|
|
151
|
+
}, []);
|
|
147
152
|
const generateFormItems = () => {
|
|
148
153
|
return searchFormConfig.map((item, index) => {
|
|
149
154
|
const {
|
|
@@ -193,6 +198,7 @@ const ListDataContainer = /*#__PURE__*/forwardRef(({
|
|
|
193
198
|
loading: loading,
|
|
194
199
|
pagination: {
|
|
195
200
|
...pagination,
|
|
201
|
+
current: pagination.pageIndex,
|
|
196
202
|
total: totalCount
|
|
197
203
|
},
|
|
198
204
|
onChange: handlePaginationChange,
|