@yeeyoon/library 2.8.1 → 2.8.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.
@@ -1,8 +1,15 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import ProTable from '@ant-design/pro-table';
4
4
  import { mergeTableColumnCommonConfig } from '../../../utils/utils';
5
5
 
6
+ let paginationData = {
7
+ current: 1,
8
+ pageSize: 10,
9
+ };
10
+ let sortData = {};
11
+ let filterData = {};
12
+
6
13
  const CommonTable = (props) => {
7
14
  const {
8
15
  data,
@@ -10,9 +17,17 @@ const CommonTable = (props) => {
10
17
  paginationKey = ['each_page', 'current_page'],
11
18
  systemTags = [],
12
19
  } = props;
20
+ const [paginationCurrent, setPaginationCurrent] = useState(1);
13
21
  const { rowKey, columns, reqFunc, reqParams, reqCbFn, ...rest } = data;
14
- let sortData = {};
15
- let filterData = {};
22
+ useEffect(() => {
23
+ paginationData = {
24
+ current: 1,
25
+ pageSize: 10,
26
+ };
27
+ sortData = {};
28
+ filterData = {};
29
+ }, [columns]);
30
+
16
31
  return (
17
32
  <ProTable
18
33
  rowKey={(record) => record[rowKey]}
@@ -20,6 +35,7 @@ const CommonTable = (props) => {
20
35
  pagination={{
21
36
  position: ['bottomCenter'],
22
37
  pageSize: 10,
38
+ current: paginationCurrent,
23
39
  }}
24
40
  options={false}
25
41
  scroll={{
@@ -29,8 +45,8 @@ const CommonTable = (props) => {
29
45
  if (typeof reqFunc !== 'function') return;
30
46
  const { current, pageSize, ...rest } = params;
31
47
  const resp = await reqFunc({
32
- [paginationKey[0]]: pageSize,
33
- [paginationKey[1]]: current,
48
+ [paginationKey[0]]: paginationData.pageSize || pageSize,
49
+ [paginationKey[1]]: paginationData.current || current,
34
50
  ...rest,
35
51
  ...reqParams,
36
52
  ...sortData,
@@ -46,6 +62,12 @@ const CommonTable = (props) => {
46
62
  };
47
63
  }}
48
64
  onChange={(pagination, filters, sorter) => {
65
+ // console.log(pagination, filters, sorter, 'xxxxxxxx');
66
+ if (pagination) {
67
+ const { current, pageSize } = pagination;
68
+ setPaginationCurrent(current);
69
+ paginationData = { current, pageSize };
70
+ }
49
71
  if (filters) {
50
72
  Object.keys(filters).forEach((key) => {
51
73
  if (filters[key]) {
@@ -58,7 +80,7 @@ const CommonTable = (props) => {
58
80
  ...filterData,
59
81
  }),
60
82
  };
61
- rest.actionRef && rest.actionRef.current.reloadAndRest();
83
+ rest.actionRef && rest.actionRef.current.reload();
62
84
  }
63
85
  if (sorter.field) {
64
86
  const { field, order, column } = sorter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeeyoon/library",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "description": "宜云前端组件库和通用服务",
5
5
  "main": "index.js",
6
6
  "repository": {