@hw-component/table 1.9.79 → 1.9.80
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.js +41 -5
- package/es/HTableBody/RowCheckBox/Title.d.ts +1 -1
- package/es/HTableBody/RowCheckBox/hooks.d.ts +1 -1
- package/es/HTableBody/RowRadioBoxSelection.d.ts +3 -3
- package/es/HTableBody/hooks/colsMk.d.ts +1 -1
- package/es/HTableBody/hooks/useControl.d.ts +1 -1
- package/es/index.css +24 -2
- package/es/render/Text.d.ts +0 -1
- package/lib/HTableBody/HeaderTitle/index.js +40 -4
- package/lib/HTableBody/RowCheckBox/Title.d.ts +1 -1
- package/lib/HTableBody/RowCheckBox/hooks.d.ts +1 -1
- package/lib/HTableBody/RowRadioBoxSelection.d.ts +3 -3
- package/lib/HTableBody/hooks/colsMk.d.ts +1 -1
- package/lib/HTableBody/hooks/useControl.d.ts +1 -1
- package/lib/index.css +24 -2
- package/lib/render/Text.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/HTableBody/HeaderTitle/index.tsx +40 -9
- package/src/components/HTableBody/RowCheckBox/RowItem.tsx +40 -41
- package/src/components/HTableBody/RowCheckBox/Title.tsx +59 -63
- package/src/components/HTableBody/RowCheckBox/hooks.ts +64 -63
- package/src/components/HTableBody/RowRadioBoxSelection.tsx +24 -24
- package/src/components/HTableBody/hooks/colsMk.tsx +47 -47
- package/src/components/HTableBody/hooks/useColData.tsx +9 -9
- package/src/components/HTableBody/hooks/useControl.tsx +12 -10
- package/src/components/HTableBody/index.tsx +14 -5
- package/src/components/Table.tsx +10 -4
- package/src/components/hooks/useRowObj.ts +11 -11
- package/src/components/index.less +8 -3
- package/src/components/modal.ts +2 -2
- package/src/components/render/CopyComponent.tsx +9 -9
- package/src/components/render/TagsComponent.tsx +18 -8
- package/src/pages/DwTable/index.tsx +4 -4
- package/src/pages/Table/index.tsx +16 -16
|
@@ -1,68 +1,69 @@
|
|
|
1
|
-
import {HTableProps} from "@/components/modal";
|
|
2
|
-
import {Key} from "react";
|
|
3
|
-
import {useHTableContext} from "@/components/context";
|
|
1
|
+
import type { HTableProps } from "@/components/modal";
|
|
2
|
+
import type { Key } from "react";
|
|
3
|
+
import { useHTableContext } from "@/components/context";
|
|
4
4
|
import type { HRowSelection } from "../../modal";
|
|
5
5
|
|
|
6
|
-
const getRowKey=(item:any,index:number,rowKey:HTableProps["rowKey"])=>{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
const getRowKey = (item: any, index: number, rowKey: HTableProps["rowKey"]) => {
|
|
7
|
+
return typeof rowKey === "function"
|
|
8
|
+
? rowKey(item, index)
|
|
9
|
+
: item[rowKey as string];
|
|
10
|
+
};
|
|
11
|
+
export const useAllChecked = (keys: Key[] = [], data: any[] = []) => {
|
|
12
|
+
const { rowKey = "id" } = useHTableContext();
|
|
13
|
+
const len = data?.length;
|
|
14
|
+
if (!len) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return data.every((item, index) => {
|
|
18
|
+
const itemKey = getRowKey(item, index, rowKey);
|
|
19
|
+
return keys.indexOf(itemKey) !== -1;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
20
22
|
|
|
21
|
-
export const useCheckControl=(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
23
|
+
export const useCheckControl = (
|
|
24
|
+
data: any[] = [],
|
|
25
|
+
onChange: HRowSelection["onChange"]
|
|
26
|
+
) => {
|
|
27
|
+
const { rowOnChange, rowKey = "id", allSelectChange } = useHTableContext();
|
|
28
|
+
const allCheck = () => {
|
|
29
|
+
const setKeys = data.map((item, index) => {
|
|
30
|
+
return getRowKey(item, index, rowKey);
|
|
31
|
+
});
|
|
32
|
+
rowOnChange(setKeys, data);
|
|
33
|
+
onChange?.(setKeys, data);
|
|
34
|
+
};
|
|
35
|
+
const allCancel = () => {
|
|
36
|
+
rowOnChange([], []);
|
|
37
|
+
onChange?.([], []);
|
|
38
|
+
};
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
allSelectChange?.(false);
|
|
62
|
-
onChange?.([], []);
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
checkChange,
|
|
66
|
-
menuClick
|
|
40
|
+
const checkChange = (e) => {
|
|
41
|
+
const checked = e.target.checked;
|
|
42
|
+
if (checked) {
|
|
43
|
+
allCheck();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
allCancel();
|
|
47
|
+
};
|
|
48
|
+
const menuClick = ({ key }) => {
|
|
49
|
+
if (key === "check") {
|
|
50
|
+
allCheck();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (key === "cancel") {
|
|
54
|
+
allCancel();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (key === "checkAll") {
|
|
58
|
+
allSelectChange?.(true);
|
|
59
|
+
onChange?.([], []);
|
|
60
|
+
return;
|
|
67
61
|
}
|
|
68
|
-
|
|
62
|
+
allSelectChange?.(false);
|
|
63
|
+
onChange?.([], []);
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
checkChange,
|
|
67
|
+
menuClick,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {HRowSelection} from "@/components/modal";
|
|
2
|
-
import {useHTableContext} from "@/components/context";
|
|
3
|
-
import {Radio} from "antd";
|
|
1
|
+
import type { HRowSelection } from "@/components/modal";
|
|
2
|
+
import { useHTableContext } from "@/components/context";
|
|
3
|
+
import { Radio } from "antd";
|
|
4
4
|
|
|
5
|
-
interface
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
interface RowRadioSelectionProps {
|
|
6
|
+
data: any;
|
|
7
|
+
onChange?: HRowSelection["onChange"];
|
|
8
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
9
|
+
index: number;
|
|
10
10
|
}
|
|
11
11
|
export const RowRadioSelection = ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
12
|
+
data,
|
|
13
|
+
onChange,
|
|
14
|
+
index,
|
|
15
|
+
getCheckboxProps,
|
|
16
|
+
}: RowRadioSelectionProps) => {
|
|
17
|
+
const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
|
|
18
|
+
const { keys = [] } = selectedRowData;
|
|
19
|
+
const key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
|
|
20
|
+
const add = () => {
|
|
21
|
+
rowOnChange([key], [data]);
|
|
22
|
+
onChange?.([key], [data]);
|
|
23
|
+
};
|
|
24
|
+
const { disabled = false } = getCheckboxProps?.(data) || {};
|
|
25
|
+
const checked = keys.indexOf(key) !== -1;
|
|
26
|
+
return <Radio checked={checked} onChange={add} disabled={disabled} />;
|
|
27
|
+
};
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import {HRowSelection} from "@/components/modal";
|
|
1
|
+
import type { HRowSelection } from "@/components/modal";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {RowRadioSelection} from "@/components/HTableBody/RowRadioBoxSelection";
|
|
4
|
-
import RowCheckBoxSelectionTitle from
|
|
5
|
-
import RowCheckBoxSelection from
|
|
3
|
+
import { RowRadioSelection } from "@/components/HTableBody/RowRadioBoxSelection";
|
|
4
|
+
import RowCheckBoxSelectionTitle from "@/components/HTableBody/RowCheckBox/Title";
|
|
5
|
+
import RowCheckBoxSelection from "@/components/HTableBody/RowCheckBox/RowItem";
|
|
6
6
|
export const checkBoxSelectionCol = (rowSelection: HRowSelection) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
7
|
+
const { allPageCheck, onChange, getCheckboxProps } = rowSelection;
|
|
8
|
+
return {
|
|
9
|
+
title: (
|
|
10
|
+
<RowCheckBoxSelectionTitle
|
|
11
|
+
allPageCheck={allPageCheck}
|
|
12
|
+
onChange={onChange}
|
|
13
|
+
getCheckboxProps={getCheckboxProps}
|
|
14
|
+
/>
|
|
15
|
+
),
|
|
16
|
+
width: 36,
|
|
17
|
+
rowSelectionTitle: true,
|
|
18
|
+
fixed: "left",
|
|
19
|
+
align: "center",
|
|
20
|
+
render: (dom, data, index) => {
|
|
21
|
+
return (
|
|
22
|
+
<RowCheckBoxSelection
|
|
23
|
+
data={data}
|
|
24
|
+
index={index}
|
|
25
|
+
onChange={onChange}
|
|
26
|
+
getCheckboxProps={getCheckboxProps}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
33
|
+
export const radioSelectionCol = (rowSelection: HRowSelection) => {
|
|
34
|
+
const { onChange, getCheckboxProps } = rowSelection;
|
|
35
|
+
return {
|
|
36
|
+
width: 36,
|
|
37
|
+
rowSelectionTitle: true,
|
|
38
|
+
fixed: "left",
|
|
39
|
+
align: "center",
|
|
40
|
+
render: (dom, data, index) => {
|
|
41
|
+
return (
|
|
42
|
+
<RowRadioSelection
|
|
43
|
+
data={data}
|
|
44
|
+
index={index}
|
|
45
|
+
onChange={onChange}
|
|
46
|
+
getCheckboxProps={getCheckboxProps}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -14,14 +14,14 @@ import configRender from "@/components/render";
|
|
|
14
14
|
import type { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
15
15
|
import { mkChangeValue, outColSetting } from "@/components/HTableBody/utils";
|
|
16
16
|
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
17
|
-
import {radioSelectionCol,checkBoxSelectionCol} from
|
|
18
|
-
const checkBoxMk=(rowSelection:HRowSelection)=>{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
17
|
+
import { radioSelectionCol, checkBoxSelectionCol } from "./colsMk";
|
|
18
|
+
const checkBoxMk = (rowSelection: HRowSelection) => {
|
|
19
|
+
const { type } = rowSelection;
|
|
20
|
+
if (type === "radio") {
|
|
21
|
+
return radioSelectionCol(rowSelection);
|
|
22
|
+
}
|
|
23
|
+
return checkBoxSelectionCol(rowSelection);
|
|
24
|
+
};
|
|
25
25
|
export const useCols = ({
|
|
26
26
|
configData,
|
|
27
27
|
rowSelection,
|
|
@@ -68,7 +68,7 @@ export const useCols = ({
|
|
|
68
68
|
return !item.hideInTable;
|
|
69
69
|
});
|
|
70
70
|
if (rowSelection !== false) {
|
|
71
|
-
colsArray.splice(0, 0, checkBoxMk(rowSelection||{}) as any);
|
|
71
|
+
colsArray.splice(0, 0, checkBoxMk(rowSelection || {}) as any);
|
|
72
72
|
}
|
|
73
73
|
return colsArray.map((item, index) => {
|
|
74
74
|
const lastItem = colsArray[index - 1];
|
|
@@ -4,7 +4,7 @@ import type { SizeType } from "antd/lib/config-provider/SizeContext";
|
|
|
4
4
|
import type { HTableBodyProps } from "../modal";
|
|
5
5
|
import { useHTableContext } from "@/components/context";
|
|
6
6
|
import type { GetRowKey } from "rc-table/lib/interface";
|
|
7
|
-
import {RowObj} from "@/components/modal";
|
|
7
|
+
import type { RowObj } from "@/components/modal";
|
|
8
8
|
|
|
9
9
|
export const useSize = (size: SizeType) => {
|
|
10
10
|
const [cuSize, setCuSize] = useState(size);
|
|
@@ -106,13 +106,15 @@ export const useSynchronousKeys = ({
|
|
|
106
106
|
}, [selectedRowKeys, records, rowKey]);
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
export const useAlwaysShowAlert = (
|
|
110
|
+
selectedRowData: RowObj,
|
|
111
|
+
alwaysShowAlert?: boolean
|
|
112
|
+
) => {
|
|
111
113
|
const { keys = [], selectAll } = selectedRowData;
|
|
112
|
-
return useMemo(()=>{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
},[selectedRowData,alwaysShowAlert])
|
|
118
|
-
}
|
|
114
|
+
return useMemo(() => {
|
|
115
|
+
if (typeof alwaysShowAlert !== "undefined") {
|
|
116
|
+
return alwaysShowAlert;
|
|
117
|
+
}
|
|
118
|
+
return keys.length > 0 || selectAll;
|
|
119
|
+
}, [selectedRowData, alwaysShowAlert]);
|
|
120
|
+
};
|
|
@@ -2,7 +2,8 @@ import ProTable from "@ant-design/pro-table";
|
|
|
2
2
|
import {
|
|
3
3
|
useSize,
|
|
4
4
|
useTableChange,
|
|
5
|
-
useSynchronousKeys,
|
|
5
|
+
useSynchronousKeys,
|
|
6
|
+
useAlwaysShowAlert,
|
|
6
7
|
} from "./hooks/useControl";
|
|
7
8
|
import { useCols, useColumnsStateType } from "./hooks/useColData";
|
|
8
9
|
import { useHTableContext } from "../context";
|
|
@@ -44,7 +45,8 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
44
45
|
bordered,
|
|
45
46
|
...props
|
|
46
47
|
} = bodyProps;
|
|
47
|
-
const { selectedRowKeys, alwaysShowAlert: configAlwaysShowAlert } =
|
|
48
|
+
const { selectedRowKeys, alwaysShowAlert: configAlwaysShowAlert } =
|
|
49
|
+
rowSelection || {};
|
|
48
50
|
const {
|
|
49
51
|
tableInstance: contextTableInstance,
|
|
50
52
|
configData: contextConfigData,
|
|
@@ -88,8 +90,13 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
88
90
|
reset={reset}
|
|
89
91
|
/>
|
|
90
92
|
);
|
|
91
|
-
const defaultOptionsNode = optionsRender
|
|
92
|
-
|
|
93
|
+
const defaultOptionsNode = optionsRender
|
|
94
|
+
? optionsRender(optionsNode)
|
|
95
|
+
: optionsNode;
|
|
96
|
+
const alwaysShowAlert = useAlwaysShowAlert(
|
|
97
|
+
selectedRowData,
|
|
98
|
+
configAlwaysShowAlert
|
|
99
|
+
);
|
|
93
100
|
const className = useClassName("hw-table-body");
|
|
94
101
|
const { tableStyle: defaultTableStyle } = useHTableConfigContext({
|
|
95
102
|
tableStyle,
|
|
@@ -139,7 +146,9 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
139
146
|
dataSource={records}
|
|
140
147
|
pagination={false}
|
|
141
148
|
/>
|
|
142
|
-
{pagination === false
|
|
149
|
+
{pagination === false ? (
|
|
150
|
+
<div style={{ paddingBottom: 24 }} />
|
|
151
|
+
) : (
|
|
143
152
|
<HTablePagination
|
|
144
153
|
onPageChange={onPageChange}
|
|
145
154
|
paginationStyle={paginationStyle}
|
package/src/components/Table.tsx
CHANGED
|
@@ -44,18 +44,24 @@ export default ({
|
|
|
44
44
|
reload,
|
|
45
45
|
});
|
|
46
46
|
const dispatch = useDispatch(action);
|
|
47
|
-
const {
|
|
47
|
+
const {
|
|
48
|
+
selectedRowData,
|
|
49
|
+
rowOnChange,
|
|
50
|
+
allSelectChange,
|
|
51
|
+
setSelectedRowData,
|
|
52
|
+
rowSelectionReload,
|
|
53
|
+
} = useRowObj(rowSelection);
|
|
48
54
|
const [open, setOpen] = useState<boolean | undefined>();
|
|
49
55
|
const tableInstance = useCurrentTable({
|
|
50
56
|
table,
|
|
51
57
|
reload: (params) => {
|
|
52
|
-
|
|
58
|
+
rowSelectionReload();
|
|
53
59
|
return run(params);
|
|
54
60
|
},
|
|
55
61
|
changeRowData: rowOnChange,
|
|
56
62
|
dispatch,
|
|
57
63
|
reloadWithParams: (reloadParams = {}) => {
|
|
58
|
-
|
|
64
|
+
rowSelectionReload();
|
|
59
65
|
return run({ ...saveParams.old, ...reloadParams });
|
|
60
66
|
},
|
|
61
67
|
getTableParams: () => {
|
|
@@ -78,7 +84,7 @@ export default ({
|
|
|
78
84
|
action,
|
|
79
85
|
configData,
|
|
80
86
|
onFinish: (value) => {
|
|
81
|
-
|
|
87
|
+
rowSelectionReload();
|
|
82
88
|
return run({ ...saveParams.old, ...value, current: 1 });
|
|
83
89
|
},
|
|
84
90
|
onPageChange: tableInstance.table.reloadWithParams,
|
|
@@ -26,21 +26,21 @@ export default (rowSelection?: HRowSelection | false) => {
|
|
|
26
26
|
selectAll: newChecked,
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
|
-
const rowSelectionReload=()=>{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
29
|
+
const rowSelectionReload = () => {
|
|
30
|
+
if (rowSelection === false) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const { preserveSelectedRowKeys } = rowSelection || {};
|
|
34
|
+
if (preserveSelectedRowKeys) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
rowOnChange([], []);
|
|
38
|
+
};
|
|
39
39
|
return {
|
|
40
40
|
rowOnChange,
|
|
41
41
|
selectedRowData,
|
|
42
42
|
allSelectChange,
|
|
43
43
|
setSelectedRowData,
|
|
44
|
-
rowSelectionReload
|
|
44
|
+
rowSelectionReload,
|
|
45
45
|
};
|
|
46
46
|
};
|
|
@@ -115,16 +115,21 @@
|
|
|
115
115
|
display: flex;
|
|
116
116
|
position: relative;
|
|
117
117
|
box-sizing: border-box;
|
|
118
|
-
overflow: auto;
|
|
119
118
|
margin: -10px 0px;
|
|
120
119
|
padding: 10px 0px;
|
|
121
|
-
margin-right: 12px;
|
|
122
120
|
.@{ant-prefix}-hw-table-header-title-box-content {
|
|
123
121
|
white-space: nowrap;
|
|
124
122
|
}
|
|
125
123
|
}
|
|
124
|
+
.@{ant-prefix}-hw-table-header-title{
|
|
125
|
+
display: flex;
|
|
126
|
+
justify-content: space-between;
|
|
127
|
+
align-content: center;
|
|
128
|
+
}
|
|
126
129
|
.@{ant-prefix}-hw-table-header-right-node{
|
|
127
|
-
|
|
130
|
+
padding-left: 12px;
|
|
131
|
+
display: flex;
|
|
132
|
+
align-items: center;
|
|
128
133
|
}
|
|
129
134
|
|
|
130
135
|
.@{ant-prefix}-hw-table-render-copy{
|
package/src/components/modal.ts
CHANGED
|
@@ -159,7 +159,7 @@ export interface DwTableProps extends DrawerProps {
|
|
|
159
159
|
contentRender?: (node: React.ReactNode) => React.ReactNode;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
export interface ModalTableProps extends Omit<ModalProps,"onOk"> {
|
|
162
|
+
export interface ModalTableProps extends Omit<ModalProps, "onOk"> {
|
|
163
163
|
tableProps?: Omit<HTableProps, "configData" | "request">;
|
|
164
164
|
dialogTable?: HDiaLogTableInstance;
|
|
165
165
|
params?: Record<string, any>;
|
|
@@ -167,7 +167,7 @@ export interface ModalTableProps extends Omit<ModalProps,"onOk"> {
|
|
|
167
167
|
request?: HTableProps["request"];
|
|
168
168
|
contentRender?: (node: React.ReactNode) => React.ReactNode;
|
|
169
169
|
dataSource?: any[];
|
|
170
|
-
onOk?:(e?: React.MouseEvent<HTMLElement>)=>void;
|
|
170
|
+
onOk?: (e?: React.MouseEvent<HTMLElement>) => void;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
export type ValueTypeConfigRenderFn = (
|
|
@@ -2,7 +2,7 @@ import copy from "copy-to-clipboard";
|
|
|
2
2
|
import { message, Typography } from "antd";
|
|
3
3
|
import type { EllipsisConfig } from "antd/lib/typography/Base";
|
|
4
4
|
import { useClassName } from "../hooks";
|
|
5
|
-
import {useMemo} from "react";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
6
|
const { Paragraph } = Typography;
|
|
7
7
|
interface IProps {
|
|
8
8
|
text: string;
|
|
@@ -12,14 +12,14 @@ interface IProps {
|
|
|
12
12
|
}
|
|
13
13
|
export default ({ cpText, text, successMsg, ellipsis }: IProps) => {
|
|
14
14
|
const className = useClassName("hw-table-render-copy");
|
|
15
|
-
const propsEllipsis=useMemo(()=>{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},[ellipsis,text]);
|
|
15
|
+
const propsEllipsis = useMemo(() => {
|
|
16
|
+
if (ellipsis === true) {
|
|
17
|
+
return {
|
|
18
|
+
tooltip: text,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return ellipsis;
|
|
22
|
+
}, [ellipsis, text]);
|
|
23
23
|
return (
|
|
24
24
|
<Paragraph
|
|
25
25
|
ellipsis={propsEllipsis}
|
|
@@ -13,9 +13,9 @@ interface IProps {
|
|
|
13
13
|
fieldNames?: { label?: string; value?: string };
|
|
14
14
|
tableInstance?: HTableInstance;
|
|
15
15
|
maxLen?: number | null;
|
|
16
|
-
popoverContentRender?:(node:React.ReactNode)=>React.ReactNode;
|
|
17
|
-
contentItemRender?:(item:any)=>React.ReactNode;
|
|
18
|
-
extra?:React.ReactNode;
|
|
16
|
+
popoverContentRender?: (node: React.ReactNode) => React.ReactNode;
|
|
17
|
+
contentItemRender?: (item: any) => React.ReactNode;
|
|
18
|
+
extra?: React.ReactNode;
|
|
19
19
|
}
|
|
20
20
|
const getTooltipProps = (
|
|
21
21
|
title: string,
|
|
@@ -48,7 +48,7 @@ const TagsComponent = (props: IProps) => {
|
|
|
48
48
|
tableInstance,
|
|
49
49
|
maxLen,
|
|
50
50
|
popoverContentRender,
|
|
51
|
-
extra
|
|
51
|
+
extra,
|
|
52
52
|
} = props;
|
|
53
53
|
const { label = "label", value = "value" } = fieldNames;
|
|
54
54
|
const { tagData, moreTag } = useMemo(() => {
|
|
@@ -65,7 +65,7 @@ const TagsComponent = (props: IProps) => {
|
|
|
65
65
|
};
|
|
66
66
|
}, [data, maxLen]);
|
|
67
67
|
const moreLen = moreTag?.length;
|
|
68
|
-
const {contentItemRender
|
|
68
|
+
const { contentItemRender, ...childProps } = props;
|
|
69
69
|
return (
|
|
70
70
|
<Row gutter={[0, 8]}>
|
|
71
71
|
{tagData?.map((tagItem, index) => {
|
|
@@ -88,7 +88,7 @@ const TagsComponent = (props: IProps) => {
|
|
|
88
88
|
onClose?.(indexKey, tableInstance);
|
|
89
89
|
}}
|
|
90
90
|
>
|
|
91
|
-
{contentItemRender?contentItemRender(tagItem):tagItem}
|
|
91
|
+
{contentItemRender ? contentItemRender(tagItem) : tagItem}
|
|
92
92
|
</Tag>
|
|
93
93
|
</Tooltip>
|
|
94
94
|
);
|
|
@@ -110,13 +110,23 @@ const TagsComponent = (props: IProps) => {
|
|
|
110
110
|
cuTagProps?.onClose(cuKey, tableInstance);
|
|
111
111
|
}}
|
|
112
112
|
>
|
|
113
|
-
{contentItemRender?contentItemRender(tagLabel):tagLabel}
|
|
113
|
+
{contentItemRender ? contentItemRender(tagLabel) : tagLabel}
|
|
114
114
|
</Tag>
|
|
115
115
|
</Tooltip>
|
|
116
116
|
);
|
|
117
117
|
})}
|
|
118
118
|
{!moreLen ? null : (
|
|
119
|
-
<Popover
|
|
119
|
+
<Popover
|
|
120
|
+
content={
|
|
121
|
+
popoverContentRender ? (
|
|
122
|
+
popoverContentRender(
|
|
123
|
+
<TagsComponent {...childProps} maxLen={null} />
|
|
124
|
+
)
|
|
125
|
+
) : (
|
|
126
|
+
<TagsComponent {...childProps} maxLen={null} />
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
>
|
|
120
130
|
<Tag>...等{data.length}个</Tag>
|
|
121
131
|
</Popover>
|
|
122
132
|
)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button } from "antd";
|
|
2
|
-
import {HDwTable, HModalTable, HTable, useHDialogTable} from "@/components";
|
|
2
|
+
import { HDwTable, HModalTable, HTable, useHDialogTable } from "@/components";
|
|
3
3
|
const configData = [
|
|
4
4
|
{
|
|
5
5
|
title: "座位",
|
|
@@ -100,9 +100,9 @@ const Test = () => {
|
|
|
100
100
|
title="111"
|
|
101
101
|
configData={configData}
|
|
102
102
|
tableProps={{
|
|
103
|
-
rowSelection:{
|
|
104
|
-
type:"radio"
|
|
105
|
-
}
|
|
103
|
+
rowSelection: {
|
|
104
|
+
type: "radio",
|
|
105
|
+
},
|
|
106
106
|
}}
|
|
107
107
|
request={req2}
|
|
108
108
|
contentRender={(node) => {
|