@hw-component/table 0.0.1-beta-v4 → 0.0.1-beta-v5
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/Header/index.d.ts +2 -1
- package/es/Header/index.js +4 -2
- package/es/Table.js +4 -2
- package/es/hooks/useCurrentTable.d.ts +1 -1
- package/es/hooks/useHTable.d.ts +1 -1
- package/lib/Header/index.d.ts +2 -1
- package/lib/Header/index.js +4 -2
- package/lib/Table.js +4 -2
- package/lib/hooks/useCurrentTable.d.ts +1 -1
- package/lib/hooks/useHTable.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/Header/index.tsx +4 -1
- package/src/components/Table.tsx +4 -2
- package/src/components/hooks/useCurrentTable.ts +1 -1
- package/src/components/hooks/useHTable.tsx +1 -1
- package/src/pages/Test/index.tsx +26 -25
package/es/Header/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ interface IHeaderProps {
|
|
|
4
4
|
configData: ConfigDataModal;
|
|
5
5
|
onFinish: (value: Record<string, any>) => Promise<any>;
|
|
6
6
|
searchSpan?: ColProps;
|
|
7
|
+
loading?: boolean;
|
|
7
8
|
}
|
|
8
|
-
declare const _default: ({ configData, onFinish, searchSpan, }: IHeaderProps) => JSX.Element;
|
|
9
|
+
declare const _default: ({ configData, onFinish, searchSpan, loading, }: IHeaderProps) => JSX.Element;
|
|
9
10
|
export default _default;
|
package/es/Header/index.js
CHANGED
|
@@ -12,7 +12,8 @@ var Header = (function (_ref) {
|
|
|
12
12
|
_ref$searchSpan = _ref.searchSpan,
|
|
13
13
|
searchSpan = _ref$searchSpan === void 0 ? {
|
|
14
14
|
span: 6
|
|
15
|
-
} : _ref$searchSpan
|
|
15
|
+
} : _ref$searchSpan,
|
|
16
|
+
loading = _ref.loading;
|
|
16
17
|
var _useHTableContext = useHTableContext(),
|
|
17
18
|
tableInstance = _useHTableContext.tableInstance;
|
|
18
19
|
var form = tableInstance.form;
|
|
@@ -29,7 +30,8 @@ var Header = (function (_ref) {
|
|
|
29
30
|
},
|
|
30
31
|
children: jsx(HForm, {
|
|
31
32
|
itemSpan: searchSpan,
|
|
32
|
-
|
|
33
|
+
onFinish: onFinish,
|
|
34
|
+
submitLoading: loading,
|
|
33
35
|
gutter: [20, 0],
|
|
34
36
|
hideLabel: true,
|
|
35
37
|
configData: nConfigData,
|
package/es/Table.js
CHANGED
|
@@ -61,8 +61,9 @@ var Table = (function (_ref) {
|
|
|
61
61
|
rowOnChange = _useRowObj.rowOnChange;
|
|
62
62
|
var tableInstance = useCurrentTable({
|
|
63
63
|
table: table,
|
|
64
|
-
reload: function reload() {
|
|
65
|
-
|
|
64
|
+
reload: function reload(params) {
|
|
65
|
+
var reqParams = params || saveParams.params;
|
|
66
|
+
run(_objectSpread({}, reqParams));
|
|
66
67
|
},
|
|
67
68
|
changeRowData: rowOnChange
|
|
68
69
|
});
|
|
@@ -83,6 +84,7 @@ var Table = (function (_ref) {
|
|
|
83
84
|
children: [!hideHeader && jsx(Header, {
|
|
84
85
|
configData: configData,
|
|
85
86
|
onFinish: run,
|
|
87
|
+
loading: loading,
|
|
86
88
|
searchSpan: searchSpan
|
|
87
89
|
}), jsx(Body, _objectSpread({
|
|
88
90
|
loading: loading,
|
|
@@ -2,7 +2,7 @@ import type React from "react";
|
|
|
2
2
|
import type { ParamsModal, HTableInstance } from "../modal";
|
|
3
3
|
interface currentTableParams {
|
|
4
4
|
table?: HTableInstance;
|
|
5
|
-
reload: (params
|
|
5
|
+
reload: (params?: ParamsModal) => void;
|
|
6
6
|
changeRowData: (keys: React.Key[], data: any) => void;
|
|
7
7
|
}
|
|
8
8
|
declare const _default: ({ table, reload, changeRowData }: currentTableParams) => HTableInstance;
|
package/es/hooks/useHTable.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ParamsModal } from "../modal";
|
|
|
2
2
|
declare const _default: () => {
|
|
3
3
|
form: import("@hw-component/form/lib/Form/modal").HFormInstance;
|
|
4
4
|
table: {
|
|
5
|
-
reload: (params
|
|
5
|
+
reload: (params?: ParamsModal) => ParamsModal | undefined;
|
|
6
6
|
setSelectedRowData: () => void;
|
|
7
7
|
};
|
|
8
8
|
};
|
package/lib/Header/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ interface IHeaderProps {
|
|
|
4
4
|
configData: ConfigDataModal;
|
|
5
5
|
onFinish: (value: Record<string, any>) => Promise<any>;
|
|
6
6
|
searchSpan?: ColProps;
|
|
7
|
+
loading?: boolean;
|
|
7
8
|
}
|
|
8
|
-
declare const _default: ({ configData, onFinish, searchSpan, }: IHeaderProps) => JSX.Element;
|
|
9
|
+
declare const _default: ({ configData, onFinish, searchSpan, loading, }: IHeaderProps) => JSX.Element;
|
|
9
10
|
export default _default;
|
package/lib/Header/index.js
CHANGED
|
@@ -15,7 +15,8 @@ var Header = (function (_ref) {
|
|
|
15
15
|
_ref$searchSpan = _ref.searchSpan,
|
|
16
16
|
searchSpan = _ref$searchSpan === void 0 ? {
|
|
17
17
|
span: 6
|
|
18
|
-
} : _ref$searchSpan
|
|
18
|
+
} : _ref$searchSpan,
|
|
19
|
+
loading = _ref.loading;
|
|
19
20
|
var _useHTableContext = context.useHTableContext(),
|
|
20
21
|
tableInstance = _useHTableContext.tableInstance;
|
|
21
22
|
var form$1 = tableInstance.form;
|
|
@@ -32,7 +33,8 @@ var Header = (function (_ref) {
|
|
|
32
33
|
},
|
|
33
34
|
children: jsxRuntime.jsx(form.HForm, {
|
|
34
35
|
itemSpan: searchSpan,
|
|
35
|
-
|
|
36
|
+
onFinish: onFinish,
|
|
37
|
+
submitLoading: loading,
|
|
36
38
|
gutter: [20, 0],
|
|
37
39
|
hideLabel: true,
|
|
38
40
|
configData: nConfigData,
|
package/lib/Table.js
CHANGED
|
@@ -64,8 +64,9 @@ var Table = (function (_ref) {
|
|
|
64
64
|
rowOnChange = _useRowObj.rowOnChange;
|
|
65
65
|
var tableInstance = useCurrentTable.default({
|
|
66
66
|
table: table,
|
|
67
|
-
reload: function reload() {
|
|
68
|
-
|
|
67
|
+
reload: function reload(params) {
|
|
68
|
+
var reqParams = params || saveParams.params;
|
|
69
|
+
run(_objectSpread({}, reqParams));
|
|
69
70
|
},
|
|
70
71
|
changeRowData: rowOnChange
|
|
71
72
|
});
|
|
@@ -86,6 +87,7 @@ var Table = (function (_ref) {
|
|
|
86
87
|
children: [!hideHeader && jsxRuntime.jsx(index.default, {
|
|
87
88
|
configData: configData,
|
|
88
89
|
onFinish: run,
|
|
90
|
+
loading: loading,
|
|
89
91
|
searchSpan: searchSpan
|
|
90
92
|
}), jsxRuntime.jsx(index$1.default, _objectSpread({
|
|
91
93
|
loading: loading,
|
|
@@ -2,7 +2,7 @@ import type React from "react";
|
|
|
2
2
|
import type { ParamsModal, HTableInstance } from "../modal";
|
|
3
3
|
interface currentTableParams {
|
|
4
4
|
table?: HTableInstance;
|
|
5
|
-
reload: (params
|
|
5
|
+
reload: (params?: ParamsModal) => void;
|
|
6
6
|
changeRowData: (keys: React.Key[], data: any) => void;
|
|
7
7
|
}
|
|
8
8
|
declare const _default: ({ table, reload, changeRowData }: currentTableParams) => HTableInstance;
|
package/lib/hooks/useHTable.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ParamsModal } from "../modal";
|
|
|
2
2
|
declare const _default: () => {
|
|
3
3
|
form: import("@hw-component/form/lib/Form/modal").HFormInstance;
|
|
4
4
|
table: {
|
|
5
|
-
reload: (params
|
|
5
|
+
reload: (params?: ParamsModal) => ParamsModal | undefined;
|
|
6
6
|
setSelectedRowData: () => void;
|
|
7
7
|
};
|
|
8
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/table",
|
|
3
|
-
"version": "0.0.1-beta-
|
|
3
|
+
"version": "0.0.1-beta-v5",
|
|
4
4
|
"description": "基于antd二次开发table组件",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"table"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@ant-design/pro-table": "2.70.0",
|
|
34
|
-
"@hw-component/form": "0.0.9-beta-
|
|
34
|
+
"@hw-component/form": "0.0.9-beta-v8",
|
|
35
35
|
"ahooks": "2.10.9",
|
|
36
36
|
"antd": "4.20.7",
|
|
37
37
|
"core-js": "3",
|
|
@@ -11,12 +11,14 @@ interface IHeaderProps {
|
|
|
11
11
|
configData: ConfigDataModal;
|
|
12
12
|
onFinish: (value: Record<string, any>) => Promise<any>;
|
|
13
13
|
searchSpan?: ColProps;
|
|
14
|
+
loading?: boolean;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export default ({
|
|
17
18
|
configData,
|
|
18
19
|
onFinish,
|
|
19
20
|
searchSpan = { span: 6 },
|
|
21
|
+
loading,
|
|
20
22
|
}: IHeaderProps) => {
|
|
21
23
|
const { tableInstance } = useHTableContext();
|
|
22
24
|
const { form } = tableInstance;
|
|
@@ -34,7 +36,8 @@ export default ({
|
|
|
34
36
|
>
|
|
35
37
|
<HForm
|
|
36
38
|
itemSpan={searchSpan}
|
|
37
|
-
|
|
39
|
+
onFinish={onFinish}
|
|
40
|
+
submitLoading={loading}
|
|
38
41
|
gutter={[20, 0]}
|
|
39
42
|
hideLabel={true}
|
|
40
43
|
configData={nConfigData}
|
package/src/components/Table.tsx
CHANGED
|
@@ -32,8 +32,9 @@ export default ({
|
|
|
32
32
|
const { selectedRowData, rowOnChange } = useRowObj();
|
|
33
33
|
const tableInstance = useCurrentTable({
|
|
34
34
|
table,
|
|
35
|
-
reload: () => {
|
|
36
|
-
|
|
35
|
+
reload: (params) => {
|
|
36
|
+
const reqParams = params || saveParams.params;
|
|
37
|
+
run({ ...reqParams });
|
|
37
38
|
},
|
|
38
39
|
changeRowData: rowOnChange,
|
|
39
40
|
});
|
|
@@ -52,6 +53,7 @@ export default ({
|
|
|
52
53
|
<Header
|
|
53
54
|
configData={configData}
|
|
54
55
|
onFinish={run}
|
|
56
|
+
loading={loading}
|
|
55
57
|
searchSpan={searchSpan}
|
|
56
58
|
/>
|
|
57
59
|
)}
|
|
@@ -5,7 +5,7 @@ import useHTable from "../hooks/useHTable";
|
|
|
5
5
|
|
|
6
6
|
interface currentTableParams {
|
|
7
7
|
table?: HTableInstance;
|
|
8
|
-
reload: (params
|
|
8
|
+
reload: (params?: ParamsModal) => void;
|
|
9
9
|
changeRowData: (keys: React.Key[], data: any) => void;
|
|
10
10
|
}
|
|
11
11
|
export default ({ table, reload, changeRowData }: currentTableParams) => {
|
package/src/pages/Test/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HTable, HTableConfig } from "../../components";
|
|
1
|
+
import { HTable, HTableConfig, useHTable } from "../../components";
|
|
2
2
|
import { Button } from "antd";
|
|
3
3
|
const configData = [
|
|
4
4
|
{
|
|
@@ -15,45 +15,46 @@ const configData = [
|
|
|
15
15
|
},
|
|
16
16
|
];
|
|
17
17
|
export default () => {
|
|
18
|
+
const hTable = useHTable();
|
|
18
19
|
return (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
<>
|
|
21
|
+
<div
|
|
22
|
+
onClick={() => {
|
|
23
|
+
hTable.table.reload();
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
{" "}
|
|
27
|
+
点我
|
|
28
|
+
</div>
|
|
24
29
|
<HTable
|
|
25
30
|
configData={configData}
|
|
26
31
|
rowKey={"id"}
|
|
27
|
-
|
|
28
|
-
emptyRender={() => {
|
|
29
|
-
return <div>无数据</div>;
|
|
30
|
-
}}
|
|
31
|
-
errorRender={(table, error) => {
|
|
32
|
-
return <div>{error.message}</div>;
|
|
33
|
-
}}
|
|
32
|
+
table={hTable}
|
|
34
33
|
actionRender={(allCheck, selectedRowKeys, xjTable) => {
|
|
35
34
|
console.log(allCheck, selectedRowKeys, xjTable);
|
|
36
35
|
return <Button>点我</Button>;
|
|
37
36
|
}}
|
|
38
37
|
footerRender={false}
|
|
39
38
|
request={(a) => {
|
|
39
|
+
console.log(a);
|
|
40
40
|
return new Promise((resolve, reject) => {
|
|
41
41
|
setTimeout(() => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
reject(new Error("错误"));
|
|
43
|
+
// resolve({
|
|
44
|
+
// size: "10",
|
|
45
|
+
// current: "1",
|
|
46
|
+
// total: "100",
|
|
47
|
+
// records: [
|
|
48
|
+
// {
|
|
49
|
+
// id: 1,
|
|
50
|
+
// name: "111",
|
|
51
|
+
// },
|
|
52
|
+
// ],
|
|
53
|
+
// });
|
|
53
54
|
}, 2000);
|
|
54
55
|
});
|
|
55
56
|
}}
|
|
56
57
|
/>
|
|
57
|
-
|
|
58
|
+
</>
|
|
58
59
|
);
|
|
59
60
|
};
|