@hw-component/table 1.1.8 → 1.1.9
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/Options/hooks.d.ts +2 -2
- package/es/HTableBody/Options/index.d.ts +1 -1
- package/es/HTableBody/Options/index.js +23 -22
- package/es/HTableBody/hooks.d.ts +3 -3
- package/es/HTableBody/index.d.ts +6 -1
- package/es/HTableBody/utils.d.ts +2 -2
- package/es/HTableHeader/Context.d.ts +1 -1
- package/es/HTableHeader/defaultSubComponent.js +5 -1
- package/es/HTableHeader/index.d.ts +1 -1
- package/es/modal.d.ts +2 -0
- package/lib/HTableBody/Options/hooks.d.ts +2 -2
- package/lib/HTableBody/Options/index.d.ts +1 -1
- package/lib/HTableBody/Options/index.js +23 -22
- package/lib/HTableBody/hooks.d.ts +3 -3
- package/lib/HTableBody/index.d.ts +6 -1
- package/lib/HTableBody/utils.d.ts +2 -2
- package/lib/HTableHeader/Context.d.ts +1 -1
- package/lib/HTableHeader/defaultSubComponent.js +5 -1
- package/lib/HTableHeader/index.d.ts +1 -1
- package/lib/modal.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/HTableBody/Options/Content.tsx +13 -13
- package/src/components/HTableBody/Options/Title.tsx +18 -18
- package/src/components/HTableBody/Options/hooks.ts +23 -20
- package/src/components/HTableBody/Options/index.tsx +23 -18
- package/src/components/HTableBody/Options/modal.d.ts +8 -6
- package/src/components/HTableBody/Options/utils.ts +2 -2
- package/src/components/HTableBody/hooks.tsx +43 -40
- package/src/components/HTableBody/index.tsx +19 -4
- package/src/components/HTableBody/utils.ts +85 -83
- package/src/components/HTableHeader/Context.tsx +7 -7
- package/src/components/HTableHeader/defaultSubComponent.tsx +7 -3
- package/src/components/HTableHeader/index.tsx +15 -15
- package/src/components/HTableHeader/modal.ts +1 -1
- package/src/components/Table.tsx +0 -1
- package/src/components/hooks/useHTable.tsx +4 -4
- package/src/components/modal.ts +4 -8
- package/src/pages/Table/index.tsx +25 -12
- package/src/pages/TableCustomize/index.tsx +13 -8
|
@@ -18,7 +18,8 @@ var Options = (function (_ref) {
|
|
|
18
18
|
columns = _ref.columns,
|
|
19
19
|
onChange = _ref.onChange,
|
|
20
20
|
colStatusValue = _ref.colStatusValue,
|
|
21
|
-
reset = _ref.reset
|
|
21
|
+
reset = _ref.reset,
|
|
22
|
+
settingRender = _ref.settingRender;
|
|
22
23
|
var pointer = useClassName(["hw-table-pointer", "hw-table-body-option-icon"]);
|
|
23
24
|
var ref = useRef(null);
|
|
24
25
|
var checkKeys = useCheckKeys({
|
|
@@ -54,9 +55,8 @@ var Options = (function (_ref) {
|
|
|
54
55
|
};
|
|
55
56
|
return jsx(Row, {
|
|
56
57
|
justify: "end",
|
|
57
|
-
ref: ref,
|
|
58
58
|
children: jsxs(Space, {
|
|
59
|
-
size:
|
|
59
|
+
size: 15,
|
|
60
60
|
children: [reload && jsx(Tooltip, {
|
|
61
61
|
title: "\u5237\u65B0",
|
|
62
62
|
children: jsx(ReloadOutlined, {
|
|
@@ -80,25 +80,26 @@ var Options = (function (_ref) {
|
|
|
80
80
|
width: 24
|
|
81
81
|
})
|
|
82
82
|
})
|
|
83
|
-
}), jsx(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
83
|
+
}), jsx(Popover, {
|
|
84
|
+
content: jsx(ColsSettingContent, {
|
|
85
|
+
columns: columns,
|
|
86
|
+
checkKeys: checkKeys,
|
|
87
|
+
onCheck: onChange
|
|
88
|
+
}),
|
|
89
|
+
title: jsx(Title, {
|
|
90
|
+
columns: columns,
|
|
91
|
+
reset: reset,
|
|
92
|
+
checkKeys: checkKeys,
|
|
93
|
+
onCheck: onChange
|
|
94
|
+
}),
|
|
95
|
+
placement: "bottomRight",
|
|
96
|
+
getPopupContainer: function getPopupContainer() {
|
|
97
|
+
return ref.current || document.body;
|
|
98
|
+
},
|
|
99
|
+
arrowPointAtCenter: true,
|
|
100
|
+
trigger: "click",
|
|
101
|
+
children: settingRender ? settingRender() : jsx(Tooltip, {
|
|
102
|
+
title: "\u5217\u8BBE\u7F6E",
|
|
102
103
|
children: jsx(SettingOutlined, {
|
|
103
104
|
className: pointer,
|
|
104
105
|
width: 24
|
package/es/HTableBody/hooks.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { HTableProps, ConfigDataModal } from "../modal";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { GetRowKey } from "rc-table/lib/interface";
|
|
4
4
|
import type { SizeType } from "antd/lib/config-provider/SizeContext";
|
|
5
|
-
import { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
6
|
-
import { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
5
|
+
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
6
|
+
import type { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
7
7
|
export declare const useCols: ({ configData, rowSelection, table }: HTableProps) => {
|
|
8
8
|
cols: ConfigDataModal;
|
|
9
9
|
};
|
|
@@ -21,7 +21,7 @@ interface useColumnsStateTypeModal {
|
|
|
21
21
|
columnsState?: ColumnsStateType;
|
|
22
22
|
columns: ConfigDataModal;
|
|
23
23
|
}
|
|
24
|
-
export declare const useColumnsStateType: ({ columnsState, columns }: useColumnsStateTypeModal) => {
|
|
24
|
+
export declare const useColumnsStateType: ({ columnsState, columns, }: useColumnsStateTypeModal) => {
|
|
25
25
|
persistenceType: "localStorage" | "sessionStorage" | undefined;
|
|
26
26
|
persistenceKey: string | undefined;
|
|
27
27
|
value: Record<string, ColumnsState> | undefined;
|
package/es/HTableBody/index.d.ts
CHANGED
|
@@ -2,7 +2,11 @@ import type { ProTableProps } from "@ant-design/pro-table";
|
|
|
2
2
|
import type { ActionRenderFn, ConfigDataModal, ParamsModal, HTableInstance, HRowSelection } from "../modal";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import type { AffixProps } from "antd/lib/affix";
|
|
5
|
-
|
|
5
|
+
import { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar";
|
|
6
|
+
export interface OptionModal extends OptionConfig {
|
|
7
|
+
settingRender?: () => React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection" | "options"> {
|
|
6
10
|
configData?: ConfigDataModal;
|
|
7
11
|
onPageChange?: (params: ParamsModal) => void;
|
|
8
12
|
emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
@@ -16,6 +20,7 @@ export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSour
|
|
|
16
20
|
optionsRender?: (node: React.ReactNode) => React.ReactNode;
|
|
17
21
|
paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
18
22
|
localSorter?: boolean;
|
|
23
|
+
options?: OptionModal | false;
|
|
19
24
|
}
|
|
20
25
|
declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, size, optionsRender, paginationActionRender, localSorter, columnsState, ...props }: HTableBodyProps) => JSX.Element;
|
|
21
26
|
export default _default;
|
package/es/HTableBody/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
2
|
-
import { ConfigDataModal } from "@/components/modal";
|
|
1
|
+
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
2
|
+
import type { ConfigDataModal } from "@/components/modal";
|
|
3
3
|
export declare const mkChangeValue: (columnsState?: ColumnsStateType) => any;
|
|
4
4
|
export declare const outColSetting: (columns: ConfigDataModal, columnsState?: ColumnsStateType) => {
|
|
5
5
|
checkCols: ConfigDataModal;
|
|
@@ -81,7 +81,11 @@ var DefaultSubComponent = function DefaultSubComponent(_ref) {
|
|
|
81
81
|
borderRadius: 4
|
|
82
82
|
},
|
|
83
83
|
onClick: function onClick() {
|
|
84
|
-
|
|
84
|
+
if (onReset) {
|
|
85
|
+
onReset();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
form.resetFields();
|
|
85
89
|
},
|
|
86
90
|
children: "\u91CD\u7F6E"
|
|
87
91
|
}), hide ? null : jsx(OpenComponent, {})]
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IHeaderProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, onFinish, searchSpan, headerStyle, initValues, hideLabel, labelWidth, onReset }: IHeaderProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, onFinish, searchSpan, headerStyle, initValues, hideLabel, labelWidth, onReset, }: IHeaderProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/es/modal.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type React from "react";
|
|
|
6
6
|
import type { ModalProps } from "antd";
|
|
7
7
|
import type { TableProps } from "antd/lib/table";
|
|
8
8
|
import type { AffixProps } from "antd/lib/affix";
|
|
9
|
+
import { OptionModal } from "./HTableBody";
|
|
9
10
|
export interface RowObj {
|
|
10
11
|
keys?: React.Key[];
|
|
11
12
|
rowData?: any[];
|
|
@@ -75,6 +76,7 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
|
|
|
75
76
|
formInitValues?: Record<string, any>;
|
|
76
77
|
labelWidth?: number;
|
|
77
78
|
hideLabel?: boolean;
|
|
79
|
+
options?: OptionModal | false;
|
|
78
80
|
}
|
|
79
81
|
interface ColCheckResultKeys {
|
|
80
82
|
keys?: string[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IProps } from "@/components/HTableBody/Options/modal";
|
|
2
|
-
export declare const useCheckKeys: ({ columns, colStatusValue }: Pick<IProps, "colStatusValue" | "columns">) => string[];
|
|
1
|
+
import type { IProps } from "@/components/HTableBody/Options/modal";
|
|
2
|
+
export declare const useCheckKeys: ({ columns, colStatusValue, }: Pick<IProps, "colStatusValue" | "columns">) => string[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IProps } from "./modal";
|
|
2
|
-
declare const _default: ({ reload, size, density, setSizeChange, columns, onChange, colStatusValue, reset }: IProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ reload, size, density, setSizeChange, columns, onChange, colStatusValue, reset, settingRender, }: IProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
|
@@ -21,7 +21,8 @@ var Options = (function (_ref) {
|
|
|
21
21
|
columns = _ref.columns,
|
|
22
22
|
onChange = _ref.onChange,
|
|
23
23
|
colStatusValue = _ref.colStatusValue,
|
|
24
|
-
reset = _ref.reset
|
|
24
|
+
reset = _ref.reset,
|
|
25
|
+
settingRender = _ref.settingRender;
|
|
25
26
|
var pointer = index.useClassName(["hw-table-pointer", "hw-table-body-option-icon"]);
|
|
26
27
|
var ref = React.useRef(null);
|
|
27
28
|
var checkKeys = hooks.useCheckKeys({
|
|
@@ -57,9 +58,8 @@ var Options = (function (_ref) {
|
|
|
57
58
|
};
|
|
58
59
|
return jsxRuntime.jsx(antd.Row, {
|
|
59
60
|
justify: "end",
|
|
60
|
-
ref: ref,
|
|
61
61
|
children: jsxRuntime.jsxs(antd.Space, {
|
|
62
|
-
size:
|
|
62
|
+
size: 15,
|
|
63
63
|
children: [reload && jsxRuntime.jsx(antd.Tooltip, {
|
|
64
64
|
title: "\u5237\u65B0",
|
|
65
65
|
children: jsxRuntime.jsx(icons.ReloadOutlined, {
|
|
@@ -83,25 +83,26 @@ var Options = (function (_ref) {
|
|
|
83
83
|
width: 24
|
|
84
84
|
})
|
|
85
85
|
})
|
|
86
|
-
}), jsxRuntime.jsx(antd.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
86
|
+
}), jsxRuntime.jsx(antd.Popover, {
|
|
87
|
+
content: jsxRuntime.jsx(Content.ColsSettingContent, {
|
|
88
|
+
columns: columns,
|
|
89
|
+
checkKeys: checkKeys,
|
|
90
|
+
onCheck: onChange
|
|
91
|
+
}),
|
|
92
|
+
title: jsxRuntime.jsx(Title.Title, {
|
|
93
|
+
columns: columns,
|
|
94
|
+
reset: reset,
|
|
95
|
+
checkKeys: checkKeys,
|
|
96
|
+
onCheck: onChange
|
|
97
|
+
}),
|
|
98
|
+
placement: "bottomRight",
|
|
99
|
+
getPopupContainer: function getPopupContainer() {
|
|
100
|
+
return ref.current || document.body;
|
|
101
|
+
},
|
|
102
|
+
arrowPointAtCenter: true,
|
|
103
|
+
trigger: "click",
|
|
104
|
+
children: settingRender ? settingRender() : jsxRuntime.jsx(antd.Tooltip, {
|
|
105
|
+
title: "\u5217\u8BBE\u7F6E",
|
|
105
106
|
children: jsxRuntime.jsx(icons.SettingOutlined, {
|
|
106
107
|
className: pointer,
|
|
107
108
|
width: 24
|
|
@@ -2,8 +2,8 @@ import type { HTableProps, ConfigDataModal } from "../modal";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { GetRowKey } from "rc-table/lib/interface";
|
|
4
4
|
import type { SizeType } from "antd/lib/config-provider/SizeContext";
|
|
5
|
-
import { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
6
|
-
import { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
5
|
+
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
6
|
+
import type { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
7
7
|
export declare const useCols: ({ configData, rowSelection, table }: HTableProps) => {
|
|
8
8
|
cols: ConfigDataModal;
|
|
9
9
|
};
|
|
@@ -21,7 +21,7 @@ interface useColumnsStateTypeModal {
|
|
|
21
21
|
columnsState?: ColumnsStateType;
|
|
22
22
|
columns: ConfigDataModal;
|
|
23
23
|
}
|
|
24
|
-
export declare const useColumnsStateType: ({ columnsState, columns }: useColumnsStateTypeModal) => {
|
|
24
|
+
export declare const useColumnsStateType: ({ columnsState, columns, }: useColumnsStateTypeModal) => {
|
|
25
25
|
persistenceType: "localStorage" | "sessionStorage" | undefined;
|
|
26
26
|
persistenceKey: string | undefined;
|
|
27
27
|
value: Record<string, ColumnsState> | undefined;
|
|
@@ -2,7 +2,11 @@ import type { ProTableProps } from "@ant-design/pro-table";
|
|
|
2
2
|
import type { ActionRenderFn, ConfigDataModal, ParamsModal, HTableInstance, HRowSelection } from "../modal";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import type { AffixProps } from "antd/lib/affix";
|
|
5
|
-
|
|
5
|
+
import { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar";
|
|
6
|
+
export interface OptionModal extends OptionConfig {
|
|
7
|
+
settingRender?: () => React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSource" | "rowSelection" | "options"> {
|
|
6
10
|
configData?: ConfigDataModal;
|
|
7
11
|
onPageChange?: (params: ParamsModal) => void;
|
|
8
12
|
emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
@@ -16,6 +20,7 @@ export interface HTableBodyProps extends Omit<ProTableProps<any, any>, "dataSour
|
|
|
16
20
|
optionsRender?: (node: React.ReactNode) => React.ReactNode;
|
|
17
21
|
paginationActionRender?: (tableInstance: HTableInstance) => React.ReactNode;
|
|
18
22
|
localSorter?: boolean;
|
|
23
|
+
options?: OptionModal | false;
|
|
19
24
|
}
|
|
20
25
|
declare const _default: ({ configData, pagination, onPageChange, rowSelection, rowKey, emptyRender, errorRender, tableStyle, paginationStyle, headerTitle, options, actionRender, affixProps, goTop, size, optionsRender, paginationActionRender, localSorter, columnsState, ...props }: HTableBodyProps) => JSX.Element;
|
|
21
26
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
2
|
-
import { ConfigDataModal } from "@/components/modal";
|
|
1
|
+
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
2
|
+
import type { ConfigDataModal } from "@/components/modal";
|
|
3
3
|
export declare const mkChangeValue: (columnsState?: ColumnsStateType) => any;
|
|
4
4
|
export declare const outColSetting: (columns: ConfigDataModal, columnsState?: ColumnsStateType) => {
|
|
5
5
|
checkCols: ConfigDataModal;
|
|
@@ -82,7 +82,11 @@ var DefaultSubComponent = function DefaultSubComponent(_ref) {
|
|
|
82
82
|
borderRadius: 4
|
|
83
83
|
},
|
|
84
84
|
onClick: function onClick() {
|
|
85
|
-
|
|
85
|
+
if (onReset) {
|
|
86
|
+
onReset();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
form.resetFields();
|
|
86
90
|
},
|
|
87
91
|
children: "\u91CD\u7F6E"
|
|
88
92
|
}), hide ? null : jsxRuntime.jsx(OpenComponent, {})]
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IHeaderProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, onFinish, searchSpan, headerStyle, initValues, hideLabel, labelWidth, onReset }: IHeaderProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, onFinish, searchSpan, headerStyle, initValues, hideLabel, labelWidth, onReset, }: IHeaderProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/lib/modal.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type React from "react";
|
|
|
6
6
|
import type { ModalProps } from "antd";
|
|
7
7
|
import type { TableProps } from "antd/lib/table";
|
|
8
8
|
import type { AffixProps } from "antd/lib/affix";
|
|
9
|
+
import { OptionModal } from "./HTableBody";
|
|
9
10
|
export interface RowObj {
|
|
10
11
|
keys?: React.Key[];
|
|
11
12
|
rowData?: any[];
|
|
@@ -75,6 +76,7 @@ export interface HTableProps extends Omit<ProTableProps<any, any>, "request" | "
|
|
|
75
76
|
formInitValues?: Record<string, any>;
|
|
76
77
|
labelWidth?: number;
|
|
77
78
|
hideLabel?: boolean;
|
|
79
|
+
options?: OptionModal | false;
|
|
78
80
|
}
|
|
79
81
|
interface ColCheckResultKeys {
|
|
80
82
|
keys?: string[];
|
package/package.json
CHANGED
|
@@ -29,17 +29,17 @@ export const ColsSettingContent = ({
|
|
|
29
29
|
});
|
|
30
30
|
return treeData;
|
|
31
31
|
}, [columns]);
|
|
32
|
-
const check=(keys:string[])=>{
|
|
33
|
-
const notCheck:string[]=[];
|
|
34
|
-
contentTreeData.forEach(({key})=>{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
-
onCheck(keys,notCheck)
|
|
42
|
-
}
|
|
32
|
+
const check = (keys: string[]) => {
|
|
33
|
+
const notCheck: string[] = [];
|
|
34
|
+
contentTreeData.forEach(({ key }) => {
|
|
35
|
+
const cuKey = key as string;
|
|
36
|
+
const index = keys.indexOf(cuKey);
|
|
37
|
+
if (index === -1) {
|
|
38
|
+
notCheck.push(cuKey);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
onCheck(keys, notCheck);
|
|
42
|
+
};
|
|
43
43
|
return (
|
|
44
44
|
<div className={content}>
|
|
45
45
|
<div style={{ paddingTop: 6, paddingBottom: 6 }}>
|
|
@@ -47,8 +47,8 @@ export const ColsSettingContent = ({
|
|
|
47
47
|
checkable
|
|
48
48
|
className={treeClass}
|
|
49
49
|
checkedKeys={checkKeys}
|
|
50
|
-
onCheck={(key)=>{
|
|
51
|
-
check(
|
|
50
|
+
onCheck={(key) => {
|
|
51
|
+
check(key as string[]);
|
|
52
52
|
}}
|
|
53
53
|
height={268}
|
|
54
54
|
treeData={contentTreeData}
|
|
@@ -3,28 +3,28 @@ import { Checkbox, Row, Space, Typography } from "antd";
|
|
|
3
3
|
import type { ItemProps } from "./modal";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
const { Link } = Typography;
|
|
6
|
-
export const Title = ({ columns, onCheck, checkKeys,reset }: ItemProps) => {
|
|
6
|
+
export const Title = ({ columns, onCheck, checkKeys, reset }: ItemProps) => {
|
|
7
7
|
const title = useClassName("hw-table-body-option-setting-title");
|
|
8
8
|
const relArrayKeys = useMemo(() => {
|
|
9
|
-
const keys:string[]=[];
|
|
10
|
-
columns.forEach((value)=>{
|
|
11
|
-
const {dataIndex,hideInTable}=value;
|
|
12
|
-
if (hideInTable || !dataIndex){
|
|
9
|
+
const keys: string[] = [];
|
|
10
|
+
columns.forEach((value) => {
|
|
11
|
+
const { dataIndex, hideInTable } = value;
|
|
12
|
+
if (hideInTable || !dataIndex) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
const dataIndexStr=dataIndex.toString();
|
|
15
|
+
const dataIndexStr = dataIndex.toString();
|
|
16
16
|
keys.push(dataIndexStr);
|
|
17
|
-
})
|
|
17
|
+
});
|
|
18
18
|
return keys;
|
|
19
19
|
}, [columns]);
|
|
20
|
-
const allKeys=columns
|
|
20
|
+
const allKeys = columns;
|
|
21
21
|
const allCheck = () => {
|
|
22
|
-
|
|
22
|
+
onCheck(relArrayKeys, []);
|
|
23
23
|
};
|
|
24
|
-
const allNotCheck=()=>{
|
|
25
|
-
onCheck([],relArrayKeys);
|
|
26
|
-
}
|
|
27
|
-
const relLen=relArrayKeys.length;
|
|
24
|
+
const allNotCheck = () => {
|
|
25
|
+
onCheck([], relArrayKeys);
|
|
26
|
+
};
|
|
27
|
+
const relLen = relArrayKeys.length;
|
|
28
28
|
const indeterminate = relLen !== checkKeys.length && checkKeys.length > 0;
|
|
29
29
|
return (
|
|
30
30
|
<Row className={title} justify={"space-between"}>
|
|
@@ -33,11 +33,11 @@ export const Title = ({ columns, onCheck, checkKeys,reset }: ItemProps) => {
|
|
|
33
33
|
checked={relLen === checkKeys.length}
|
|
34
34
|
indeterminate={indeterminate}
|
|
35
35
|
onChange={(e) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
if (e.target.checked) {
|
|
37
|
+
allCheck();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
allNotCheck();
|
|
41
41
|
}}
|
|
42
42
|
/>
|
|
43
43
|
<span>列展示</span>
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import {useMemo} from "react";
|
|
2
|
-
import {IProps} from "@/components/HTableBody/Options/modal";
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import type { IProps } from "@/components/HTableBody/Options/modal";
|
|
3
3
|
|
|
4
|
-
export const useCheckKeys=({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
4
|
+
export const useCheckKeys = ({
|
|
5
|
+
columns,
|
|
6
|
+
colStatusValue,
|
|
7
|
+
}: Pick<IProps, "colStatusValue" | "columns">) => {
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
const keys: string[] = [];
|
|
10
|
+
columns.forEach((value) => {
|
|
11
|
+
const { dataIndex, hideInTable } = value;
|
|
12
|
+
if (hideInTable || !dataIndex) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const dataIndexStr = dataIndex.toString();
|
|
16
|
+
const { show = true } = colStatusValue[dataIndexStr] || {};
|
|
17
|
+
if (!show) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
keys.push(dataIndexStr);
|
|
21
|
+
});
|
|
22
|
+
return keys;
|
|
23
|
+
}, [colStatusValue, columns]);
|
|
24
|
+
};
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
SettingOutlined,
|
|
7
7
|
} from "@ant-design/icons";
|
|
8
8
|
import type { SizeType } from "antd/lib/config-provider/SizeContext";
|
|
9
|
-
import {useRef} from "react";
|
|
9
|
+
import { useRef } from "react";
|
|
10
10
|
import { ColsSettingContent } from "./Content";
|
|
11
11
|
import { Title } from "./Title";
|
|
12
12
|
import type { IProps } from "./modal";
|
|
13
|
-
import {useCheckKeys} from "@/components/HTableBody/Options/hooks";
|
|
13
|
+
import { useCheckKeys } from "@/components/HTableBody/Options/hooks";
|
|
14
14
|
export default ({
|
|
15
15
|
reload,
|
|
16
16
|
size = "middle",
|
|
@@ -18,15 +18,16 @@ export default ({
|
|
|
18
18
|
setSizeChange,
|
|
19
19
|
columns,
|
|
20
20
|
onChange,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
colStatusValue,
|
|
22
|
+
reset,
|
|
23
|
+
settingRender,
|
|
23
24
|
}: IProps) => {
|
|
24
25
|
const pointer = useClassName([
|
|
25
26
|
"hw-table-pointer",
|
|
26
27
|
"hw-table-body-option-icon",
|
|
27
28
|
]);
|
|
28
29
|
const ref = useRef<HTMLDivElement>(null);
|
|
29
|
-
const checkKeys = useCheckKeys({columns,colStatusValue})
|
|
30
|
+
const checkKeys = useCheckKeys({ columns, colStatusValue });
|
|
30
31
|
const SizeItem = () => {
|
|
31
32
|
const MenuComponent = Menu as any;
|
|
32
33
|
const MenuItem = Menu.Item as any;
|
|
@@ -50,8 +51,8 @@ export default ({
|
|
|
50
51
|
);
|
|
51
52
|
};
|
|
52
53
|
return (
|
|
53
|
-
<Row justify={"end"}
|
|
54
|
-
<Space size={
|
|
54
|
+
<Row justify={"end"}>
|
|
55
|
+
<Space size={15}>
|
|
55
56
|
{reload && (
|
|
56
57
|
<Tooltip title="刷新">
|
|
57
58
|
<ReloadOutlined
|
|
@@ -77,25 +78,29 @@ export default ({
|
|
|
77
78
|
</Dropdown>
|
|
78
79
|
</Tooltip>
|
|
79
80
|
)}
|
|
80
|
-
<
|
|
81
|
-
<Popover
|
|
81
|
+
<Popover
|
|
82
82
|
content={
|
|
83
83
|
<ColsSettingContent
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
columns={columns}
|
|
85
|
+
checkKeys={checkKeys}
|
|
86
|
+
onCheck={onChange}
|
|
87
87
|
/>
|
|
88
88
|
}
|
|
89
89
|
title={
|
|
90
|
-
<Title
|
|
90
|
+
<Title
|
|
91
|
+
columns={columns}
|
|
92
|
+
reset={reset}
|
|
93
|
+
checkKeys={checkKeys}
|
|
94
|
+
onCheck={onChange}
|
|
95
|
+
/>
|
|
91
96
|
}
|
|
92
|
-
placement="
|
|
97
|
+
placement="bottomRight"
|
|
93
98
|
getPopupContainer={() => ref.current || document.body}
|
|
99
|
+
arrowPointAtCenter
|
|
94
100
|
trigger="click"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
</Tooltip>
|
|
101
|
+
>
|
|
102
|
+
{settingRender?settingRender():<Tooltip title="列设置"><SettingOutlined className={pointer} width={24} /></Tooltip>}
|
|
103
|
+
</Popover>
|
|
99
104
|
</Space>
|
|
100
105
|
</Row>
|
|
101
106
|
);
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import type { OptionConfig } from "@ant-design/pro-table/lib/components/ToolBar";
|
|
2
2
|
import type { SizeType } from "antd/lib/config-provider/SizeContext";
|
|
3
3
|
import type { ConfigDataModal } from "../../modal";
|
|
4
|
-
import {ColumnsState} from "@ant-design/pro-table/es/container";
|
|
4
|
+
import type { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
5
|
+
import React from "react";
|
|
5
6
|
|
|
6
7
|
export interface IProps extends OptionConfig {
|
|
7
8
|
size?: SizeType;
|
|
8
9
|
setSizeChange: (size: SizeType) => void;
|
|
9
10
|
columns: ConfigDataModal;
|
|
10
|
-
onChange: (keys:string[],notCheck:string[]) => void;
|
|
11
|
-
colStatusValue:Record<string, ColumnsState
|
|
12
|
-
reset:VoidFunction;
|
|
11
|
+
onChange: (keys: string[], notCheck: string[]) => void;
|
|
12
|
+
colStatusValue: Record<string, ColumnsState>;
|
|
13
|
+
reset: VoidFunction;
|
|
14
|
+
settingRender?:()=>React.ReactNode
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export interface ItemProps {
|
|
16
18
|
checkKeys: string[];
|
|
17
|
-
onCheck:(keys:string[],notCheck:string[])=>void;
|
|
19
|
+
onCheck: (keys: string[], notCheck: string[]) => void;
|
|
18
20
|
columns: ConfigDataModal;
|
|
19
|
-
reset?:VoidFunction;
|
|
21
|
+
reset?: VoidFunction;
|
|
20
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConfigDataModal, ConfigItemModal } from "../../modal";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {ColumnsState} from "@ant-design/pro-table/es/container";
|
|
3
|
+
import { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
4
4
|
export const getItemValue = (data: ConfigItemModal) => {
|
|
5
5
|
const { dataIndex, title, titleStr, ...oData } = data;
|
|
6
6
|
let resultTitle = React.isValidElement(title) ? title.props.children : title;
|
|
@@ -12,4 +12,4 @@ export const getItemValue = (data: ConfigItemModal) => {
|
|
|
12
12
|
dataIndex,
|
|
13
13
|
...oData,
|
|
14
14
|
};
|
|
15
|
-
};
|
|
15
|
+
};
|