@lemon-fe/kits 0.1.154 → 0.1.155

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.
@@ -6,6 +6,7 @@ export default function useBatchOperate<RecordType = Record<string, any>, Result
6
6
  modalTitle: string;
7
7
  handler: (record: RecordType) => Promise<string | void | ResultType>;
8
8
  columns?: ColumnType<RecordType>[];
9
+ needPagination?: boolean;
9
10
  rowKey?: BaseTableProps<RecordType>['rowKey'];
10
11
  onClose?: (results: Map<Key, Result<ResultType>>) => void;
11
12
  /** 弹窗关闭前的检验,返回true校验通过关闭弹窗,false校验不通过 */
@@ -27,7 +27,8 @@ export default function useBatchOperate(options) {
27
27
  onClose = options.onClose,
28
28
  onBeforeClose = options.onBeforeClose,
29
29
  rowKey = options.rowKey,
30
- renderResult = options.renderResult;
30
+ renderResult = options.renderResult,
31
+ needPagination = options.needPagination;
31
32
  var _useState = useState(false),
32
33
  _useState2 = _slicedToArray(_useState, 2),
33
34
  visible = _useState2[0],
@@ -48,6 +49,15 @@ export default function useBatchOperate(options) {
48
49
  _useState10 = _slicedToArray(_useState9, 2),
49
50
  paused = _useState10[0],
50
51
  setPaused = _useState10[1];
52
+ var _useState11 = useState({
53
+ pageSize: 50,
54
+ current: 1
55
+ }),
56
+ _useState12 = _slicedToArray(_useState11, 2),
57
+ pagination = _useState12[0],
58
+ setPagination = _useState12[1];
59
+ var paginationRef = useRef(pagination);
60
+ paginationRef.current = pagination;
51
61
  var mounted = useRef(false);
52
62
  var pausedRef = useRef(paused);
53
63
  pausedRef.current = paused;
@@ -71,7 +81,9 @@ export default function useBatchOperate(options) {
71
81
  title: '编号',
72
82
  key: 'id',
73
83
  dataIndex: typeof rowKey === 'string' ? rowKey : undefined,
74
- render: function render(_, record, index) {
84
+ render: function render(_, record, dataIndex) {
85
+ var pagination = paginationRef.current;
86
+ var index = dataIndex + (pagination.current - 1) * pagination.pageSize;
75
87
  return getRowKey(record, index);
76
88
  }
77
89
  }];
@@ -79,10 +91,12 @@ export default function useBatchOperate(options) {
79
91
  title: '',
80
92
  key: 'delete',
81
93
  width: 32,
82
- render: function render(_, record, index) {
83
- var key = getRowKey(record, index);
94
+ render: function render(_, record, dataIndex) {
84
95
  return /*#__PURE__*/React.createElement(DeleteTwoTone, {
85
96
  onClick: function onClick() {
97
+ var pagination = paginationRef.current;
98
+ var index = dataIndex + (pagination.current - 1) * pagination.pageSize;
99
+ var key = getRowKey(record, index);
86
100
  if (!paused) {
87
101
  return;
88
102
  }
@@ -113,7 +127,9 @@ export default function useBatchOperate(options) {
113
127
  title: '状态',
114
128
  key: 'status',
115
129
  width: 'auto',
116
- render: function render(_, record, index) {
130
+ render: function render(_, record, dataIndex) {
131
+ var pagination = paginationRef.current;
132
+ var index = dataIndex + (pagination.current - 1) * pagination.pageSize;
117
133
  var key = getRowKey(record, index);
118
134
  var result = results.get(key);
119
135
  if (active === index && !paused || result === loading) {
@@ -349,7 +365,13 @@ export default function useBatchOperate(options) {
349
365
  scroll: {
350
366
  y: true
351
367
  },
352
- pagination: false,
368
+ pagination: needPagination ? pagination : false,
369
+ onChange: function onChange(val) {
370
+ setPagination({
371
+ current: val.current || 1,
372
+ pageSize: val.pageSize || 50
373
+ });
374
+ },
353
375
  dataSource: data,
354
376
  columns: mCols,
355
377
  rowKey: rowKey
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "0.1.154",
3
+ "version": "0.1.155",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -32,5 +32,5 @@
32
32
  "scripts": {
33
33
  "test": "echo \"Error: run tests from root\" && exit 1"
34
34
  },
35
- "gitHead": "2037f3d0336b2b3a0ba2cd326f89a605330c170e"
35
+ "gitHead": "c7dcc1d54c50fe5674a23ec4de7d9206c49a7a14"
36
36
  }