@hw-component/table 0.0.5-beta-v1 → 0.0.5-beta-v3

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,9 @@
1
- import { HRowSelection } from "../modal";
2
- export declare const RowSelectionTitle: ({ allPageCheck, onChange }: HRowSelection) => JSX.Element;
1
+ import type { HRowSelection } from "../modal";
2
+ export declare const RowSelectionTitle: ({ allPageCheck, onChange, getCheckboxProps, }: HRowSelection) => JSX.Element;
3
3
  interface RowSelectionBoxProps {
4
4
  data: any;
5
5
  onChange?: HRowSelection["onChange"];
6
+ getCheckboxProps?: HRowSelection["getCheckboxProps"];
6
7
  }
7
- export declare const RowSelectionBox: ({ data, onChange }: RowSelectionBoxProps) => JSX.Element;
8
+ export declare const RowSelectionBox: ({ data, onChange, getCheckboxProps, }: RowSelectionBoxProps) => JSX.Element;
8
9
  export {};
@@ -1,5 +1,6 @@
1
1
  // welcome to hoo hoo hoo
2
2
  import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
3
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
3
4
  import _keysInstanceProperty from '@babel/runtime-corejs3/core-js/instance/keys';
4
5
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
5
6
  import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js/instance/index-of';
@@ -12,7 +13,8 @@ import { useMemo } from 'react';
12
13
  var RowSelectionTitle = function RowSelectionTitle(_ref) {
13
14
  var _ref$allPageCheck = _ref.allPageCheck,
14
15
  allPageCheck = _ref$allPageCheck === void 0 ? true : _ref$allPageCheck,
15
- onChange = _ref.onChange;
16
+ onChange = _ref.onChange,
17
+ getCheckboxProps = _ref.getCheckboxProps;
16
18
  var _useHTableContext = useHTableContext(),
17
19
  data = _useHTableContext.data,
18
20
  selectedRowData = _useHTableContext.selectedRowData,
@@ -23,14 +25,20 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
23
25
  var _ref2 = data || {},
24
26
  _ref2$records = _ref2.records,
25
27
  records = _ref2$records === void 0 ? [] : _ref2$records;
28
+ var newData = records === null || records === void 0 ? void 0 : _filterInstanceProperty(records).call(records, function (item) {
29
+ var _ref3 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
30
+ _ref3$disabled = _ref3.disabled,
31
+ disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
32
+ return !disabled;
33
+ });
26
34
  var keys = _keysInstanceProperty(selectedRowData),
27
35
  selectAll = selectedRowData.selectAll;
28
36
  var allCheck = function allCheck() {
29
- var setKeys = _mapInstanceProperty(records).call(records, function (item) {
37
+ var setKeys = _mapInstanceProperty(newData).call(newData, function (item) {
30
38
  return item[rowKey];
31
39
  });
32
- rowOnChange(setKeys, records);
33
- onChange === null || onChange === void 0 || onChange(setKeys, records);
40
+ rowOnChange(setKeys, newData);
41
+ onChange === null || onChange === void 0 || onChange(setKeys, newData);
34
42
  };
35
43
  var allCancel = function allCancel() {
36
44
  rowOnChange([], []);
@@ -44,8 +52,8 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
44
52
  }
45
53
  allCancel();
46
54
  };
47
- var change = function change(_ref3) {
48
- var key = _ref3.key;
55
+ var change = function change(_ref4) {
56
+ var key = _ref4.key;
49
57
  if (key === "check") {
50
58
  allCheck();
51
59
  return;
@@ -63,7 +71,7 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
63
71
  onChange === null || onChange === void 0 || onChange([], []);
64
72
  };
65
73
  var len = (keys === null || keys === void 0 ? void 0 : keys.length) || 0;
66
- var dataLen = (records === null || records === void 0 ? void 0 : records.length) || 0;
74
+ var dataLen = (newData === null || newData === void 0 ? void 0 : newData.length) || 0;
67
75
  var checked = len === dataLen && len !== 0;
68
76
  var configItems = useMemo(function () {
69
77
  var fsArray = checked ? {
@@ -90,6 +98,7 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
90
98
  });
91
99
  };
92
100
  var disabled = dataLen === 0;
101
+ console.log(dataLen, "dadada");
93
102
  if (allPageCheck) {
94
103
  return jsx(Dropdown, {
95
104
  overlay: menu,
@@ -109,9 +118,10 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
109
118
  disabled: disabled
110
119
  });
111
120
  };
112
- var RowSelectionBox = function RowSelectionBox(_ref4) {
113
- var data = _ref4.data,
114
- onChange = _ref4.onChange;
121
+ var RowSelectionBox = function RowSelectionBox(_ref5) {
122
+ var data = _ref5.data,
123
+ onChange = _ref5.onChange,
124
+ getCheckboxProps = _ref5.getCheckboxProps;
115
125
  var _useHTableContext2 = useHTableContext(),
116
126
  selectedRowData = _useHTableContext2.selectedRowData,
117
127
  rowOnChange = _useHTableContext2.rowOnChange,
@@ -139,9 +149,13 @@ var RowSelectionBox = function RowSelectionBox(_ref4) {
139
149
  rowOnChange(newKeys, newRowData);
140
150
  onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
141
151
  };
152
+ var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
153
+ _ref6$disabled = _ref6.disabled,
154
+ disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
142
155
  return jsx(Checkbox, {
143
156
  checked: _indexOfInstanceProperty(keys).call(keys, key) !== -1,
144
- onChange: check
157
+ onChange: check,
158
+ disabled: disabled
145
159
  });
146
160
  };
147
161
 
@@ -22,17 +22,21 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _co
22
22
  var rowSelectionCol = function rowSelectionCol(rowSelection) {
23
23
  var _ref = rowSelection || {},
24
24
  allPageCheck = _ref.allPageCheck,
25
- onChange = _ref.onChange;
25
+ onChange = _ref.onChange,
26
+ getCheckboxProps = _ref.getCheckboxProps;
26
27
  return {
27
28
  title: jsx(RowSelectionTitle, {
28
29
  allPageCheck: allPageCheck,
29
- onChange: onChange
30
+ onChange: onChange,
31
+ getCheckboxProps: getCheckboxProps
30
32
  }),
31
33
  dataIndex: "rowSelectionTitle",
32
34
  width: 32,
33
35
  render: function render(dom, data) {
34
36
  return jsx(RowSelectionBox, {
35
- data: data
37
+ data: data,
38
+ onChange: onChange,
39
+ getCheckboxProps: getCheckboxProps
36
40
  });
37
41
  }
38
42
  };
@@ -57,7 +61,7 @@ var useCols = function useCols(_ref2) {
57
61
  }
58
62
  });
59
63
  });
60
- }, [configData, table]);
64
+ }, [configData, table, rowSelection]);
61
65
  };
62
66
  var useSynchronousKeys = function useSynchronousKeys(_ref3) {
63
67
  var selectedRowKeys = _ref3.selectedRowKeys,
@@ -2,7 +2,7 @@ import type { ProTableProps } from "@ant-design/pro-table";
2
2
  import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
3
3
  import React from "react";
4
4
  import type { HTableInstance } from "../modal";
5
- import { HRowSelection } from "../modal";
5
+ import type { HRowSelection } from "../modal";
6
6
  interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
7
7
  configData?: ConfigDataModal;
8
8
  onPageChange?: (params: ParamsModal) => void;
@@ -32,7 +32,7 @@ var defaultRender = function defaultRender() {
32
32
  var contentStyle = {
33
33
  paddingLeft: 24,
34
34
  paddingRight: 24,
35
- marginBottom: 12
35
+ marginBottom: 16
36
36
  };
37
37
  var Body = (function (_ref) {
38
38
  var configData = _ref.configData,
@@ -52,7 +52,6 @@ var Body = (function (_ref) {
52
52
  actionRender = _ref.actionRender,
53
53
  props = _objectWithoutProperties(_ref, _excluded);
54
54
  var selectedRowKeys = rowSelection.selectedRowKeys;
55
- rowSelection.onChange;
56
55
  var _useHTableContext = useHTableContext(),
57
56
  tableInstance = _useHTableContext.tableInstance,
58
57
  contextConfigData = _useHTableContext.configData,
@@ -1,9 +1,11 @@
1
1
  import type { PaginationProps } from "antd";
2
2
  import type { ParamsModal } from "@/components/modal";
3
3
  import React from "react";
4
+ import type { AffixProps } from "antd/lib/affix";
4
5
  interface IPaginationProps extends PaginationProps {
5
6
  onPageChange?: (params: ParamsModal) => void;
6
7
  paginationStyle?: React.CSSProperties;
8
+ affixProps?: AffixProps | false;
7
9
  }
8
- declare const _default: ({ onPageChange, paginationStyle, ...props }: IPaginationProps) => JSX.Element;
10
+ declare const _default: ({ onPageChange, paginationStyle, affixProps, ...props }: IPaginationProps) => JSX.Element;
9
11
  export default _default;
@@ -7,22 +7,25 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/fo
7
7
  import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
8
8
  import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
9
9
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
10
- import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
11
10
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
11
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
12
12
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
13
13
  import _Number$parseInt from '@babel/runtime-corejs3/core-js/number/parse-int';
14
14
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js/instance/concat';
15
15
  import { jsx, Fragment } from 'react/jsx-runtime';
16
- import { Row, Pagination } from 'antd';
16
+ import { Row, Pagination, Affix } from 'antd';
17
17
  import { useHTableContext } from '../context.js';
18
18
  import { useClassName } from '../hooks/index.js';
19
+ import { useState } from 'react';
19
20
 
20
- var _excluded = ["onPageChange", "paginationStyle"];
21
+ var _excluded = ["onPageChange", "paginationStyle", "affixProps"],
22
+ _excluded2 = ["offsetBottom"];
21
23
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
24
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
23
25
  var HTablePagination = (function (_ref) {
24
26
  var onPageChange = _ref.onPageChange,
25
27
  paginationStyle = _ref.paginationStyle,
28
+ affixProps = _ref.affixProps,
26
29
  props = _objectWithoutProperties(_ref, _excluded);
27
30
  var _useHTableContext = useHTableContext(),
28
31
  contextOnPageChange = _useHTableContext.onPageChange,
@@ -36,7 +39,14 @@ var HTablePagination = (function (_ref) {
36
39
  var pageSize = _Number$parseInt(size || "10", 10);
37
40
  var pageTotal = _Number$parseInt(total || "0", 10);
38
41
  var className = useClassName("hw-table-pagination");
39
- if (data) {
42
+ var _useState = useState({}),
43
+ _useState2 = _slicedToArray(_useState, 2),
44
+ style = _useState2[0],
45
+ setStyle = _useState2[1];
46
+ if (!data) {
47
+ return jsx(Fragment, {});
48
+ }
49
+ if (affixProps === false) {
40
50
  return jsx(Row, {
41
51
  justify: "end",
42
52
  className: className,
@@ -63,7 +73,48 @@ var HTablePagination = (function (_ref) {
63
73
  }, props))
64
74
  });
65
75
  }
66
- return jsx(Fragment, {});
76
+ var _ref5 = affixProps || {},
77
+ _ref5$offsetBottom = _ref5.offsetBottom,
78
+ offsetBottom = _ref5$offsetBottom === void 0 ? 0 : _ref5$offsetBottom,
79
+ afProps = _objectWithoutProperties(_ref5, _excluded2);
80
+ return jsx(Affix, _objectSpread(_objectSpread({
81
+ offsetBottom: offsetBottom,
82
+ onChange: function onChange(affixed) {
83
+ if (!affixed) {
84
+ setStyle({});
85
+ return;
86
+ }
87
+ setStyle({
88
+ boxShadow: "0px -3px 10px 1px rgba(165,165,165,0.16)"
89
+ });
90
+ }
91
+ }, afProps), {}, {
92
+ children: jsx(Row, {
93
+ justify: "end",
94
+ className: className,
95
+ style: _objectSpread(_objectSpread({}, paginationStyle), style),
96
+ children: jsx(Pagination, _objectSpread({
97
+ size: "small",
98
+ showQuickJumper: true,
99
+ pageSize: pageSize,
100
+ current: pageCurrent,
101
+ showTotal: function showTotal(totalNum, _ref6) {
102
+ var _context3, _context4;
103
+ var _ref7 = _slicedToArray(_ref6, 2),
104
+ showCurrent = _ref7[0],
105
+ showCurrentEnd = _ref7[1];
106
+ return _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "\u7B2C".concat(showCurrent, "-")).call(_context4, showCurrentEnd, "/\u603B\u5171")).call(_context3, totalNum, "\u6761");
107
+ },
108
+ total: pageTotal,
109
+ onChange: function onChange(pn, ps) {
110
+ tableOnPageChange({
111
+ size: ps,
112
+ current: pn
113
+ });
114
+ }
115
+ }, props))
116
+ })
117
+ }));
67
118
  });
68
119
 
69
120
  export { HTablePagination as default };
package/es/index.css CHANGED
@@ -5,7 +5,15 @@
5
5
  overflow: hidden;
6
6
  }
7
7
  .ant-hw-table-body .ant-hw-table-pagination {
8
- padding: 0 24px 24px;
8
+ padding: 12px 24px;
9
+ background-color: #ffffff;
10
+ border-radius: 0px;
11
+ }
12
+ .ant-hw-table-body .ant-pro-card-body {
13
+ padding-bottom: 0px;
14
+ }
15
+ .ant-hw-table-body .ant-pro-table-list-toolbar-container {
16
+ padding-top: 0px;
9
17
  }
10
18
  .ant-hw-table-pagination {
11
19
  padding: 24px;
package/es/modal.d.ts CHANGED
@@ -4,7 +4,7 @@ import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal
4
4
  import type { ColProps } from "antd";
5
5
  import type React from "react";
6
6
  import type { ModalProps } from "antd";
7
- import { TableProps } from "antd/lib/table";
7
+ import type { TableProps } from "antd/lib/table";
8
8
  export interface RowObj {
9
9
  keys?: React.Key[];
10
10
  rowData?: any[];
@@ -34,7 +34,7 @@ export type actionFn = (...arg: any[]) => void;
34
34
  export interface RowSelectionOuter {
35
35
  allPageCheck?: boolean;
36
36
  }
37
- export type HRowSelection = RowSelectionOuter & (TableProps<any>['rowSelection'] & {
37
+ export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
38
38
  alwaysShowAlert?: boolean;
39
39
  });
40
40
  export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "rowKey" | "rowSelection"> {
@@ -1,8 +1,9 @@
1
- import { HRowSelection } from "../modal";
2
- export declare const RowSelectionTitle: ({ allPageCheck, onChange }: HRowSelection) => JSX.Element;
1
+ import type { HRowSelection } from "../modal";
2
+ export declare const RowSelectionTitle: ({ allPageCheck, onChange, getCheckboxProps, }: HRowSelection) => JSX.Element;
3
3
  interface RowSelectionBoxProps {
4
4
  data: any;
5
5
  onChange?: HRowSelection["onChange"];
6
+ getCheckboxProps?: HRowSelection["getCheckboxProps"];
6
7
  }
7
- export declare const RowSelectionBox: ({ data, onChange }: RowSelectionBoxProps) => JSX.Element;
8
+ export declare const RowSelectionBox: ({ data, onChange, getCheckboxProps, }: RowSelectionBoxProps) => JSX.Element;
8
9
  export {};
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
4
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
4
5
  var _keysInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/keys');
5
6
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
6
7
  var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/index-of');
@@ -13,7 +14,8 @@ var React = require('react');
13
14
  var RowSelectionTitle = function RowSelectionTitle(_ref) {
14
15
  var _ref$allPageCheck = _ref.allPageCheck,
15
16
  allPageCheck = _ref$allPageCheck === void 0 ? true : _ref$allPageCheck,
16
- onChange = _ref.onChange;
17
+ onChange = _ref.onChange,
18
+ getCheckboxProps = _ref.getCheckboxProps;
17
19
  var _useHTableContext = context.useHTableContext(),
18
20
  data = _useHTableContext.data,
19
21
  selectedRowData = _useHTableContext.selectedRowData,
@@ -24,14 +26,20 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
24
26
  var _ref2 = data || {},
25
27
  _ref2$records = _ref2.records,
26
28
  records = _ref2$records === void 0 ? [] : _ref2$records;
29
+ var newData = records === null || records === void 0 ? void 0 : _filterInstanceProperty(records).call(records, function (item) {
30
+ var _ref3 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
31
+ _ref3$disabled = _ref3.disabled,
32
+ disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
33
+ return !disabled;
34
+ });
27
35
  var keys = _keysInstanceProperty(selectedRowData),
28
36
  selectAll = selectedRowData.selectAll;
29
37
  var allCheck = function allCheck() {
30
- var setKeys = _mapInstanceProperty(records).call(records, function (item) {
38
+ var setKeys = _mapInstanceProperty(newData).call(newData, function (item) {
31
39
  return item[rowKey];
32
40
  });
33
- rowOnChange(setKeys, records);
34
- onChange === null || onChange === void 0 || onChange(setKeys, records);
41
+ rowOnChange(setKeys, newData);
42
+ onChange === null || onChange === void 0 || onChange(setKeys, newData);
35
43
  };
36
44
  var allCancel = function allCancel() {
37
45
  rowOnChange([], []);
@@ -45,8 +53,8 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
45
53
  }
46
54
  allCancel();
47
55
  };
48
- var change = function change(_ref3) {
49
- var key = _ref3.key;
56
+ var change = function change(_ref4) {
57
+ var key = _ref4.key;
50
58
  if (key === "check") {
51
59
  allCheck();
52
60
  return;
@@ -64,7 +72,7 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
64
72
  onChange === null || onChange === void 0 || onChange([], []);
65
73
  };
66
74
  var len = (keys === null || keys === void 0 ? void 0 : keys.length) || 0;
67
- var dataLen = (records === null || records === void 0 ? void 0 : records.length) || 0;
75
+ var dataLen = (newData === null || newData === void 0 ? void 0 : newData.length) || 0;
68
76
  var checked = len === dataLen && len !== 0;
69
77
  var configItems = React.useMemo(function () {
70
78
  var fsArray = checked ? {
@@ -91,6 +99,7 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
91
99
  });
92
100
  };
93
101
  var disabled = dataLen === 0;
102
+ console.log(dataLen, "dadada");
94
103
  if (allPageCheck) {
95
104
  return jsxRuntime.jsx(antd.Dropdown, {
96
105
  overlay: menu,
@@ -110,9 +119,10 @@ var RowSelectionTitle = function RowSelectionTitle(_ref) {
110
119
  disabled: disabled
111
120
  });
112
121
  };
113
- var RowSelectionBox = function RowSelectionBox(_ref4) {
114
- var data = _ref4.data,
115
- onChange = _ref4.onChange;
122
+ var RowSelectionBox = function RowSelectionBox(_ref5) {
123
+ var data = _ref5.data,
124
+ onChange = _ref5.onChange,
125
+ getCheckboxProps = _ref5.getCheckboxProps;
116
126
  var _useHTableContext2 = context.useHTableContext(),
117
127
  selectedRowData = _useHTableContext2.selectedRowData,
118
128
  rowOnChange = _useHTableContext2.rowOnChange,
@@ -140,9 +150,13 @@ var RowSelectionBox = function RowSelectionBox(_ref4) {
140
150
  rowOnChange(newKeys, newRowData);
141
151
  onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
142
152
  };
153
+ var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
154
+ _ref6$disabled = _ref6.disabled,
155
+ disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
143
156
  return jsxRuntime.jsx(antd.Checkbox, {
144
157
  checked: _indexOfInstanceProperty(keys).call(keys, key) !== -1,
145
- onChange: check
158
+ onChange: check,
159
+ disabled: disabled
146
160
  });
147
161
  };
148
162
 
@@ -23,17 +23,21 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _co
23
23
  var rowSelectionCol = function rowSelectionCol(rowSelection) {
24
24
  var _ref = rowSelection || {},
25
25
  allPageCheck = _ref.allPageCheck,
26
- onChange = _ref.onChange;
26
+ onChange = _ref.onChange,
27
+ getCheckboxProps = _ref.getCheckboxProps;
27
28
  return {
28
29
  title: jsxRuntime.jsx(RowSelection.RowSelectionTitle, {
29
30
  allPageCheck: allPageCheck,
30
- onChange: onChange
31
+ onChange: onChange,
32
+ getCheckboxProps: getCheckboxProps
31
33
  }),
32
34
  dataIndex: "rowSelectionTitle",
33
35
  width: 32,
34
36
  render: function render(dom, data) {
35
37
  return jsxRuntime.jsx(RowSelection.RowSelectionBox, {
36
- data: data
38
+ data: data,
39
+ onChange: onChange,
40
+ getCheckboxProps: getCheckboxProps
37
41
  });
38
42
  }
39
43
  };
@@ -58,7 +62,7 @@ var useCols = function useCols(_ref2) {
58
62
  }
59
63
  });
60
64
  });
61
- }, [configData, table]);
65
+ }, [configData, table, rowSelection]);
62
66
  };
63
67
  var useSynchronousKeys = function useSynchronousKeys(_ref3) {
64
68
  var selectedRowKeys = _ref3.selectedRowKeys,
@@ -2,7 +2,7 @@ import type { ProTableProps } from "@ant-design/pro-table";
2
2
  import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
3
3
  import React from "react";
4
4
  import type { HTableInstance } from "../modal";
5
- import { HRowSelection } from "../modal";
5
+ import type { HRowSelection } from "../modal";
6
6
  interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
7
7
  configData?: ConfigDataModal;
8
8
  onPageChange?: (params: ParamsModal) => void;
@@ -35,7 +35,7 @@ var defaultRender = function defaultRender() {
35
35
  var contentStyle = {
36
36
  paddingLeft: 24,
37
37
  paddingRight: 24,
38
- marginBottom: 12
38
+ marginBottom: 16
39
39
  };
40
40
  var Body = (function (_ref) {
41
41
  var configData = _ref.configData,
@@ -55,7 +55,6 @@ var Body = (function (_ref) {
55
55
  actionRender = _ref.actionRender,
56
56
  props = _objectWithoutProperties(_ref, _excluded);
57
57
  var selectedRowKeys = rowSelection.selectedRowKeys;
58
- rowSelection.onChange;
59
58
  var _useHTableContext = context.useHTableContext(),
60
59
  tableInstance = _useHTableContext.tableInstance,
61
60
  contextConfigData = _useHTableContext.configData,
@@ -1,9 +1,11 @@
1
1
  import type { PaginationProps } from "antd";
2
2
  import type { ParamsModal } from "@/components/modal";
3
3
  import React from "react";
4
+ import type { AffixProps } from "antd/lib/affix";
4
5
  interface IPaginationProps extends PaginationProps {
5
6
  onPageChange?: (params: ParamsModal) => void;
6
7
  paginationStyle?: React.CSSProperties;
8
+ affixProps?: AffixProps | false;
7
9
  }
8
- declare const _default: ({ onPageChange, paginationStyle, ...props }: IPaginationProps) => JSX.Element;
10
+ declare const _default: ({ onPageChange, paginationStyle, affixProps, ...props }: IPaginationProps) => JSX.Element;
9
11
  export default _default;
@@ -10,8 +10,8 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/
10
10
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
11
11
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
13
- var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
14
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
+ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
15
15
  var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
16
16
  var _Number$parseInt = require('@babel/runtime-corejs3/core-js/number/parse-int');
17
17
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/concat');
@@ -19,13 +19,16 @@ var jsxRuntime = require('react/jsx-runtime');
19
19
  var antd = require('antd');
20
20
  var context = require('../context.js');
21
21
  var index = require('../hooks/index.js');
22
+ var React = require('react');
22
23
 
23
- var _excluded = ["onPageChange", "paginationStyle"];
24
+ var _excluded = ["onPageChange", "paginationStyle", "affixProps"],
25
+ _excluded2 = ["offsetBottom"];
24
26
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
27
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
26
28
  var HTablePagination = (function (_ref) {
27
29
  var onPageChange = _ref.onPageChange,
28
30
  paginationStyle = _ref.paginationStyle,
31
+ affixProps = _ref.affixProps,
29
32
  props = _objectWithoutProperties(_ref, _excluded);
30
33
  var _useHTableContext = context.useHTableContext(),
31
34
  contextOnPageChange = _useHTableContext.onPageChange,
@@ -39,7 +42,14 @@ var HTablePagination = (function (_ref) {
39
42
  var pageSize = _Number$parseInt(size || "10", 10);
40
43
  var pageTotal = _Number$parseInt(total || "0", 10);
41
44
  var className = index.useClassName("hw-table-pagination");
42
- if (data) {
45
+ var _useState = React.useState({}),
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ style = _useState2[0],
48
+ setStyle = _useState2[1];
49
+ if (!data) {
50
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {});
51
+ }
52
+ if (affixProps === false) {
43
53
  return jsxRuntime.jsx(antd.Row, {
44
54
  justify: "end",
45
55
  className: className,
@@ -66,7 +76,48 @@ var HTablePagination = (function (_ref) {
66
76
  }, props))
67
77
  });
68
78
  }
69
- return jsxRuntime.jsx(jsxRuntime.Fragment, {});
79
+ var _ref5 = affixProps || {},
80
+ _ref5$offsetBottom = _ref5.offsetBottom,
81
+ offsetBottom = _ref5$offsetBottom === void 0 ? 0 : _ref5$offsetBottom,
82
+ afProps = _objectWithoutProperties(_ref5, _excluded2);
83
+ return jsxRuntime.jsx(antd.Affix, _objectSpread(_objectSpread({
84
+ offsetBottom: offsetBottom,
85
+ onChange: function onChange(affixed) {
86
+ if (!affixed) {
87
+ setStyle({});
88
+ return;
89
+ }
90
+ setStyle({
91
+ boxShadow: "0px -3px 10px 1px rgba(165,165,165,0.16)"
92
+ });
93
+ }
94
+ }, afProps), {}, {
95
+ children: jsxRuntime.jsx(antd.Row, {
96
+ justify: "end",
97
+ className: className,
98
+ style: _objectSpread(_objectSpread({}, paginationStyle), style),
99
+ children: jsxRuntime.jsx(antd.Pagination, _objectSpread({
100
+ size: "small",
101
+ showQuickJumper: true,
102
+ pageSize: pageSize,
103
+ current: pageCurrent,
104
+ showTotal: function showTotal(totalNum, _ref6) {
105
+ var _context3, _context4;
106
+ var _ref7 = _slicedToArray(_ref6, 2),
107
+ showCurrent = _ref7[0],
108
+ showCurrentEnd = _ref7[1];
109
+ return _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "\u7B2C".concat(showCurrent, "-")).call(_context4, showCurrentEnd, "/\u603B\u5171")).call(_context3, totalNum, "\u6761");
110
+ },
111
+ total: pageTotal,
112
+ onChange: function onChange(pn, ps) {
113
+ tableOnPageChange({
114
+ size: ps,
115
+ current: pn
116
+ });
117
+ }
118
+ }, props))
119
+ })
120
+ }));
70
121
  });
71
122
 
72
123
  exports.default = HTablePagination;
package/lib/index.css CHANGED
@@ -5,7 +5,15 @@
5
5
  overflow: hidden;
6
6
  }
7
7
  .ant-hw-table-body .ant-hw-table-pagination {
8
- padding: 0 24px 24px;
8
+ padding: 12px 24px;
9
+ background-color: #ffffff;
10
+ border-radius: 0px;
11
+ }
12
+ .ant-hw-table-body .ant-pro-card-body {
13
+ padding-bottom: 0px;
14
+ }
15
+ .ant-hw-table-body .ant-pro-table-list-toolbar-container {
16
+ padding-top: 0px;
9
17
  }
10
18
  .ant-hw-table-pagination {
11
19
  padding: 24px;
package/lib/modal.d.ts CHANGED
@@ -4,7 +4,7 @@ import type { HItemProps, HFormInstance } from "@hw-component/form/es/Form/modal
4
4
  import type { ColProps } from "antd";
5
5
  import type React from "react";
6
6
  import type { ModalProps } from "antd";
7
- import { TableProps } from "antd/lib/table";
7
+ import type { TableProps } from "antd/lib/table";
8
8
  export interface RowObj {
9
9
  keys?: React.Key[];
10
10
  rowData?: any[];
@@ -34,7 +34,7 @@ export type actionFn = (...arg: any[]) => void;
34
34
  export interface RowSelectionOuter {
35
35
  allPageCheck?: boolean;
36
36
  }
37
- export type HRowSelection = RowSelectionOuter & (TableProps<any>['rowSelection'] & {
37
+ export type HRowSelection = RowSelectionOuter & (TableProps<any>["rowSelection"] & {
38
38
  alwaysShowAlert?: boolean;
39
39
  });
40
40
  export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "dataSource" | "rowKey" | "rowSelection"> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "0.0.5-beta-v1",
3
+ "version": "0.0.5-beta-v3",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -1,10 +1,11 @@
1
1
  import { useHTableContext } from "../context";
2
2
  import { Checkbox, Dropdown, Menu } from "antd";
3
3
  import { useMemo } from "react";
4
- import {HRowSelection} from "../modal";
4
+ import type { HRowSelection } from "../modal";
5
5
  export const RowSelectionTitle = ({
6
6
  allPageCheck = true,
7
- onChange
7
+ onChange,
8
+ getCheckboxProps,
8
9
  }: HRowSelection) => {
9
10
  const {
10
11
  data,
@@ -14,17 +15,21 @@ export const RowSelectionTitle = ({
14
15
  rowKey = "id",
15
16
  } = useHTableContext();
16
17
  const { records = [] } = data || {};
18
+ const newData = records?.filter((item) => {
19
+ const { disabled = false } = getCheckboxProps?.(data) || {};
20
+ return !disabled;
21
+ });
17
22
  const { keys, selectAll } = selectedRowData;
18
23
  const allCheck = () => {
19
- const setKeys = records.map((item) => {
24
+ const setKeys = newData.map((item) => {
20
25
  return item[rowKey];
21
26
  });
22
- rowOnChange(setKeys, records);
23
- onChange?.(setKeys,records);
27
+ rowOnChange(setKeys, newData);
28
+ onChange?.(setKeys, newData);
24
29
  };
25
30
  const allCancel = () => {
26
31
  rowOnChange([], []);
27
- onChange?.([],[]);
32
+ onChange?.([], []);
28
33
  };
29
34
  const checkChange = (e) => {
30
35
  const checked = e.target.checked;
@@ -45,14 +50,14 @@ export const RowSelectionTitle = ({
45
50
  }
46
51
  if (key === "checkAll") {
47
52
  allSelectChange?.(true);
48
- onChange?.([],[]);
53
+ onChange?.([], []);
49
54
  return;
50
55
  }
51
56
  allSelectChange?.(false);
52
- onChange?.([],[]);
57
+ onChange?.([], []);
53
58
  };
54
- const len = keys?.length||0;
55
- const dataLen=records?.length||0;
59
+ const len = keys?.length || 0;
60
+ const dataLen = newData?.length || 0;
56
61
  const checked = len === dataLen && len !== 0;
57
62
  const configItems = useMemo(() => {
58
63
  const fsArray = checked
@@ -76,26 +81,38 @@ export const RowSelectionTitle = ({
76
81
  return [fsArray, enArray];
77
82
  }, [checked, selectAll]);
78
83
 
79
- const menu = ()=>{
80
- const MenuEle=(Menu as any);
81
- return <MenuEle onClick={change} items={configItems}/>;
82
- }
83
- const disabled=dataLen===0;
84
+ const menu = () => {
85
+ const MenuEle = Menu as any;
86
+ return <MenuEle onClick={change} items={configItems} />;
87
+ };
88
+ const disabled = dataLen === 0;
89
+ console.log(dataLen, "dadada");
84
90
  if (allPageCheck) {
85
91
  return (
86
92
  <Dropdown overlay={menu} arrow placement={"bottom"} disabled={disabled}>
87
- <Checkbox checked={checked} onChange={checkChange} disabled={disabled}/>
93
+ <Checkbox
94
+ checked={checked}
95
+ onChange={checkChange}
96
+ disabled={disabled}
97
+ />
88
98
  </Dropdown>
89
99
  );
90
100
  }
91
- return <Checkbox checked={checked} onChange={checkChange} disabled={disabled}/>;
101
+ return (
102
+ <Checkbox checked={checked} onChange={checkChange} disabled={disabled} />
103
+ );
92
104
  };
93
105
 
94
106
  interface RowSelectionBoxProps {
95
107
  data: any;
96
- onChange?:HRowSelection["onChange"]
108
+ onChange?: HRowSelection["onChange"];
109
+ getCheckboxProps?: HRowSelection["getCheckboxProps"];
97
110
  }
98
- export const RowSelectionBox = ({ data ,onChange}: RowSelectionBoxProps) => {
111
+ export const RowSelectionBox = ({
112
+ data,
113
+ onChange,
114
+ getCheckboxProps,
115
+ }: RowSelectionBoxProps) => {
99
116
  const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
100
117
  const { rowData = [], keys = [] } = selectedRowData;
101
118
  const key = data[rowKey];
@@ -107,14 +124,21 @@ export const RowSelectionBox = ({ data ,onChange}: RowSelectionBoxProps) => {
107
124
  newKeys.push(key);
108
125
  newRowData.push(data);
109
126
  rowOnChange(newKeys, newRowData);
110
- onChange?.(newKeys,newRowData);
127
+ onChange?.(newKeys, newRowData);
111
128
  return;
112
129
  }
113
130
  const index = newKeys.indexOf(key);
114
131
  newKeys.splice(index, 1);
115
132
  newRowData.splice(index, 1);
116
133
  rowOnChange(newKeys, newRowData);
117
- onChange?.(newKeys,newRowData);
134
+ onChange?.(newKeys, newRowData);
118
135
  };
119
- return <Checkbox checked={keys.indexOf(key) !== -1} onChange={check} />;
136
+ const { disabled = false } = getCheckboxProps?.(data) || {};
137
+ return (
138
+ <Checkbox
139
+ checked={keys.indexOf(key) !== -1}
140
+ onChange={check}
141
+ disabled={disabled}
142
+ />
143
+ );
120
144
  };
@@ -4,15 +4,27 @@ import { useEffect, useMemo } from "react";
4
4
  import { useHTableContext } from "../context";
5
5
  import type { GetRowKey } from "rc-table/lib/interface";
6
6
  import { RowSelectionBox, RowSelectionTitle } from "./RowSelection";
7
- import {HRowSelection} from "../modal";
8
- const rowSelectionCol = (rowSelection?:HRowSelection) => {
9
- const { allPageCheck ,onChange} = rowSelection || {};
7
+ import type { HRowSelection } from "../modal";
8
+ const rowSelectionCol = (rowSelection?: HRowSelection) => {
9
+ const { allPageCheck, onChange, getCheckboxProps } = rowSelection || {};
10
10
  return {
11
- title: <RowSelectionTitle allPageCheck={allPageCheck} onChange={onChange}/>,
11
+ title: (
12
+ <RowSelectionTitle
13
+ allPageCheck={allPageCheck}
14
+ onChange={onChange}
15
+ getCheckboxProps={getCheckboxProps}
16
+ />
17
+ ),
12
18
  dataIndex: "rowSelectionTitle",
13
19
  width: 32,
14
20
  render: (dom, data) => {
15
- return <RowSelectionBox data={data} />;
21
+ return (
22
+ <RowSelectionBox
23
+ data={data}
24
+ onChange={onChange}
25
+ getCheckboxProps={getCheckboxProps}
26
+ />
27
+ );
16
28
  },
17
29
  };
18
30
  };
@@ -34,7 +46,7 @@ export const useCols = ({ configData, rowSelection, table }: HTableProps) => {
34
46
  },
35
47
  };
36
48
  });
37
- }, [configData, table]);
49
+ }, [configData, table, rowSelection]);
38
50
  };
39
51
  interface FilterKeysModal {
40
52
  selectedRowKeys?: React.Key[];
@@ -1,18 +1,19 @@
1
1
  import type { ProTableProps } from "@ant-design/pro-table";
2
2
  import ProTable from "@ant-design/pro-table";
3
- import type {ActionRenderFn, ConfigDataModal, ParamsModal} from "../modal";
3
+ import type { ActionRenderFn, ConfigDataModal, ParamsModal } from "../modal";
4
4
  import { useCols, useSynchronousKeys } from "./hooks";
5
5
  import { useHTableContext } from "../context";
6
6
  import type { DetailedReactHTMLElement } from "react";
7
- import React from "react";
7
+ import React, { useRef } from "react";
8
8
  import { ConfigProvider, Empty, Row, Alert } from "antd";
9
9
  import type { HTableInstance } from "../modal";
10
10
  import { useHTableConfigContext } from "../TableConfig";
11
11
  import HTablePagination from "../HTablePagination";
12
12
  import { useClassName } from "../hooks";
13
13
  import AlertMsg from "./AlertMsg";
14
- import {HRowSelection} from "../modal";
15
- interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource"|"rowSelection"> {
14
+ import type { HRowSelection } from "../modal";
15
+ interface HTableBodyProps
16
+ extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
16
17
  configData?: ConfigDataModal;
17
18
  onPageChange?: (params: ParamsModal) => void;
18
19
  emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
@@ -22,8 +23,8 @@ interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource"|"ro
22
23
  ) => React.ReactNode;
23
24
  tableStyle?: React.CSSProperties;
24
25
  paginationStyle?: React.CSSProperties;
25
- actionRender?:ActionRenderFn
26
- rowSelection?:HRowSelection
26
+ actionRender?: ActionRenderFn;
27
+ rowSelection?: HRowSelection;
27
28
  }
28
29
  const defaultRender = () => {
29
30
  return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
@@ -31,7 +32,7 @@ const defaultRender = () => {
31
32
  const contentStyle = {
32
33
  paddingLeft: 24,
33
34
  paddingRight: 24,
34
- marginBottom: 12,
35
+ marginBottom: 16,
35
36
  };
36
37
  export default ({
37
38
  configData,
@@ -45,11 +46,11 @@ export default ({
45
46
  paginationStyle,
46
47
  headerTitle,
47
48
  options,
48
- actionRender,
49
+ actionRender,
49
50
  ...props
50
51
  }: HTableBodyProps) => {
51
52
  // @ts-ignore
52
- const { selectedRowKeys, onChange } = rowSelection;
53
+ const { selectedRowKeys } = rowSelection;
53
54
  const {
54
55
  tableInstance,
55
56
  configData: contextConfigData,
@@ -78,7 +79,6 @@ export default ({
78
79
 
79
80
  const alwaysShowAlert = keys.length > 0 || selectAll;
80
81
  const className = useClassName("hw-table-body");
81
-
82
82
  return (
83
83
  <div style={tableStyle} className={`hw_table_body ${className}`}>
84
84
  <ConfigProvider
@@ -99,7 +99,10 @@ export default ({
99
99
  )}
100
100
  {alwaysShowAlert && (
101
101
  <div style={contentStyle}>
102
- <Alert message={<AlertMsg actionRender={actionRender}/>} type="info" />
102
+ <Alert
103
+ message={<AlertMsg actionRender={actionRender} />}
104
+ type="info"
105
+ />
103
106
  </div>
104
107
  )}
105
108
  <ProTable
@@ -1,16 +1,19 @@
1
1
  import type { PaginationProps } from "antd";
2
- import { Button, Pagination, Row, Space, Typography } from "antd";
2
+ import { Affix, Button, Pagination, Row, Space, Typography } from "antd";
3
3
  import { useHTableContext } from "../context";
4
4
  import type { ParamsModal } from "@/components/modal";
5
5
  import { useClassName } from "../hooks";
6
- import React from "react";
6
+ import React, { useState } from "react";
7
+ import type { AffixProps } from "antd/lib/affix";
7
8
  interface IPaginationProps extends PaginationProps {
8
9
  onPageChange?: (params: ParamsModal) => void;
9
10
  paginationStyle?: React.CSSProperties;
11
+ affixProps?: AffixProps | false;
10
12
  }
11
13
  export default ({
12
14
  onPageChange,
13
15
  paginationStyle,
16
+ affixProps,
14
17
  ...props
15
18
  }: IPaginationProps) => {
16
19
  const { onPageChange: contextOnPageChange, data } = useHTableContext();
@@ -20,7 +23,11 @@ export default ({
20
23
  const pageSize = Number.parseInt(size || "10", 10);
21
24
  const pageTotal = Number.parseInt(total || "0", 10);
22
25
  const className = useClassName("hw-table-pagination");
23
- if (data) {
26
+ const [style, setStyle] = useState({});
27
+ if (!data) {
28
+ return <></>;
29
+ }
30
+ if (affixProps === false) {
24
31
  return (
25
32
  <Row justify={"end"} className={className} style={paginationStyle}>
26
33
  <Pagination
@@ -40,5 +47,41 @@ export default ({
40
47
  </Row>
41
48
  );
42
49
  }
43
- return <></>;
50
+ const { offsetBottom = 0, ...afProps } = affixProps || {};
51
+ return (
52
+ <Affix
53
+ offsetBottom={offsetBottom}
54
+ onChange={(affixed) => {
55
+ if (!affixed) {
56
+ setStyle({});
57
+ return;
58
+ }
59
+ setStyle({
60
+ boxShadow: "0px -3px 10px 1px rgba(165,165,165,0.16)",
61
+ });
62
+ }}
63
+ {...afProps}
64
+ >
65
+ <Row
66
+ justify={"end"}
67
+ className={className}
68
+ style={{ ...paginationStyle, ...style }}
69
+ >
70
+ <Pagination
71
+ size={"small"}
72
+ showQuickJumper={true}
73
+ pageSize={pageSize}
74
+ current={pageCurrent}
75
+ showTotal={(totalNum, [showCurrent, showCurrentEnd]) => {
76
+ return `第${showCurrent}-${showCurrentEnd}/总共${totalNum}条`;
77
+ }}
78
+ total={pageTotal}
79
+ onChange={(pn, ps) => {
80
+ tableOnPageChange({ size: ps, current: pn });
81
+ }}
82
+ {...props}
83
+ />
84
+ </Row>
85
+ </Affix>
86
+ );
44
87
  };
@@ -12,7 +12,7 @@ const Index: React.FC<HTableProps> = ({
12
12
  table,
13
13
  action = {},
14
14
  children,
15
- rowKey,
15
+ rowKey,
16
16
  ...props
17
17
  }) => {
18
18
  const { run, loading, data, error, saveParams } = useReq({
@@ -57,7 +57,7 @@ const Index: React.FC<HTableProps> = ({
57
57
  },
58
58
  onPageChange: tableInstance.table.reloadWithParams,
59
59
  setSelectedRowData,
60
- rowKey,
60
+ rowKey,
61
61
  }}
62
62
  >
63
63
  {children}
@@ -5,7 +5,15 @@
5
5
  background-color: #fff;
6
6
  overflow: hidden;
7
7
  .@{ant-prefix}-hw-table-pagination{
8
- padding: 0 24px 24px;
8
+ padding: 12px 24px;
9
+ background-color:#ffffff;
10
+ border-radius: 0px;
11
+ }
12
+ .@{ant-prefix}-pro-card-body{
13
+ padding-bottom: 0px;
14
+ }
15
+ .@{ant-prefix}-pro-table-list-toolbar-container{
16
+ padding-top: 0px;
9
17
  }
10
18
  }
11
19
  .@{ant-prefix}-hw-table-pagination{
@@ -7,7 +7,7 @@ import type {
7
7
  import type { ColProps } from "antd";
8
8
  import type React from "react";
9
9
  import type { ModalProps } from "antd";
10
- import {TableProps} from "antd/lib/table";
10
+ import type { TableProps } from "antd/lib/table";
11
11
 
12
12
  export interface RowObj {
13
13
  keys?: React.Key[];
@@ -58,9 +58,9 @@ export interface RowSelectionOuter {
58
58
  allPageCheck?: boolean;
59
59
  }
60
60
  export type HRowSelection = RowSelectionOuter &
61
- (TableProps<any>['rowSelection'] & {
62
- alwaysShowAlert?: boolean;
63
- })
61
+ (TableProps<any>["rowSelection"] & {
62
+ alwaysShowAlert?: boolean;
63
+ });
64
64
  export interface HTableProps
65
65
  extends Omit<
66
66
  ProTableProps<any, any>,
@@ -89,7 +89,7 @@ export interface HTableProps
89
89
  paginationStyle?: React.CSSProperties;
90
90
  rowKey?: string;
91
91
  allPageCheck?: boolean;
92
- rowSelection?: HRowSelection|false;
92
+ rowSelection?: HRowSelection | false;
93
93
  }
94
94
  export interface TableInstance {
95
95
  reload: (params?: ParamsModal) => Promise<any>;
@@ -36,22 +36,20 @@ export default () => {
36
36
  configData={configData}
37
37
  rowKey={"id"}
38
38
  table={hTable}
39
- rowSelection={{
40
-
41
- }}
39
+ rowSelection={{}}
42
40
  options={{
43
41
  reload: false,
44
42
  setting: false,
45
43
  density: false,
46
44
  }}
47
- actionRender={()=>{
48
- return <Button>你大爷</Button>
45
+ actionRender={() => {
46
+ return <Button>你大爷</Button>;
49
47
  }}
50
48
  headerTitle={<Button type={"primary"}>操作</Button>}
51
49
  request={(params) => {
52
50
  const { current = 1 } = params;
53
51
  const arrayData = [];
54
- for (let i = 0; i < 10; i = i + 1) {
52
+ for (let i = 0; i < 100; i = i + 1) {
55
53
  arrayData.push({
56
54
  id: i,
57
55
  name: "11",
@@ -65,6 +65,11 @@ export default () => {
65
65
  pagination={false}
66
66
  scroll={{ x: 1000, y: 100 }}
67
67
  headerTitle={<AddBtn />}
68
+ rowSelection={{
69
+ onChange: () => {
70
+ console.log("rowSelection");
71
+ },
72
+ }}
68
73
  />
69
74
  </Space>
70
75
  </TableCustomize>
package/src/routes.tsx CHANGED
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { Navigate } from "react-router-dom";
3
3
  import Table from "./pages/Table";
4
4
  import ModalTable from "./pages/ModalTable";
5
- import TableCustomize from './pages/TableCustomize'
5
+ import TableCustomize from "./pages/TableCustomize";
6
6
  export interface RouteModal {
7
7
  path?: string;
8
8
  name?: string;