@hw-component/table 0.0.3-beta-v2 → 0.0.3-beta-v4
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/es/HTableBody/index.d.ts +1 -1
- package/es/HTableBody/index.js +18 -24
- package/es/HTableHeader/index.d.ts +2 -2
- package/es/HTableHeader/index.js +7 -3
- package/es/HTablePagination/index.d.ts +7 -0
- package/es/HTablePagination/index.js +71 -0
- package/es/Table.js +23 -43
- package/es/TableCustomize.d.ts +4 -0
- package/es/TableCustomize.js +70 -0
- package/es/context.d.ts +5 -1
- package/es/hooks/useCurrentTable.d.ts +3 -2
- package/es/hooks/useCurrentTable.js +3 -1
- package/es/hooks/useDispatch.d.ts +3 -0
- package/es/hooks/useDispatch.js +10 -0
- package/es/hooks/useHTable.d.ts +2 -1
- package/es/hooks/useHTable.js +6 -2
- package/es/hooks/useReq.d.ts +23 -0
- package/es/hooks/useReq.js +45 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/modal.d.ts +3 -2
- package/lib/HTableBody/index.d.ts +1 -1
- package/lib/HTableBody/index.js +17 -23
- package/lib/HTableHeader/index.d.ts +2 -2
- package/lib/HTableHeader/index.js +7 -3
- package/lib/HTablePagination/index.d.ts +7 -0
- package/lib/HTablePagination/index.js +74 -0
- package/lib/Table.js +23 -43
- package/lib/TableCustomize.d.ts +4 -0
- package/lib/TableCustomize.js +73 -0
- package/lib/context.d.ts +5 -1
- package/lib/hooks/useCurrentTable.d.ts +3 -2
- package/lib/hooks/useCurrentTable.js +3 -1
- package/lib/hooks/useDispatch.d.ts +3 -0
- package/lib/hooks/useDispatch.js +13 -0
- package/lib/hooks/useHTable.d.ts +2 -1
- package/lib/hooks/useHTable.js +6 -2
- package/lib/hooks/useReq.d.ts +23 -0
- package/lib/hooks/useReq.js +48 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +8 -0
- package/lib/modal.d.ts +3 -2
- package/package.json +1 -1
- package/src/components/HTableBody/index.tsx +20 -20
- package/src/components/HTableHeader/index.tsx +12 -6
- package/src/components/HTablePagination/index.tsx +43 -0
- package/src/components/Table.tsx +14 -35
- package/src/components/TableCustomize.tsx +48 -0
- package/src/components/context.ts +5 -1
- package/src/components/hooks/useCurrentTable.ts +4 -1
- package/src/components/hooks/useDispatch.ts +8 -0
- package/src/components/hooks/useHTable.tsx +4 -1
- package/src/components/hooks/useReq.ts +23 -0
- package/src/components/index.tsx +4 -0
- package/src/components/modal.ts +3 -2
- package/src/pages/{Test → Table}/index.tsx +4 -11
- package/src/pages/TableCustomize/index.tsx +51 -0
- package/src/routes.tsx +11 -5
|
@@ -7,9 +7,9 @@ import React from "react";
|
|
|
7
7
|
import { ConfigProvider, Empty } from "antd";
|
|
8
8
|
import type { HTableInstance } from "../modal";
|
|
9
9
|
import { useHTableConfigContext } from "../TableConfig";
|
|
10
|
-
|
|
10
|
+
import HTablePagination from "../HTablePagination";
|
|
11
11
|
interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource"> {
|
|
12
|
-
configData
|
|
12
|
+
configData?: ConfigDataModal;
|
|
13
13
|
onPageChange?: (params: ParamsModal) => void;
|
|
14
14
|
emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
15
15
|
errorRender?: (
|
|
@@ -34,14 +34,22 @@ export default ({
|
|
|
34
34
|
}: HTableBodyProps) => {
|
|
35
35
|
// @ts-ignore
|
|
36
36
|
const { selectedRowKeys, onChange } = rowSelection;
|
|
37
|
-
const {
|
|
38
|
-
|
|
37
|
+
const {
|
|
38
|
+
tableInstance,
|
|
39
|
+
configData: contextConfigData,
|
|
40
|
+
data,
|
|
41
|
+
selectedRowData,
|
|
42
|
+
rowOnChange,
|
|
43
|
+
error,
|
|
44
|
+
loading,
|
|
45
|
+
} = useHTableContext();
|
|
39
46
|
const {
|
|
40
47
|
emptyRender: tableEmptyRender = defaultRender,
|
|
41
48
|
errorRender: tableErrorRender = defaultRender,
|
|
42
49
|
} = useHTableConfigContext({ emptyRender, errorRender });
|
|
50
|
+
const bodyConfigData = configData || contextConfigData;
|
|
43
51
|
const { records, size, current, total } = data || {};
|
|
44
|
-
const cols = useCols(
|
|
52
|
+
const cols = useCols(bodyConfigData, tableInstance);
|
|
45
53
|
const change = (key: React.Key[], rowData: any[]) => {
|
|
46
54
|
if (onChange) {
|
|
47
55
|
return onChange(key, rowData);
|
|
@@ -67,6 +75,9 @@ export default ({
|
|
|
67
75
|
columns={cols}
|
|
68
76
|
tableAlertRender={false}
|
|
69
77
|
search={false}
|
|
78
|
+
tableStyle={{
|
|
79
|
+
paddingBottom: 0,
|
|
80
|
+
}}
|
|
70
81
|
rowSelection={{
|
|
71
82
|
...rowSelection,
|
|
72
83
|
selectedRowKeys: selectedRowData.keys,
|
|
@@ -75,22 +86,11 @@ export default ({
|
|
|
75
86
|
loading={loading}
|
|
76
87
|
rowKey={rowKey}
|
|
77
88
|
dataSource={records}
|
|
78
|
-
|
|
79
|
-
const { pageSize: ps, current: pn } = paginationData;
|
|
80
|
-
onPageChange?.({ size: ps, current: pn });
|
|
81
|
-
}}
|
|
82
|
-
pagination={
|
|
83
|
-
pagination === false
|
|
84
|
-
? pagination
|
|
85
|
-
: {
|
|
86
|
-
current: Number.parseInt(current || "1", 10),
|
|
87
|
-
total: Number.parseInt(total || "0", 10),
|
|
88
|
-
pageSize: Number.parseInt(size || "10", 10),
|
|
89
|
-
showQuickJumper: true,
|
|
90
|
-
...pagination,
|
|
91
|
-
}
|
|
92
|
-
}
|
|
89
|
+
pagination={false}
|
|
93
90
|
/>
|
|
91
|
+
{pagination !== false && (
|
|
92
|
+
<HTablePagination onPageChange={onPageChange} {...pagination} />
|
|
93
|
+
)}
|
|
94
94
|
</ConfigProvider>
|
|
95
95
|
</div>
|
|
96
96
|
);
|
|
@@ -8,8 +8,8 @@ import { formConfigDataProvider } from "./utils";
|
|
|
8
8
|
import type { HItemProps } from "@hw-component/form/lib/Form/modal";
|
|
9
9
|
|
|
10
10
|
interface IHeaderProps {
|
|
11
|
-
configData
|
|
12
|
-
onFinish
|
|
11
|
+
configData?: ConfigDataModal;
|
|
12
|
+
onFinish?: (value: Record<string, any>) => Promise<any>;
|
|
13
13
|
searchSpan?: ColProps;
|
|
14
14
|
loading?: boolean;
|
|
15
15
|
headerStyle?: React.CSSProperties;
|
|
@@ -21,11 +21,17 @@ export default ({
|
|
|
21
21
|
searchSpan = { span: 6 },
|
|
22
22
|
headerStyle,
|
|
23
23
|
}: IHeaderProps) => {
|
|
24
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
tableInstance,
|
|
26
|
+
loading,
|
|
27
|
+
onFinish: contextOnFinish,
|
|
28
|
+
configData: contextConfigData,
|
|
29
|
+
} = useHTableContext();
|
|
30
|
+
const headerConfigData = configData || contextConfigData;
|
|
25
31
|
const { form } = tableInstance;
|
|
26
|
-
|
|
32
|
+
const subOnFinish = onFinish || contextOnFinish;
|
|
27
33
|
const nConfigData: HItemProps[] = useMemo(
|
|
28
|
-
() => formConfigDataProvider(
|
|
34
|
+
() => formConfigDataProvider(headerConfigData),
|
|
29
35
|
[configData]
|
|
30
36
|
);
|
|
31
37
|
|
|
@@ -38,7 +44,7 @@ export default ({
|
|
|
38
44
|
>
|
|
39
45
|
<HForm
|
|
40
46
|
itemSpan={searchSpan}
|
|
41
|
-
onFinish={
|
|
47
|
+
onFinish={subOnFinish}
|
|
42
48
|
submitLoading={loading}
|
|
43
49
|
gutter={[20, 0]}
|
|
44
50
|
hideLabel={true}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { PaginationProps} from "antd";
|
|
2
|
+
import { Pagination, Row } from "antd";
|
|
3
|
+
import { useHTableContext } from "../context";
|
|
4
|
+
import type { ParamsModal } from "@/components/modal";
|
|
5
|
+
interface IPaginationProps extends PaginationProps {
|
|
6
|
+
onPageChange?: (params: ParamsModal) => void;
|
|
7
|
+
}
|
|
8
|
+
export default ({ onPageChange, ...props }: IPaginationProps) => {
|
|
9
|
+
const {
|
|
10
|
+
onPageChange: contextOnPageChange,
|
|
11
|
+
configData: contextConfigData,
|
|
12
|
+
data,
|
|
13
|
+
} = useHTableContext();
|
|
14
|
+
const tableOnPageChange = onPageChange || contextOnPageChange;
|
|
15
|
+
const { size, current, total } = data || {};
|
|
16
|
+
const pageCurrent = Number.parseInt(current || "1", 10);
|
|
17
|
+
const pageSize = Number.parseInt(size || "10", 10);
|
|
18
|
+
const pageTotal = Number.parseInt(total || "0", 10);
|
|
19
|
+
if (data) {
|
|
20
|
+
return (
|
|
21
|
+
<Row
|
|
22
|
+
justify={"end"}
|
|
23
|
+
style={{ paddingBottom: 24, paddingRight: 24, paddingLeft: 24 }}
|
|
24
|
+
>
|
|
25
|
+
<Pagination
|
|
26
|
+
size={"small"}
|
|
27
|
+
showQuickJumper={true}
|
|
28
|
+
pageSize={pageSize}
|
|
29
|
+
current={pageCurrent}
|
|
30
|
+
showTotal={(totalNum, [showCurrent, showCurrentEnd]) => {
|
|
31
|
+
return `第${showCurrent}-${showCurrentEnd}/总共${totalNum}条`;
|
|
32
|
+
}}
|
|
33
|
+
total={pageTotal}
|
|
34
|
+
onChange={(pn, ps) => {
|
|
35
|
+
tableOnPageChange({ size: ps, current: pn });
|
|
36
|
+
}}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
</Row>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return <></>;
|
|
43
|
+
};
|
package/src/components/Table.tsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import Header from "./HTableHeader";
|
|
2
2
|
import Body from "./HTableBody";
|
|
3
|
-
import { useRequest } from "ahooks";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
3
|
import useCurrentTable from "./hooks/useCurrentTable";
|
|
6
4
|
import Footer from "./HTableFooter";
|
|
7
5
|
import useRowObj from "./hooks/useRowObj";
|
|
8
6
|
import { HTableContext } from "./context";
|
|
9
7
|
import { Space } from "antd";
|
|
10
8
|
import type { HTableProps } from "./modal";
|
|
9
|
+
import useReq from "./hooks/useReq";
|
|
10
|
+
import useDispatch from "./hooks/useDispatch";
|
|
11
11
|
export default ({
|
|
12
12
|
request,
|
|
13
13
|
configData,
|
|
@@ -24,30 +24,17 @@ export default ({
|
|
|
24
24
|
className,
|
|
25
25
|
...props
|
|
26
26
|
}: HTableProps) => {
|
|
27
|
-
const saveParams =
|
|
28
|
-
|
|
29
|
-
params: {},
|
|
30
|
-
};
|
|
31
|
-
}, []);
|
|
32
|
-
const { run, loading, data, error } = useRequest((params = {}) => {
|
|
33
|
-
const { size = "10", current = "1", ...oParams } = params;
|
|
34
|
-
const reqParams = { size, current, ...oParams };
|
|
35
|
-
saveParams.params = reqParams;
|
|
36
|
-
return request(reqParams);
|
|
37
|
-
});
|
|
38
|
-
const dispatch = (key: string, params: any) => {
|
|
39
|
-
const fn = action[key];
|
|
40
|
-
fn?.(params);
|
|
41
|
-
};
|
|
27
|
+
const { run, loading, data, error, saveParams } = useReq({ request });
|
|
28
|
+
const dispatch = useDispatch(action);
|
|
42
29
|
const { selectedRowData, rowOnChange, allSelectChange } = useRowObj();
|
|
43
30
|
const tableInstance = useCurrentTable({
|
|
44
31
|
table,
|
|
45
|
-
reload:
|
|
46
|
-
const reqParams = params || saveParams.params;
|
|
47
|
-
run({ ...reqParams });
|
|
48
|
-
},
|
|
32
|
+
reload: run,
|
|
49
33
|
changeRowData: rowOnChange,
|
|
50
34
|
dispatch,
|
|
35
|
+
reloadWithParams: (reloadParams = {}) => {
|
|
36
|
+
return run({ ...saveParams.old, ...reloadParams });
|
|
37
|
+
},
|
|
51
38
|
});
|
|
52
39
|
return (
|
|
53
40
|
<HTableContext.Provider
|
|
@@ -59,6 +46,10 @@ export default ({
|
|
|
59
46
|
error,
|
|
60
47
|
loading,
|
|
61
48
|
allSelectChange,
|
|
49
|
+
action,
|
|
50
|
+
configData,
|
|
51
|
+
onFinish: run,
|
|
52
|
+
onPageChange: tableInstance.table.reloadWithParams,
|
|
62
53
|
}}
|
|
63
54
|
>
|
|
64
55
|
<Space
|
|
@@ -68,21 +59,9 @@ export default ({
|
|
|
68
59
|
className={className}
|
|
69
60
|
>
|
|
70
61
|
{!hideHeader && (
|
|
71
|
-
<Header
|
|
72
|
-
configData={configData}
|
|
73
|
-
onFinish={run}
|
|
74
|
-
searchSpan={searchSpan}
|
|
75
|
-
headerStyle={headerStyle}
|
|
76
|
-
/>
|
|
62
|
+
<Header searchSpan={searchSpan} headerStyle={headerStyle} />
|
|
77
63
|
)}
|
|
78
|
-
<Body
|
|
79
|
-
configData={configData}
|
|
80
|
-
tableStyle={tableStyle}
|
|
81
|
-
onPageChange={(page) => {
|
|
82
|
-
run({ ...saveParams.params, ...page });
|
|
83
|
-
}}
|
|
84
|
-
{...props}
|
|
85
|
-
/>
|
|
64
|
+
<Body tableStyle={tableStyle} {...props} />
|
|
86
65
|
{footerRender !== false && (
|
|
87
66
|
<Footer
|
|
88
67
|
actionRender={actionRender}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import useCurrentTable from "./hooks/useCurrentTable";
|
|
2
|
+
import useRowObj from "./hooks/useRowObj";
|
|
3
|
+
import { HTableContext } from "./context";
|
|
4
|
+
import type { HTableProps } from "./modal";
|
|
5
|
+
import useReq from "./hooks/useReq";
|
|
6
|
+
import useDispatch from "./hooks/useDispatch";
|
|
7
|
+
import React from "react";
|
|
8
|
+
const Index: React.FC<HTableProps> = ({
|
|
9
|
+
request,
|
|
10
|
+
configData,
|
|
11
|
+
table,
|
|
12
|
+
action = {},
|
|
13
|
+
children,
|
|
14
|
+
}) => {
|
|
15
|
+
const { run, loading, data, error, saveParams } = useReq({ request });
|
|
16
|
+
const dispatch = useDispatch(action);
|
|
17
|
+
const { selectedRowData, rowOnChange, allSelectChange } = useRowObj();
|
|
18
|
+
const tableInstance = useCurrentTable({
|
|
19
|
+
table,
|
|
20
|
+
reload: run,
|
|
21
|
+
changeRowData: rowOnChange,
|
|
22
|
+
dispatch,
|
|
23
|
+
reloadWithParams: (reloadParams = {}) => {
|
|
24
|
+
return run({ ...saveParams.old, ...reloadParams });
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return (
|
|
28
|
+
<HTableContext.Provider
|
|
29
|
+
value={{
|
|
30
|
+
tableInstance,
|
|
31
|
+
selectedRowData,
|
|
32
|
+
rowOnChange,
|
|
33
|
+
data,
|
|
34
|
+
error,
|
|
35
|
+
loading,
|
|
36
|
+
allSelectChange,
|
|
37
|
+
action,
|
|
38
|
+
configData,
|
|
39
|
+
params: saveParams.old,
|
|
40
|
+
onFinish: run,
|
|
41
|
+
onPageChange: tableInstance.table.reloadWithParams,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</HTableContext.Provider>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
export default Index;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
2
|
import type { ResultModal, RowObj, HTableInstance } from "./modal";
|
|
3
|
+
import type { HTableProps } from "./modal";
|
|
3
4
|
|
|
4
|
-
interface HContextModal {
|
|
5
|
+
interface HContextModal extends Omit<HTableProps, "request"> {
|
|
5
6
|
tableInstance: HTableInstance;
|
|
6
7
|
data?: ResultModal;
|
|
7
8
|
selectedRowData: RowObj;
|
|
@@ -9,6 +10,9 @@ interface HContextModal {
|
|
|
9
10
|
error?: Error;
|
|
10
11
|
loading?: boolean;
|
|
11
12
|
allSelectChange?: VoidFunction;
|
|
13
|
+
params?: any;
|
|
14
|
+
onFinish: (value: Record<string, any>) => Promise<any>;
|
|
15
|
+
onPageChange: (value: Record<string, any>) => Promise<any>;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
export const HTableContext = React.createContext<HContextModal | null>(null);
|
|
@@ -5,15 +5,17 @@ import useHTable from "../hooks/useHTable";
|
|
|
5
5
|
|
|
6
6
|
interface currentTableParams {
|
|
7
7
|
table?: HTableInstance;
|
|
8
|
-
reload: (params?: ParamsModal) =>
|
|
8
|
+
reload: (params?: ParamsModal) => Promise<any>;
|
|
9
9
|
changeRowData: (keys: React.Key[], data: any) => void;
|
|
10
10
|
dispatch: (key: string, params: any) => void;
|
|
11
|
+
reloadWithParams: (params?: ParamsModal) => Promise<any>;
|
|
11
12
|
}
|
|
12
13
|
export default ({
|
|
13
14
|
table,
|
|
14
15
|
reload,
|
|
15
16
|
changeRowData,
|
|
16
17
|
dispatch,
|
|
18
|
+
reloadWithParams,
|
|
17
19
|
}: currentTableParams) => {
|
|
18
20
|
const useCurrentTable = useHTable();
|
|
19
21
|
return useMemo(() => {
|
|
@@ -21,6 +23,7 @@ export default ({
|
|
|
21
23
|
resultTable.table.reload = reload;
|
|
22
24
|
resultTable.table.setSelectedRowData = changeRowData;
|
|
23
25
|
resultTable.table.dispatch = dispatch;
|
|
26
|
+
resultTable.table.reloadWithParams = reloadWithParams;
|
|
24
27
|
return resultTable;
|
|
25
28
|
}, [table]);
|
|
26
29
|
};
|
|
@@ -7,10 +7,13 @@ export default () => {
|
|
|
7
7
|
const table = useMemo(() => {
|
|
8
8
|
return {
|
|
9
9
|
reload: (params?: ParamsModal) => {
|
|
10
|
-
return params;
|
|
10
|
+
return Promise.resolve(params);
|
|
11
11
|
},
|
|
12
12
|
setSelectedRowData: () => {},
|
|
13
13
|
dispatch: () => {},
|
|
14
|
+
reloadWithParams: (params?: ParamsModal) => {
|
|
15
|
+
return Promise.resolve(params);
|
|
16
|
+
},
|
|
14
17
|
};
|
|
15
18
|
}, []);
|
|
16
19
|
return {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useRequest } from "ahooks";
|
|
3
|
+
import type { ParamsModal, ResultModal } from "@/components/modal";
|
|
4
|
+
interface IParamsModal {
|
|
5
|
+
request: (params: ParamsModal) => Promise<ResultModal>;
|
|
6
|
+
}
|
|
7
|
+
export default ({ request }: IParamsModal) => {
|
|
8
|
+
const saveParams = useMemo(() => {
|
|
9
|
+
return {
|
|
10
|
+
old: {},
|
|
11
|
+
};
|
|
12
|
+
}, []);
|
|
13
|
+
const resultAction = useRequest((params = {}) => {
|
|
14
|
+
const { size = "10", current = "1", ...oParams } = params;
|
|
15
|
+
const reqParams = { size, current, ...oParams };
|
|
16
|
+
saveParams.old = reqParams;
|
|
17
|
+
return request(reqParams);
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
...resultAction,
|
|
21
|
+
saveParams,
|
|
22
|
+
};
|
|
23
|
+
};
|
package/src/components/index.tsx
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export { default as HTable } from "./Table";
|
|
2
2
|
export { default as useHTable } from "./hooks/useHTable";
|
|
3
3
|
export { default as HTableConfig } from "./TableConfig";
|
|
4
|
+
export { default as TableCustomize } from "./TableCustomize";
|
|
5
|
+
export { default as HTableBody } from "./HTableBody";
|
|
6
|
+
export { default as HTableFooter } from "./HTableFooter";
|
|
7
|
+
export { default as HTableHeader } from "./HTableHeader";
|
package/src/components/modal.ts
CHANGED
|
@@ -39,7 +39,7 @@ export type ActionRenderFn = (
|
|
|
39
39
|
selectedRowKeys: RowObj,
|
|
40
40
|
tableInstance: HTableInstance
|
|
41
41
|
) => React.ReactNode;
|
|
42
|
-
type actionFn = (...arg) => void;
|
|
42
|
+
export type actionFn = (...arg) => void;
|
|
43
43
|
type FooterRenderFn = (
|
|
44
44
|
tableInstance: HTableInstance,
|
|
45
45
|
selectedRowData: RowObj,
|
|
@@ -66,9 +66,10 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request"> {
|
|
|
66
66
|
className?: string;
|
|
67
67
|
}
|
|
68
68
|
export interface TableInstance {
|
|
69
|
-
reload: (params?: ParamsModal) =>
|
|
69
|
+
reload: (params?: ParamsModal) => Promise<any>;
|
|
70
70
|
setSelectedRowData: (keys: React.Key[], data: any) => void;
|
|
71
71
|
dispatch: (key: string, params: any) => void;
|
|
72
|
+
reloadWithParams: (params?: ParamsModal) => Promise<any>;
|
|
72
73
|
}
|
|
73
74
|
export interface HTableInstance {
|
|
74
75
|
form: HFormInstance;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HTable, useHTable } from "../../components";
|
|
2
2
|
import { Button } from "antd";
|
|
3
|
+
|
|
3
4
|
const configData = [
|
|
4
5
|
{
|
|
5
6
|
title: "座位",
|
|
@@ -18,34 +19,26 @@ export default () => {
|
|
|
18
19
|
const hTable = useHTable();
|
|
19
20
|
return (
|
|
20
21
|
<>
|
|
21
|
-
<div
|
|
22
|
-
onClick={() => {
|
|
23
|
-
hTable.table.reload();
|
|
24
|
-
}}
|
|
25
|
-
>
|
|
26
|
-
点我
|
|
27
|
-
</div>
|
|
28
22
|
<HTable
|
|
29
23
|
configData={configData}
|
|
30
24
|
rowKey={"id"}
|
|
31
25
|
headerStyle={{ borderRadius: 0 }}
|
|
32
26
|
tableStyle={{ borderRadius: 0, background: "#fff" }}
|
|
33
27
|
spaceSize={0}
|
|
34
|
-
pagination={false}
|
|
35
28
|
footerStyle={{ marginTop: 20 }}
|
|
36
29
|
table={hTable}
|
|
37
30
|
actionRender={(allCheck, selectedRowKeys, xjTable) => {
|
|
38
31
|
console.log(allCheck, selectedRowKeys, xjTable);
|
|
39
32
|
return <Button>点我</Button>;
|
|
40
33
|
}}
|
|
41
|
-
request={(
|
|
42
|
-
|
|
34
|
+
request={(params) => {
|
|
35
|
+
const { current = 1 } = params;
|
|
43
36
|
return new Promise((resolve, reject) => {
|
|
44
37
|
setTimeout(() => {
|
|
45
38
|
// reject(new Error("错误"));
|
|
46
39
|
resolve({
|
|
47
40
|
size: "10",
|
|
48
|
-
current:
|
|
41
|
+
current: current.toString(10),
|
|
49
42
|
total: "100",
|
|
50
43
|
records: [
|
|
51
44
|
{
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TableCustomize,
|
|
3
|
+
HTableHeader,
|
|
4
|
+
HTableBody,
|
|
5
|
+
HTableFooter,
|
|
6
|
+
} from "../../components";
|
|
7
|
+
|
|
8
|
+
const configData = [
|
|
9
|
+
{
|
|
10
|
+
title: "座位",
|
|
11
|
+
showSearch: true,
|
|
12
|
+
searchType: "select",
|
|
13
|
+
dataIndex: "name",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title: "操作",
|
|
17
|
+
name: "aaa",
|
|
18
|
+
showSearch: true,
|
|
19
|
+
searchType: "rangePicker",
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
export default () => {
|
|
23
|
+
return (
|
|
24
|
+
<TableCustomize
|
|
25
|
+
configData={configData}
|
|
26
|
+
request={(params) => {
|
|
27
|
+
const { current = 1 } = params;
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
// reject(new Error("错误"));
|
|
31
|
+
resolve({
|
|
32
|
+
size: "10",
|
|
33
|
+
current: current.toString(10),
|
|
34
|
+
total: "100",
|
|
35
|
+
records: [
|
|
36
|
+
{
|
|
37
|
+
id: 1,
|
|
38
|
+
name: "111",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
}, 2000);
|
|
43
|
+
});
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<HTableHeader />
|
|
47
|
+
<HTableBody />
|
|
48
|
+
<HTableFooter />
|
|
49
|
+
</TableCustomize>
|
|
50
|
+
);
|
|
51
|
+
};
|
package/src/routes.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Navigate } from "react-router-dom";
|
|
3
|
-
import
|
|
3
|
+
import Table from "./pages/Table";
|
|
4
|
+
import TableCustomize from "./pages/TableCustomize";
|
|
4
5
|
|
|
5
6
|
export interface RouteModal {
|
|
6
7
|
path?: string;
|
|
@@ -14,12 +15,17 @@ export interface RouteModal {
|
|
|
14
15
|
const routes: RouteModal[] = [
|
|
15
16
|
{
|
|
16
17
|
index: true,
|
|
17
|
-
element: <Navigate to="/
|
|
18
|
+
element: <Navigate to="/table" replace={true} />,
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
|
-
path: "/
|
|
21
|
-
name: "
|
|
22
|
-
element: <
|
|
21
|
+
path: "/table",
|
|
22
|
+
name: "table",
|
|
23
|
+
element: <Table />,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
path: "/tableCustomize",
|
|
27
|
+
name: "tableCustomize",
|
|
28
|
+
element: <TableCustomize />,
|
|
23
29
|
},
|
|
24
30
|
];
|
|
25
31
|
|