@hw-component/table 0.0.6-beta-v8 → 0.0.6-beta-v9
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 -0
- package/es/HTableBody/hooks.d.ts +2 -9
- package/es/HTableHeader/defaultSubComponent.d.ts +6 -0
- package/es/HTableHeader/defaultSubComponent.js +61 -0
- package/es/HTableHeader/hooks.d.ts +3 -0
- package/es/HTableHeader/hooks.js +203 -0
- package/es/HTableHeader/index.js +8 -8
- package/es/Table.js +9 -1
- package/es/TableCustomize.js +9 -1
- package/es/index.css +6 -2
- package/lib/HTableBody/hooks.d.ts +2 -9
- package/lib/HTableHeader/defaultSubComponent.d.ts +6 -0
- package/lib/HTableHeader/defaultSubComponent.js +62 -0
- package/lib/HTableHeader/hooks.d.ts +3 -0
- package/lib/HTableHeader/hooks.js +204 -0
- package/lib/HTableHeader/index.js +8 -8
- package/lib/Table.js +9 -1
- package/lib/TableCustomize.js +9 -1
- package/lib/index.css +6 -2
- package/package.json +3 -2
- package/.husky/pre-commit +0 -4
- package/es/HTableHeader/index.d.ts +0 -12
- package/es/HTableHeader/utils.d.ts +0 -7
- package/es/HTableHeader/utils.js +0 -83
- package/es/Table.d.ts +0 -3
- package/es/context.d.ts +0 -20
- package/es/hooks/index.d.ts +0 -1
- package/es/index.d.ts +0 -11
- package/es/modal.d.ts +0 -100
- package/lib/HTableHeader/index.d.ts +0 -12
- package/lib/HTableHeader/utils.d.ts +0 -7
- package/lib/HTableHeader/utils.js +0 -85
- package/lib/Table.d.ts +0 -3
- package/lib/context.d.ts +0 -20
- package/lib/hooks/index.d.ts +0 -1
- package/lib/index.d.ts +0 -11
- package/lib/modal.d.ts +0 -100
- package/public/index.html +0 -19
- package/scripts/rollup.config.js +0 -93
- package/scripts/webpack.config.js +0 -79
- package/src/Layout.tsx +0 -61
- package/src/app.tsx +0 -33
- package/src/components/GoTop/goTop.png +0 -0
- package/src/components/GoTop/index.tsx +0 -37
- package/src/components/HTableBody/AlertMsg.tsx +0 -37
- package/src/components/HTableBody/RowSelection.tsx +0 -143
- package/src/components/HTableBody/hooks.tsx +0 -72
- package/src/components/HTableBody/index.tsx +0 -148
- package/src/components/HTableFooter/index.tsx +0 -78
- package/src/components/HTableHeader/index.tsx +0 -67
- package/src/components/HTableHeader/utils.ts +0 -63
- package/src/components/HTablePagination/index.tsx +0 -91
- package/src/components/ModalTable/hooks.ts +0 -60
- package/src/components/ModalTable/index.tsx +0 -78
- package/src/components/Table.tsx +0 -81
- package/src/components/TableConfig.tsx +0 -30
- package/src/components/TableCustomize.tsx +0 -67
- package/src/components/context.ts +0 -25
- package/src/components/hooks/index.ts +0 -14
- package/src/components/hooks/useCurrentTable.ts +0 -32
- package/src/components/hooks/useDispatch.ts +0 -8
- package/src/components/hooks/useHTable.tsx +0 -26
- package/src/components/hooks/useReq.ts +0 -65
- package/src/components/hooks/useRowObj.ts +0 -27
- package/src/components/index.less +0 -41
- package/src/components/index.tsx +0 -11
- package/src/components/modal.ts +0 -130
- package/src/components/styles/local.less +0 -1
- package/src/index.less +0 -21
- package/src/index.tsx +0 -12
- package/src/pages/ModalTable/index.tsx +0 -101
- package/src/pages/Table/index.tsx +0 -83
- package/src/pages/TableCustomize/index.tsx +0 -79
- package/src/routes.tsx +0 -37
- package/src/typings.d.ts +0 -46
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import useHTable from "../hooks/useHTable";
|
|
2
|
-
import type {
|
|
3
|
-
HDiaLogTableInstance,
|
|
4
|
-
HOnDiaLogTableInstance,
|
|
5
|
-
ModalTableProps,
|
|
6
|
-
} from "../modal";
|
|
7
|
-
import { useEffect, useMemo, useState } from "react";
|
|
8
|
-
import type { DialogParamsModal } from "../modal";
|
|
9
|
-
|
|
10
|
-
export const useHDialogTable = () => {
|
|
11
|
-
const tableInstance = useHTable();
|
|
12
|
-
return useMemo(() => {
|
|
13
|
-
return {
|
|
14
|
-
...tableInstance,
|
|
15
|
-
show: (params: DialogParamsModal) => {},
|
|
16
|
-
hide: () => {},
|
|
17
|
-
} as HDiaLogTableInstance;
|
|
18
|
-
}, []);
|
|
19
|
-
};
|
|
20
|
-
interface ParamsModal extends HOnDiaLogTableInstance {
|
|
21
|
-
dialogTable?: HDiaLogTableInstance;
|
|
22
|
-
}
|
|
23
|
-
export const useTableProps = ({
|
|
24
|
-
configData,
|
|
25
|
-
params,
|
|
26
|
-
title,
|
|
27
|
-
request,
|
|
28
|
-
}: Omit<ModalTableProps, "tableProps">) => {
|
|
29
|
-
const [modalTableParams, setModalTableParams] = useState({
|
|
30
|
-
params,
|
|
31
|
-
title,
|
|
32
|
-
configData,
|
|
33
|
-
request,
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
modalTableParams,
|
|
37
|
-
setModalTableParams,
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export const useCurrentTable = ({ show, hide, dialogTable }: ParamsModal) => {
|
|
41
|
-
const cuDialogTableInstance = useHDialogTable();
|
|
42
|
-
const dialogTableInstance = dialogTable || cuDialogTableInstance;
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
dialogTableInstance.show = show;
|
|
45
|
-
dialogTableInstance.hide = hide;
|
|
46
|
-
}, []);
|
|
47
|
-
return dialogTableInstance;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const useVisible = (visible: boolean) => {
|
|
51
|
-
const [modalVisible, setModalVisible] = useState(visible);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
setModalVisible(visible);
|
|
54
|
-
}, [visible]);
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
modalVisible,
|
|
58
|
-
setModalVisible,
|
|
59
|
-
};
|
|
60
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Modal } from "antd";
|
|
2
|
-
import Table from "../Table";
|
|
3
|
-
import type { ModalTableProps } from "../modal";
|
|
4
|
-
import { useCurrentTable, useTableProps, useVisible } from "./hooks";
|
|
5
|
-
export default ({
|
|
6
|
-
configData: configDataProps,
|
|
7
|
-
request: requestProps,
|
|
8
|
-
tableProps,
|
|
9
|
-
dialogTable,
|
|
10
|
-
visible = false,
|
|
11
|
-
onCancel,
|
|
12
|
-
bodyStyle = {},
|
|
13
|
-
afterClose,
|
|
14
|
-
...props
|
|
15
|
-
}: ModalTableProps) => {
|
|
16
|
-
const { modalVisible, setModalVisible } = useVisible(visible);
|
|
17
|
-
const { modalTableParams, setModalTableParams } = useTableProps({
|
|
18
|
-
...props,
|
|
19
|
-
configData: configDataProps,
|
|
20
|
-
request: requestProps,
|
|
21
|
-
});
|
|
22
|
-
const currentTable = useCurrentTable({
|
|
23
|
-
show: (showParams) => {
|
|
24
|
-
if (showParams) {
|
|
25
|
-
setModalTableParams((oldParams) => {
|
|
26
|
-
const { configData, request, title } = oldParams;
|
|
27
|
-
const {
|
|
28
|
-
title: showTitle = title,
|
|
29
|
-
configData: showConfigData = configData,
|
|
30
|
-
request: showReq,
|
|
31
|
-
params = request,
|
|
32
|
-
} = showParams;
|
|
33
|
-
return {
|
|
34
|
-
title: showTitle,
|
|
35
|
-
request: showReq,
|
|
36
|
-
configData: showConfigData,
|
|
37
|
-
params,
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
setModalVisible(true);
|
|
42
|
-
},
|
|
43
|
-
hide: () => {
|
|
44
|
-
setModalVisible(false);
|
|
45
|
-
},
|
|
46
|
-
dialogTable,
|
|
47
|
-
});
|
|
48
|
-
const { configData, request, title, params } = modalTableParams;
|
|
49
|
-
const req = request
|
|
50
|
-
? (reqParams) => {
|
|
51
|
-
return request({ ...params, ...reqParams });
|
|
52
|
-
}
|
|
53
|
-
: undefined;
|
|
54
|
-
return (
|
|
55
|
-
<Modal
|
|
56
|
-
{...props}
|
|
57
|
-
visible={modalVisible}
|
|
58
|
-
onCancel={(e) => {
|
|
59
|
-
setModalVisible(false);
|
|
60
|
-
onCancel?.(e);
|
|
61
|
-
}}
|
|
62
|
-
destroyOnClose
|
|
63
|
-
title={title}
|
|
64
|
-
bodyStyle={{ padding: 0, paddingBottom: 24, ...bodyStyle }}
|
|
65
|
-
afterClose={() => {
|
|
66
|
-
currentTable.form.resetFields();
|
|
67
|
-
afterClose?.();
|
|
68
|
-
}}
|
|
69
|
-
>
|
|
70
|
-
<Table
|
|
71
|
-
{...tableProps}
|
|
72
|
-
configData={configData || []}
|
|
73
|
-
table={currentTable}
|
|
74
|
-
request={req}
|
|
75
|
-
/>
|
|
76
|
-
</Modal>
|
|
77
|
-
);
|
|
78
|
-
};
|
package/src/components/Table.tsx
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import Header from "./HTableHeader";
|
|
2
|
-
import Body from "./HTableBody";
|
|
3
|
-
import useCurrentTable from "./hooks/useCurrentTable";
|
|
4
|
-
import useRowObj from "./hooks/useRowObj";
|
|
5
|
-
import { HTableContext } from "./context";
|
|
6
|
-
import { Space } from "antd";
|
|
7
|
-
import type { HTableProps } from "./modal";
|
|
8
|
-
import useReq from "./hooks/useReq";
|
|
9
|
-
import useDispatch from "./hooks/useDispatch";
|
|
10
|
-
export default ({
|
|
11
|
-
request,
|
|
12
|
-
configData,
|
|
13
|
-
searchSpan,
|
|
14
|
-
table,
|
|
15
|
-
hideHeader,
|
|
16
|
-
headerStyle = {},
|
|
17
|
-
tableStyle = {},
|
|
18
|
-
action = {},
|
|
19
|
-
spaceSize = 15,
|
|
20
|
-
className,
|
|
21
|
-
paginationStyle,
|
|
22
|
-
rowKey = "id",
|
|
23
|
-
...props
|
|
24
|
-
}: HTableProps) => {
|
|
25
|
-
const { run, loading, data, error, saveParams } = useReq({ request });
|
|
26
|
-
const dispatch = useDispatch(action);
|
|
27
|
-
const { selectedRowData, rowOnChange, allSelectChange, setSelectedRowData } =
|
|
28
|
-
useRowObj();
|
|
29
|
-
const tableInstance = useCurrentTable({
|
|
30
|
-
table,
|
|
31
|
-
reload: (params) => {
|
|
32
|
-
rowOnChange([], []);
|
|
33
|
-
return run(params);
|
|
34
|
-
},
|
|
35
|
-
changeRowData: rowOnChange,
|
|
36
|
-
dispatch,
|
|
37
|
-
reloadWithParams: (reloadParams = {}) => {
|
|
38
|
-
rowOnChange([], []);
|
|
39
|
-
return run({ ...saveParams.old, ...reloadParams });
|
|
40
|
-
},
|
|
41
|
-
getTableParams: () => {
|
|
42
|
-
return saveParams.old;
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
return (
|
|
46
|
-
<HTableContext.Provider
|
|
47
|
-
value={{
|
|
48
|
-
tableInstance,
|
|
49
|
-
selectedRowData,
|
|
50
|
-
rowOnChange,
|
|
51
|
-
data,
|
|
52
|
-
error,
|
|
53
|
-
loading,
|
|
54
|
-
allSelectChange,
|
|
55
|
-
action,
|
|
56
|
-
configData,
|
|
57
|
-
onFinish: (value) => {
|
|
58
|
-
rowOnChange([], []);
|
|
59
|
-
return run(value);
|
|
60
|
-
},
|
|
61
|
-
onPageChange: tableInstance.table.reloadWithParams,
|
|
62
|
-
setSelectedRowData,
|
|
63
|
-
rowKey,
|
|
64
|
-
}}
|
|
65
|
-
>
|
|
66
|
-
<Space direction={"vertical"} size={0} style={{ width: "100%" }}>
|
|
67
|
-
{!hideHeader && (
|
|
68
|
-
<Header searchSpan={searchSpan} headerStyle={headerStyle} />
|
|
69
|
-
)}
|
|
70
|
-
<Body
|
|
71
|
-
tableStyle={
|
|
72
|
-
hideHeader ? { paddingTop: 24, ...tableStyle } : tableStyle
|
|
73
|
-
}
|
|
74
|
-
paginationStyle={paginationStyle}
|
|
75
|
-
rowKey={rowKey}
|
|
76
|
-
{...props}
|
|
77
|
-
/>
|
|
78
|
-
</Space>
|
|
79
|
-
</HTableContext.Provider>
|
|
80
|
-
);
|
|
81
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
import type { HTableInstance } from "./modal";
|
|
3
|
-
|
|
4
|
-
interface HTableConfigContextModal {
|
|
5
|
-
emptyRender?: (table: HTableInstance) => React.ReactNode;
|
|
6
|
-
errorRender?: (table: HTableInstance, error: Error) => React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export const HTableConfigContext =
|
|
9
|
-
React.createContext<HTableConfigContextModal | null>(null);
|
|
10
|
-
|
|
11
|
-
export const useHTableConfigContext = ({
|
|
12
|
-
emptyRender,
|
|
13
|
-
errorRender,
|
|
14
|
-
}: HTableConfigContextModal) => {
|
|
15
|
-
const { errorRender: configErrorRender, emptyRender: configEmptyRender } =
|
|
16
|
-
useContext(HTableConfigContext) || {};
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
errorRender: errorRender || configErrorRender,
|
|
20
|
-
emptyRender: emptyRender || configEmptyRender,
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
const Index: React.FC<HTableConfigContextModal> = ({ children, ...props }) => {
|
|
24
|
-
return (
|
|
25
|
-
<HTableConfigContext.Provider value={props}>
|
|
26
|
-
{children}
|
|
27
|
-
</HTableConfigContext.Provider>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
export default Index;
|
|
@@ -1,67 +0,0 @@
|
|
|
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 type { IParamsModal } from "./hooks/useReq";
|
|
6
|
-
import useReq from "./hooks/useReq";
|
|
7
|
-
import useDispatch from "./hooks/useDispatch";
|
|
8
|
-
import React from "react";
|
|
9
|
-
const Index: React.FC<HTableProps> = ({
|
|
10
|
-
request,
|
|
11
|
-
configData,
|
|
12
|
-
table,
|
|
13
|
-
action = {},
|
|
14
|
-
children,
|
|
15
|
-
rowKey,
|
|
16
|
-
...props
|
|
17
|
-
}) => {
|
|
18
|
-
const { run, loading, data, error, saveParams } = useReq({
|
|
19
|
-
request,
|
|
20
|
-
...props,
|
|
21
|
-
} as IParamsModal);
|
|
22
|
-
const dispatch = useDispatch(action);
|
|
23
|
-
const { selectedRowData, rowOnChange, allSelectChange, setSelectedRowData } =
|
|
24
|
-
useRowObj();
|
|
25
|
-
const tableInstance = useCurrentTable({
|
|
26
|
-
table,
|
|
27
|
-
reload: (params) => {
|
|
28
|
-
rowOnChange([], []);
|
|
29
|
-
return run(params);
|
|
30
|
-
},
|
|
31
|
-
changeRowData: rowOnChange,
|
|
32
|
-
dispatch,
|
|
33
|
-
reloadWithParams: (reloadParams = {}) => {
|
|
34
|
-
rowOnChange([], []);
|
|
35
|
-
return run({ ...saveParams.old, ...reloadParams });
|
|
36
|
-
},
|
|
37
|
-
getTableParams: () => {
|
|
38
|
-
return saveParams.old;
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
return (
|
|
42
|
-
<HTableContext.Provider
|
|
43
|
-
value={{
|
|
44
|
-
tableInstance,
|
|
45
|
-
selectedRowData,
|
|
46
|
-
rowOnChange,
|
|
47
|
-
data,
|
|
48
|
-
error,
|
|
49
|
-
loading,
|
|
50
|
-
allSelectChange,
|
|
51
|
-
action,
|
|
52
|
-
configData,
|
|
53
|
-
params: saveParams.old,
|
|
54
|
-
onFinish: (value) => {
|
|
55
|
-
rowOnChange([], []);
|
|
56
|
-
return run(value);
|
|
57
|
-
},
|
|
58
|
-
onPageChange: tableInstance.table.reloadWithParams,
|
|
59
|
-
setSelectedRowData,
|
|
60
|
-
rowKey,
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
{children}
|
|
64
|
-
</HTableContext.Provider>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
export default Index;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
import type { ResultModal, RowObj, HTableInstance } from "./modal";
|
|
3
|
-
import type { HTableProps } from "./modal";
|
|
4
|
-
|
|
5
|
-
interface HContextModal extends Omit<HTableProps, "request"> {
|
|
6
|
-
tableInstance: HTableInstance;
|
|
7
|
-
data?: ResultModal;
|
|
8
|
-
selectedRowData: RowObj;
|
|
9
|
-
rowOnChange: (keys: React.Key[], rowData: any[]) => void;
|
|
10
|
-
error?: Error;
|
|
11
|
-
loading?: boolean;
|
|
12
|
-
allSelectChange?: (checked?: boolean) => void;
|
|
13
|
-
params?: any;
|
|
14
|
-
onFinish: (value: Record<string, any>) => Promise<any>;
|
|
15
|
-
onPageChange: (value: Record<string, any>) => Promise<any>;
|
|
16
|
-
setSelectedRowData: (row: RowObj) => void;
|
|
17
|
-
rowKey?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const HTableContext = React.createContext<HContextModal | null>(null);
|
|
21
|
-
|
|
22
|
-
export const useHTableContext = () => {
|
|
23
|
-
const result = useContext(HTableContext);
|
|
24
|
-
return (result || {}) as HContextModal;
|
|
25
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useContext, useMemo } from "react";
|
|
2
|
-
import { ConfigContext } from "antd/es/config-provider";
|
|
3
|
-
export const useClassName = (className: string | string[]) => {
|
|
4
|
-
const config = useContext(ConfigContext);
|
|
5
|
-
return useMemo(() => {
|
|
6
|
-
if (Array.isArray(className)) {
|
|
7
|
-
const classNames = className.map((item) => {
|
|
8
|
-
return `${config.getPrefixCls()}-${item}`;
|
|
9
|
-
});
|
|
10
|
-
return classNames.join(" ");
|
|
11
|
-
}
|
|
12
|
-
return `${config.getPrefixCls()}-${className}`;
|
|
13
|
-
}, [className]);
|
|
14
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import type { ParamsModal, HTableInstance } from "../modal";
|
|
4
|
-
import useHTable from "../hooks/useHTable";
|
|
5
|
-
|
|
6
|
-
interface currentTableParams {
|
|
7
|
-
table?: HTableInstance;
|
|
8
|
-
reload: (params?: ParamsModal) => Promise<any>;
|
|
9
|
-
changeRowData: (keys: React.Key[], data: any) => void;
|
|
10
|
-
dispatch: (key: string, params: any) => void;
|
|
11
|
-
reloadWithParams: (params?: ParamsModal) => Promise<any>;
|
|
12
|
-
getTableParams: () => any;
|
|
13
|
-
}
|
|
14
|
-
export default ({
|
|
15
|
-
table,
|
|
16
|
-
reload,
|
|
17
|
-
changeRowData,
|
|
18
|
-
dispatch,
|
|
19
|
-
reloadWithParams,
|
|
20
|
-
getTableParams,
|
|
21
|
-
}: currentTableParams) => {
|
|
22
|
-
const useCurrentTable = useHTable();
|
|
23
|
-
return useMemo(() => {
|
|
24
|
-
const resultTable = table || useCurrentTable;
|
|
25
|
-
resultTable.table.reload = reload;
|
|
26
|
-
resultTable.table.setSelectedRowData = changeRowData;
|
|
27
|
-
resultTable.table.dispatch = dispatch;
|
|
28
|
-
resultTable.table.reloadWithParams = reloadWithParams;
|
|
29
|
-
resultTable.table.getParams = getTableParams;
|
|
30
|
-
return resultTable;
|
|
31
|
-
}, [table]);
|
|
32
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import type { ParamsModal } from "../modal";
|
|
3
|
-
import { useHForm } from "@hw-component/form";
|
|
4
|
-
|
|
5
|
-
export default () => {
|
|
6
|
-
const form = useHForm();
|
|
7
|
-
const table = useMemo(() => {
|
|
8
|
-
return {
|
|
9
|
-
reload: (params?: ParamsModal) => {
|
|
10
|
-
return Promise.resolve(params);
|
|
11
|
-
},
|
|
12
|
-
setSelectedRowData: () => {},
|
|
13
|
-
dispatch: () => {},
|
|
14
|
-
reloadWithParams: (params?: ParamsModal) => {
|
|
15
|
-
return Promise.resolve(params);
|
|
16
|
-
},
|
|
17
|
-
getParams: () => {
|
|
18
|
-
return {} as any;
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
}, []);
|
|
22
|
-
return {
|
|
23
|
-
form,
|
|
24
|
-
table,
|
|
25
|
-
};
|
|
26
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo } from "react";
|
|
2
|
-
import { useRequest } from "ahooks";
|
|
3
|
-
import type { ParamsModal, ResultModal } from "@/components/modal";
|
|
4
|
-
export interface IParamsModal {
|
|
5
|
-
request?: (params: ParamsModal) => Promise<ResultModal>;
|
|
6
|
-
loading?: boolean;
|
|
7
|
-
error?: Error;
|
|
8
|
-
reload?: (params: any) => Promise<any>;
|
|
9
|
-
dataSource?: any;
|
|
10
|
-
manual?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export default ({
|
|
13
|
-
request,
|
|
14
|
-
loading,
|
|
15
|
-
error,
|
|
16
|
-
reload,
|
|
17
|
-
dataSource,
|
|
18
|
-
manual = false,
|
|
19
|
-
}: IParamsModal) => {
|
|
20
|
-
const saveParams = useMemo(() => {
|
|
21
|
-
return {
|
|
22
|
-
old: {},
|
|
23
|
-
};
|
|
24
|
-
}, []);
|
|
25
|
-
const reloadFn = async (params: Record<string, any> = {}) => {
|
|
26
|
-
const { size = "10", current = "1", ...oParams } = params;
|
|
27
|
-
const reqParams = { size, current, ...oParams };
|
|
28
|
-
saveParams.old = reqParams;
|
|
29
|
-
return reload?.(reqParams);
|
|
30
|
-
};
|
|
31
|
-
const resultAction = useRequest(
|
|
32
|
-
(params = {}) => {
|
|
33
|
-
const { size = "10", current = "1", ...oParams } = params;
|
|
34
|
-
const reqParams = { size, current, ...oParams };
|
|
35
|
-
saveParams.old = reqParams;
|
|
36
|
-
return request?.(reqParams);
|
|
37
|
-
},
|
|
38
|
-
{ manual: true }
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (manual) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (request) {
|
|
46
|
-
resultAction.run();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
reloadFn();
|
|
50
|
-
}, []);
|
|
51
|
-
|
|
52
|
-
if (request) {
|
|
53
|
-
return {
|
|
54
|
-
...resultAction,
|
|
55
|
-
saveParams,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
loading,
|
|
60
|
-
error,
|
|
61
|
-
data: dataSource,
|
|
62
|
-
run: reloadFn,
|
|
63
|
-
saveParams,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import type { RowObj } from "../modal";
|
|
4
|
-
|
|
5
|
-
export default () => {
|
|
6
|
-
const [selectedRowData, setSelectedRowData] = useState<RowObj>({});
|
|
7
|
-
const { selectAll = false } = selectedRowData;
|
|
8
|
-
const rowOnChange = (keys: React.Key[], rowData: any[]) => {
|
|
9
|
-
setSelectedRowData({
|
|
10
|
-
keys,
|
|
11
|
-
rowData,
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
const allSelectChange = (checked?: boolean) => {
|
|
15
|
-
const newChecked = typeof checked === "undefined" ? !selectAll : checked;
|
|
16
|
-
setSelectedRowData({
|
|
17
|
-
selectAll: newChecked,
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
rowOnChange,
|
|
23
|
-
selectedRowData,
|
|
24
|
-
allSelectChange,
|
|
25
|
-
setSelectedRowData,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
@import "./styles/local.less";
|
|
2
|
-
.@{ant-prefix}-hw-table-body{
|
|
3
|
-
border-bottom-left-radius: 4px;
|
|
4
|
-
border-bottom-right-radius: 4px;
|
|
5
|
-
background-color: #fff;
|
|
6
|
-
position: relative;
|
|
7
|
-
.@{ant-prefix}-hw-table-pagination{
|
|
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;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
.@{ant-prefix}-hw-table-pagination{
|
|
20
|
-
padding: 24px;
|
|
21
|
-
border-radius: 4px;
|
|
22
|
-
background-color: #ffffff;
|
|
23
|
-
position: relative;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.@{ant-prefix}-hw-top-btn{
|
|
27
|
-
position: absolute;
|
|
28
|
-
right: 10px;
|
|
29
|
-
bottom: 54px;
|
|
30
|
-
z-index: 9;
|
|
31
|
-
cursor: pointer;
|
|
32
|
-
width: 48px;
|
|
33
|
-
height: 48px;
|
|
34
|
-
background: url("./GoTop/goTop.png") no-repeat;
|
|
35
|
-
background-size: 100%;
|
|
36
|
-
}
|
|
37
|
-
.@{ant-prefix}-hw-table-header{
|
|
38
|
-
border-top-left-radius: 4px;
|
|
39
|
-
border-top-right-radius: 4px;
|
|
40
|
-
padding-bottom: 0px;
|
|
41
|
-
}
|
package/src/components/index.tsx
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import "./index.less";
|
|
2
|
-
export { default as HTable } from "./Table";
|
|
3
|
-
export { default as useHTable } from "./hooks/useHTable";
|
|
4
|
-
export { default as HTableConfig } from "./TableConfig";
|
|
5
|
-
export { default as TableCustomize } from "./TableCustomize";
|
|
6
|
-
export { default as HTableBody } from "./HTableBody";
|
|
7
|
-
export { default as HTableFooter } from "./HTableFooter";
|
|
8
|
-
export { default as HTableHeader } from "./HTableHeader";
|
|
9
|
-
export { default as HTablePagination } from "./HTablePagination";
|
|
10
|
-
export { default as HModalTable } from "./ModalTable";
|
|
11
|
-
export { useHDialogTable } from "./ModalTable/hooks";
|