@hw-component/table 0.0.9-beta-v8 → 0.0.9-beta-v11
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/.eslintcache +1 -1
- package/es/HTableBody/HeaderTitle/index.d.ts +1 -1
- package/es/HTableBody/HeaderTitle/index.js +1 -1
- package/es/HTableBody/index.d.ts +2 -1
- package/es/HTableBody/index.js +6 -2
- package/es/HTableHeader/hooks.d.ts +1 -1
- package/es/HTableHeader/modal.d.ts +1 -1
- package/es/HTablePagination/index.d.ts +1 -1
- package/es/modal.d.ts +1 -0
- package/lib/HTableBody/HeaderTitle/index.d.ts +1 -1
- package/lib/HTableBody/HeaderTitle/index.js +1 -1
- package/lib/HTableBody/index.d.ts +2 -1
- package/lib/HTableBody/index.js +6 -2
- package/lib/HTableHeader/hooks.d.ts +1 -1
- package/lib/HTableHeader/modal.d.ts +1 -1
- package/lib/HTablePagination/index.d.ts +1 -1
- package/lib/modal.d.ts +1 -0
- package/package.json +2 -2
- package/src/app.tsx +20 -20
- package/src/components/HTableBody/HeaderTitle/index.tsx +27 -27
- package/src/components/HTableBody/index.tsx +22 -8
- package/src/components/HTableHeader/hooks.tsx +36 -24
- package/src/components/HTableHeader/index.tsx +1 -1
- package/src/components/HTableHeader/modal.ts +3 -3
- package/src/components/HTablePagination/index.tsx +15 -10
- package/src/components/Table.tsx +1 -1
- package/src/components/TableCustomize.tsx +2 -2
- package/src/components/modal.ts +8 -2
- package/src/pages/Table/index.tsx +9 -8
|
@@ -14,7 +14,7 @@ var HeaderTitle = (function (_ref) {
|
|
|
14
14
|
selectedRowData = _useHTableContext.selectedRowData,
|
|
15
15
|
rowOnChange = _useHTableContext.rowOnChange,
|
|
16
16
|
allSelectChange = _useHTableContext.allSelectChange;
|
|
17
|
-
var headerBox = useClassName(
|
|
17
|
+
var headerBox = useClassName("hw-table-header-title-box");
|
|
18
18
|
if (!headerTitle && !rNode) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
package/es/HTableBody/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSour
|
|
|
17
17
|
goTop?: boolean;
|
|
18
18
|
optionsRender?: (node: React.ReactNode) => React.ReactNode;
|
|
19
19
|
paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
20
|
+
localSorter?: boolean;
|
|
20
21
|
}
|
|
21
|
-
declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, size, optionsRender, paginationActionRender, ...props }: HTableBodyProps) => JSX.Element;
|
|
22
|
+
declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, size, optionsRender, paginationActionRender, localSorter, ...props }: HTableBodyProps) => JSX.Element;
|
|
22
23
|
export default _default;
|
package/es/HTableBody/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import AlertMsg from './AlertMsg.js';
|
|
|
22
22
|
import Options from './Options/index.js';
|
|
23
23
|
import HeaderTitle from './HeaderTitle/index.js';
|
|
24
24
|
|
|
25
|
-
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender", "paginationActionRender"];
|
|
25
|
+
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender", "paginationActionRender", "localSorter"];
|
|
26
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; }
|
|
27
27
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
28
28
|
var defaultRender = function defaultRender() {
|
|
@@ -57,6 +57,7 @@ var Body = (function (_ref) {
|
|
|
57
57
|
size = _ref.size,
|
|
58
58
|
optionsRender = _ref.optionsRender,
|
|
59
59
|
paginationActionRender = _ref.paginationActionRender,
|
|
60
|
+
localSorter = _ref.localSorter,
|
|
60
61
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
61
62
|
var _ref2 = rowSelection || {},
|
|
62
63
|
selectedRowKeys = _ref2.selectedRowKeys,
|
|
@@ -138,7 +139,10 @@ var Body = (function (_ref) {
|
|
|
138
139
|
columns: cols,
|
|
139
140
|
size: cuSize,
|
|
140
141
|
search: false,
|
|
141
|
-
onChange: function onChange(
|
|
142
|
+
onChange: function onChange(page, filters, sorter) {
|
|
143
|
+
if (localSorter) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
142
146
|
var field = sorter.field,
|
|
143
147
|
order = sorter.order;
|
|
144
148
|
tableInstance.table.reloadWithParams({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IHeaderProps } from "./modal";
|
|
2
2
|
import type { HItemProps } from "@hw-component/form/es/Form/modal";
|
|
3
|
-
export declare const useHideMoreTitle: ({ searchSpan, configData, table }: IHeaderProps) => HItemProps[];
|
|
3
|
+
export declare const useHideMoreTitle: ({ searchSpan, configData, table, }: IHeaderProps) => HItemProps[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConfigDataModal, ConfigItemModal } from "../modal";
|
|
2
2
|
import type { ColProps } from "antd";
|
|
3
3
|
import type React from "react";
|
|
4
|
-
import { HTableInstance } from "../modal";
|
|
4
|
+
import type { HTableInstance } from "../modal";
|
|
5
5
|
export interface IHeaderProps {
|
|
6
6
|
configData?: ConfigDataModal;
|
|
7
7
|
onFinish?: (value: Record<string, any>) => Promise<any>;
|
|
@@ -2,7 +2,7 @@ import type { PaginationProps } from "antd";
|
|
|
2
2
|
import type { ParamsModal } from "../modal";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import type { AffixProps } from "antd/lib/affix";
|
|
5
|
-
import { HTableInstance } from "../modal";
|
|
5
|
+
import type { HTableInstance } from "../modal";
|
|
6
6
|
export interface IPaginationProps extends PaginationProps {
|
|
7
7
|
onPageChange?: (params: ParamsModal) => void;
|
|
8
8
|
paginationStyle?: React.CSSProperties;
|
package/es/modal.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
|
|
|
71
71
|
optionsRender?: (node: React.ReactNode) => React.ReactNode;
|
|
72
72
|
onFinish?: (value: any) => Promise<any>;
|
|
73
73
|
paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
74
|
+
localSorter?: boolean;
|
|
74
75
|
}
|
|
75
76
|
export interface TableInstance {
|
|
76
77
|
reload: (params?: ParamsModal) => Promise<any>;
|
|
@@ -17,7 +17,7 @@ var HeaderTitle = (function (_ref) {
|
|
|
17
17
|
selectedRowData = _useHTableContext.selectedRowData,
|
|
18
18
|
rowOnChange = _useHTableContext.rowOnChange,
|
|
19
19
|
allSelectChange = _useHTableContext.allSelectChange;
|
|
20
|
-
var headerBox = index.useClassName(
|
|
20
|
+
var headerBox = index.useClassName("hw-table-header-title-box");
|
|
21
21
|
if (!headerTitle && !rNode) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
@@ -17,6 +17,7 @@ export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSour
|
|
|
17
17
|
goTop?: boolean;
|
|
18
18
|
optionsRender?: (node: React.ReactNode) => React.ReactNode;
|
|
19
19
|
paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
20
|
+
localSorter?: boolean;
|
|
20
21
|
}
|
|
21
|
-
declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, size, optionsRender, paginationActionRender, ...props }: HTableBodyProps) => JSX.Element;
|
|
22
|
+
declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, size, optionsRender, paginationActionRender, localSorter, ...props }: HTableBodyProps) => JSX.Element;
|
|
22
23
|
export default _default;
|
package/lib/HTableBody/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var AlertMsg = require('./AlertMsg.js');
|
|
|
25
25
|
var index = require('./Options/index.js');
|
|
26
26
|
var index$2 = require('./HeaderTitle/index.js');
|
|
27
27
|
|
|
28
|
-
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender", "paginationActionRender"];
|
|
28
|
+
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender", "paginationActionRender", "localSorter"];
|
|
29
29
|
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; }
|
|
30
30
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
31
|
var defaultRender = function defaultRender() {
|
|
@@ -60,6 +60,7 @@ var Body = (function (_ref) {
|
|
|
60
60
|
size = _ref.size,
|
|
61
61
|
optionsRender = _ref.optionsRender,
|
|
62
62
|
paginationActionRender = _ref.paginationActionRender,
|
|
63
|
+
localSorter = _ref.localSorter,
|
|
63
64
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
64
65
|
var _ref2 = rowSelection || {},
|
|
65
66
|
selectedRowKeys = _ref2.selectedRowKeys,
|
|
@@ -141,7 +142,10 @@ var Body = (function (_ref) {
|
|
|
141
142
|
columns: cols,
|
|
142
143
|
size: cuSize,
|
|
143
144
|
search: false,
|
|
144
|
-
onChange: function onChange(
|
|
145
|
+
onChange: function onChange(page, filters, sorter) {
|
|
146
|
+
if (localSorter) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
145
149
|
var field = sorter.field,
|
|
146
150
|
order = sorter.order;
|
|
147
151
|
tableInstance.table.reloadWithParams({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IHeaderProps } from "./modal";
|
|
2
2
|
import type { HItemProps } from "@hw-component/form/es/Form/modal";
|
|
3
|
-
export declare const useHideMoreTitle: ({ searchSpan, configData, table }: IHeaderProps) => HItemProps[];
|
|
3
|
+
export declare const useHideMoreTitle: ({ searchSpan, configData, table, }: IHeaderProps) => HItemProps[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConfigDataModal, ConfigItemModal } from "../modal";
|
|
2
2
|
import type { ColProps } from "antd";
|
|
3
3
|
import type React from "react";
|
|
4
|
-
import { HTableInstance } from "../modal";
|
|
4
|
+
import type { HTableInstance } from "../modal";
|
|
5
5
|
export interface IHeaderProps {
|
|
6
6
|
configData?: ConfigDataModal;
|
|
7
7
|
onFinish?: (value: Record<string, any>) => Promise<any>;
|
|
@@ -2,7 +2,7 @@ import type { PaginationProps } from "antd";
|
|
|
2
2
|
import type { ParamsModal } from "../modal";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import type { AffixProps } from "antd/lib/affix";
|
|
5
|
-
import { HTableInstance } from "../modal";
|
|
5
|
+
import type { HTableInstance } from "../modal";
|
|
6
6
|
export interface IPaginationProps extends PaginationProps {
|
|
7
7
|
onPageChange?: (params: ParamsModal) => void;
|
|
8
8
|
paginationStyle?: React.CSSProperties;
|
package/lib/modal.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
|
|
|
71
71
|
optionsRender?: (node: React.ReactNode) => React.ReactNode;
|
|
72
72
|
onFinish?: (value: any) => Promise<any>;
|
|
73
73
|
paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
74
|
+
localSorter?: boolean;
|
|
74
75
|
}
|
|
75
76
|
export interface TableInstance {
|
|
76
77
|
reload: (params?: ParamsModal) => Promise<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/table",
|
|
3
|
-
"version": "0.0.9-beta-
|
|
3
|
+
"version": "0.0.9-beta-v11",
|
|
4
4
|
"description": "基于antd二次开发table组件",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"table"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@ant-design/icons": "4.6.2",
|
|
33
33
|
"@ant-design/pro-table": "2.70.0",
|
|
34
|
-
"@hw-component/form": "1.0.
|
|
34
|
+
"@hw-component/form": "1.0.8",
|
|
35
35
|
"ahooks": "2.10.9",
|
|
36
36
|
"antd": "4.20.7",
|
|
37
37
|
"core-js": "3",
|
package/src/app.tsx
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import routes from "./routes";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
createBrowserRouter,
|
|
5
|
+
Navigate,
|
|
6
|
+
RouterProvider,
|
|
7
|
+
useRouteError,
|
|
8
8
|
} from "react-router-dom";
|
|
9
9
|
import type { RouteObject } from "react-router";
|
|
10
10
|
import Layout from "./Layout";
|
|
11
11
|
const Error = () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const error = useRouteError();
|
|
13
|
+
if (error.status === 404) {
|
|
14
|
+
return <Navigate to="/form/select" replace />;
|
|
15
|
+
}
|
|
16
|
+
return <div>错误</div>;
|
|
17
17
|
};
|
|
18
18
|
const rootRoute = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
{
|
|
20
|
+
path: "/",
|
|
21
|
+
element: <Layout />,
|
|
22
|
+
errorElement: <Error />,
|
|
23
|
+
children: routes,
|
|
24
|
+
},
|
|
25
25
|
];
|
|
26
26
|
const router = () => {
|
|
27
|
-
|
|
27
|
+
return createBrowserRouter(rootRoute as RouteObject[]);
|
|
28
28
|
};
|
|
29
29
|
export default () => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
30
|
+
return (
|
|
31
|
+
<RouterProvider router={router()} fallbackElement={<p>Loading...</p>} />
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {Row, Space} from "antd";
|
|
2
|
-
import {HTableBodyProps} from "../index";
|
|
3
|
-
import
|
|
1
|
+
import { Row, Space } from "antd";
|
|
2
|
+
import type { HTableBodyProps } from "../index";
|
|
3
|
+
import type { DetailedReactHTMLElement } from "react";
|
|
4
|
+
import React from "react";
|
|
4
5
|
import { useHTableContext } from "../../context";
|
|
5
|
-
import {useClassName} from "../../hooks";
|
|
6
|
+
import { useClassName } from "../../hooks";
|
|
6
7
|
interface IProps {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
headerTitle: HTableBodyProps["headerTitle"];
|
|
9
|
+
contentStyle?: React.CSSProperties;
|
|
10
|
+
rNode?: React.ReactNode;
|
|
10
11
|
}
|
|
11
|
-
export default ({headerTitle,contentStyle,rNode}:IProps)=>{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</div>
|
|
29
|
-
{rNode&&rNode}
|
|
12
|
+
export default ({ headerTitle, contentStyle, rNode }: IProps) => {
|
|
13
|
+
const { tableInstance, selectedRowData, rowOnChange, allSelectChange } =
|
|
14
|
+
useHTableContext();
|
|
15
|
+
const headerBox = useClassName("hw-table-header-title-box");
|
|
16
|
+
if (!headerTitle && !rNode) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return (
|
|
20
|
+
<Row justify={"space-between"} align={"middle"} style={contentStyle}>
|
|
21
|
+
<div className={headerBox}>
|
|
22
|
+
{headerTitle &&
|
|
23
|
+
React.cloneElement(
|
|
24
|
+
headerTitle as DetailedReactHTMLElement<any, any>,
|
|
25
|
+
{ selectedRowData, allSelectChange, rowOnChange, tableInstance }
|
|
26
|
+
)}
|
|
27
|
+
</div>
|
|
28
|
+
{rNode && rNode}
|
|
30
29
|
</Row>
|
|
31
|
-
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -13,7 +13,7 @@ import AlertMsg from "./AlertMsg";
|
|
|
13
13
|
import type { HRowSelection } from "../modal";
|
|
14
14
|
import type { AffixProps } from "antd/lib/affix";
|
|
15
15
|
import Options from "./Options";
|
|
16
|
-
import HeaderTitle from
|
|
16
|
+
import HeaderTitle from "./HeaderTitle";
|
|
17
17
|
export interface HTableBodyProps
|
|
18
18
|
extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection"> {
|
|
19
19
|
configData?: ConfigDataModal;
|
|
@@ -31,7 +31,7 @@ export interface HTableBodyProps
|
|
|
31
31
|
goTop?: boolean;
|
|
32
32
|
optionsRender?: (node: React.ReactNode) => React.ReactNode;
|
|
33
33
|
paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
34
|
-
|
|
34
|
+
localSorter?: boolean;
|
|
35
35
|
}
|
|
36
36
|
const defaultRender = () => {
|
|
37
37
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
|
@@ -58,7 +58,8 @@ export default ({
|
|
|
58
58
|
goTop = true,
|
|
59
59
|
size,
|
|
60
60
|
optionsRender,
|
|
61
|
-
|
|
61
|
+
paginationActionRender,
|
|
62
|
+
localSorter,
|
|
62
63
|
...props
|
|
63
64
|
}: HTableBodyProps) => {
|
|
64
65
|
// @ts-ignore
|
|
@@ -100,7 +101,9 @@ export default ({
|
|
|
100
101
|
/>
|
|
101
102
|
);
|
|
102
103
|
const { keys = [], selectAll } = selectedRowData;
|
|
103
|
-
const defaultOptionsNode=
|
|
104
|
+
const defaultOptionsNode = optionsRender
|
|
105
|
+
? optionsRender(optionsNode)
|
|
106
|
+
: optionsNode;
|
|
104
107
|
const alwaysShowAlert = keys.length > 0 || selectAll || configAlwaysShowAlert;
|
|
105
108
|
const className = useClassName("hw-table-body");
|
|
106
109
|
return (
|
|
@@ -113,7 +116,11 @@ export default ({
|
|
|
113
116
|
/>
|
|
114
117
|
</div>
|
|
115
118
|
)}
|
|
116
|
-
<HeaderTitle
|
|
119
|
+
<HeaderTitle
|
|
120
|
+
headerTitle={headerTitle}
|
|
121
|
+
contentStyle={contentStyle}
|
|
122
|
+
rNode={defaultOptionsNode}
|
|
123
|
+
/>
|
|
117
124
|
<ConfigProvider
|
|
118
125
|
renderEmpty={() => {
|
|
119
126
|
if (error) {
|
|
@@ -127,9 +134,16 @@ export default ({
|
|
|
127
134
|
columns={cols as any}
|
|
128
135
|
size={cuSize}
|
|
129
136
|
search={false}
|
|
130
|
-
onChange={(
|
|
131
|
-
|
|
132
|
-
|
|
137
|
+
onChange={(page, filters, sorter) => {
|
|
138
|
+
if (localSorter) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const { field, order } = sorter as any;
|
|
142
|
+
tableInstance.table.reloadWithParams({
|
|
143
|
+
current: 1,
|
|
144
|
+
orderByField: field,
|
|
145
|
+
asc: order === "ascend",
|
|
146
|
+
});
|
|
133
147
|
}}
|
|
134
148
|
options={false}
|
|
135
149
|
tableStyle={{
|
|
@@ -6,7 +6,7 @@ import { useClassName } from "../hooks";
|
|
|
6
6
|
import type { HFormInstance } from "@hw-component/form/es/Form/modal";
|
|
7
7
|
import { DefaultSubComponent } from "../HTableHeader/defaultSubComponent";
|
|
8
8
|
import { useHTableContext } from "../context";
|
|
9
|
-
import {HTableInstance} from "@/components/modal";
|
|
9
|
+
import type { HTableInstance } from "@/components/modal";
|
|
10
10
|
const sizeObj = {
|
|
11
11
|
xl: {
|
|
12
12
|
min: 1200,
|
|
@@ -56,20 +56,23 @@ const getCuSpanMaxNum = (searchSpan: ColProps = { span: 6 }) => {
|
|
|
56
56
|
const cuSpan = searchSpan[cuKey] || searchSpan.span;
|
|
57
57
|
return 24 / cuSpan;
|
|
58
58
|
};
|
|
59
|
-
const formConfigDataItemProvider = (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
const formConfigDataItemProvider = (
|
|
60
|
+
{
|
|
61
|
+
colon = false,
|
|
62
|
+
searchType,
|
|
63
|
+
title,
|
|
64
|
+
name,
|
|
65
|
+
dataIndex,
|
|
66
|
+
itemProps = {},
|
|
67
|
+
searchRender,
|
|
68
|
+
childrenDataIndex,
|
|
69
|
+
showSearch,
|
|
70
|
+
hideInTable,
|
|
71
|
+
align,
|
|
72
|
+
...props
|
|
73
|
+
}: FormConfigDataItemProviderModal,
|
|
74
|
+
table: HTableInstance
|
|
75
|
+
): HItemProps => {
|
|
73
76
|
const { allowClear = true } = itemProps as any;
|
|
74
77
|
return {
|
|
75
78
|
...props,
|
|
@@ -81,15 +84,15 @@ const formConfigDataItemProvider = ({
|
|
|
81
84
|
colon,
|
|
82
85
|
type: searchType,
|
|
83
86
|
name: name || (dataIndex as string),
|
|
84
|
-
render:(item,node,form)=>{
|
|
85
|
-
if (searchRender){
|
|
86
|
-
|
|
87
|
+
render: (item, node, form) => {
|
|
88
|
+
if (searchRender) {
|
|
89
|
+
return searchRender(item, node, form, table);
|
|
87
90
|
}
|
|
88
|
-
return
|
|
91
|
+
return node;
|
|
89
92
|
},
|
|
90
93
|
};
|
|
91
94
|
};
|
|
92
|
-
const mkNewConfig = ({ configData = []
|
|
95
|
+
const mkNewConfig = ({ configData = [], table }: IHeaderProps) => {
|
|
93
96
|
let subConfigData: HItemProps | undefined;
|
|
94
97
|
const realConfigData: HItemProps[] = [];
|
|
95
98
|
configData.forEach((value) => {
|
|
@@ -98,10 +101,15 @@ const mkNewConfig = ({ configData = [] ,table}: IHeaderProps) => {
|
|
|
98
101
|
return false;
|
|
99
102
|
}
|
|
100
103
|
if (searchType === "submit") {
|
|
101
|
-
subConfigData = formConfigDataItemProvider(
|
|
104
|
+
subConfigData = formConfigDataItemProvider(
|
|
105
|
+
value,
|
|
106
|
+
table as HTableInstance
|
|
107
|
+
);
|
|
102
108
|
return false;
|
|
103
109
|
}
|
|
104
|
-
realConfigData.push(
|
|
110
|
+
realConfigData.push(
|
|
111
|
+
formConfigDataItemProvider(value, table as HTableInstance)
|
|
112
|
+
);
|
|
105
113
|
});
|
|
106
114
|
return {
|
|
107
115
|
realConfigData,
|
|
@@ -136,7 +144,11 @@ const filterHideFormItem = (
|
|
|
136
144
|
hideData,
|
|
137
145
|
};
|
|
138
146
|
};
|
|
139
|
-
export const useHideMoreTitle = ({
|
|
147
|
+
export const useHideMoreTitle = ({
|
|
148
|
+
searchSpan,
|
|
149
|
+
configData,
|
|
150
|
+
table,
|
|
151
|
+
}: IHeaderProps) => {
|
|
140
152
|
const [formConfigData, setFormConfigData] = useState<HItemProps[]>([]);
|
|
141
153
|
const [subData, setSubData] = useState<HItemProps>(defaultSubItem as any);
|
|
142
154
|
const { headerOpen, setHeaderOpen } = useHTableContext();
|
|
@@ -145,7 +157,7 @@ export const useHideMoreTitle = ({ searchSpan, configData ,table}: IHeaderProps)
|
|
|
145
157
|
const { realConfigData, subConfigData } = mkNewConfig({
|
|
146
158
|
searchSpan,
|
|
147
159
|
configData,
|
|
148
|
-
table
|
|
160
|
+
table,
|
|
149
161
|
});
|
|
150
162
|
const changeClassName = headerOpen ? "" : className;
|
|
151
163
|
const { lessData, hideData } = filterHideFormItem(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {ConfigDataModal, ConfigItemModal} from "../modal";
|
|
1
|
+
import type { ConfigDataModal, ConfigItemModal } from "../modal";
|
|
2
2
|
import type { ColProps } from "antd";
|
|
3
3
|
import type React from "react";
|
|
4
|
-
import {HTableInstance} from "../modal";
|
|
4
|
+
import type { HTableInstance } from "../modal";
|
|
5
5
|
|
|
6
6
|
export interface IHeaderProps {
|
|
7
7
|
configData?: ConfigDataModal;
|
|
@@ -9,7 +9,7 @@ export interface IHeaderProps {
|
|
|
9
9
|
searchSpan?: ColProps;
|
|
10
10
|
loading?: boolean;
|
|
11
11
|
headerStyle?: React.CSSProperties;
|
|
12
|
-
table?:HTableInstance;
|
|
12
|
+
table?: HTableInstance;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface FormConfigDataItemProviderModal extends ConfigItemModal {
|
|
@@ -6,7 +6,7 @@ import { useClassName } from "../hooks";
|
|
|
6
6
|
import React, { useState } from "react";
|
|
7
7
|
import type { AffixProps } from "antd/lib/affix";
|
|
8
8
|
import GoTop from "../GoTop";
|
|
9
|
-
import {HTableInstance} from "../modal";
|
|
9
|
+
import type { HTableInstance } from "../modal";
|
|
10
10
|
export interface IPaginationProps extends PaginationProps {
|
|
11
11
|
onPageChange?: (params: ParamsModal) => void;
|
|
12
12
|
paginationStyle?: React.CSSProperties;
|
|
@@ -19,10 +19,14 @@ export default ({
|
|
|
19
19
|
paginationStyle,
|
|
20
20
|
affixProps,
|
|
21
21
|
goTop,
|
|
22
|
-
|
|
22
|
+
actionRender,
|
|
23
23
|
...props
|
|
24
24
|
}: IPaginationProps) => {
|
|
25
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
onPageChange: contextOnPageChange,
|
|
27
|
+
data,
|
|
28
|
+
tableInstance,
|
|
29
|
+
} = useHTableContext();
|
|
26
30
|
const tableOnPageChange = onPageChange || contextOnPageChange;
|
|
27
31
|
const { size, current, total } = data || {};
|
|
28
32
|
const pageCurrent = Number.parseInt(current || "1", 10);
|
|
@@ -35,10 +39,13 @@ export default ({
|
|
|
35
39
|
}
|
|
36
40
|
if (affixProps === false) {
|
|
37
41
|
return (
|
|
38
|
-
<Row
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
<Row
|
|
43
|
+
justify={"space-between"}
|
|
44
|
+
align={"middle"}
|
|
45
|
+
className={className}
|
|
46
|
+
style={paginationStyle}
|
|
47
|
+
>
|
|
48
|
+
<div>{actionRender?.(tableInstance)}</div>
|
|
42
49
|
<Pagination
|
|
43
50
|
size={"small"}
|
|
44
51
|
showQuickJumper={true}
|
|
@@ -78,9 +85,7 @@ export default ({
|
|
|
78
85
|
align={"middle"}
|
|
79
86
|
style={{ ...paginationStyle, ...style }}
|
|
80
87
|
>
|
|
81
|
-
<div>
|
|
82
|
-
{actionRender?.(tableInstance)}
|
|
83
|
-
</div>
|
|
88
|
+
<div>{actionRender?.(tableInstance)}</div>
|
|
84
89
|
<Pagination
|
|
85
90
|
size={"small"}
|
|
86
91
|
showQuickJumper={true}
|
package/src/components/Table.tsx
CHANGED
|
@@ -60,7 +60,7 @@ export default ({
|
|
|
60
60
|
configData,
|
|
61
61
|
onFinish: (value) => {
|
|
62
62
|
rowOnChange([], []);
|
|
63
|
-
|
|
63
|
+
return run({ ...saveParams.old, ...value, current: 1 });
|
|
64
64
|
},
|
|
65
65
|
onPageChange: tableInstance.table.reloadWithParams,
|
|
66
66
|
setSelectedRowData,
|
|
@@ -54,8 +54,8 @@ const Index: React.FC<HTableProps> = ({
|
|
|
54
54
|
configData,
|
|
55
55
|
params: saveParams.old,
|
|
56
56
|
onFinish: (value) => {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
rowOnChange([], []);
|
|
58
|
+
return run({ ...saveParams.old, ...value, current: 1 });
|
|
59
59
|
},
|
|
60
60
|
onPageChange: tableInstance.table.reloadWithParams,
|
|
61
61
|
setSelectedRowData,
|
package/src/components/modal.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
HItemProps,
|
|
5
5
|
HFormInstance,
|
|
6
6
|
} from "@hw-component/form/es/Form/modal";
|
|
7
|
-
import type {ColProps, FormInstance} from "antd";
|
|
7
|
+
import type { ColProps, FormInstance } from "antd";
|
|
8
8
|
import type React from "react";
|
|
9
9
|
import type { ModalProps } from "antd";
|
|
10
10
|
import type { TableProps } from "antd/lib/table";
|
|
@@ -34,7 +34,12 @@ interface HColumns extends Omit<ProColumns, "render" | "title"> {
|
|
|
34
34
|
) => React.ReactNode;
|
|
35
35
|
showSearch?: boolean;
|
|
36
36
|
searchType?: HItemProps["type"];
|
|
37
|
-
searchRender?:(
|
|
37
|
+
searchRender?: (
|
|
38
|
+
item: HItemProps,
|
|
39
|
+
node: React.ReactNode,
|
|
40
|
+
form: FormInstance,
|
|
41
|
+
tableInstance: HTableInstance
|
|
42
|
+
) => React.ReactNode;
|
|
38
43
|
rowSelectionTitle?: boolean;
|
|
39
44
|
title?: string | React.ReactNode;
|
|
40
45
|
}
|
|
@@ -104,6 +109,7 @@ export interface HTableProps
|
|
|
104
109
|
optionsRender?: (node: React.ReactNode) => React.ReactNode;
|
|
105
110
|
onFinish?: (value: any) => Promise<any>;
|
|
106
111
|
paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
112
|
+
localSorter?: boolean;
|
|
107
113
|
}
|
|
108
114
|
export interface TableInstance {
|
|
109
115
|
reload: (params?: ParamsModal) => Promise<any>;
|