@hw-component/table 1.9.61 → 1.9.63
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/RowCheckBox/RowItem.d.ts +10 -0
- package/es/HTableBody/RowCheckBox/RowItem.js +62 -0
- package/es/HTableBody/RowCheckBox/Title.d.ts +4 -0
- package/es/HTableBody/RowCheckBox/Title.js +81 -0
- package/es/HTableBody/RowCheckBox/hooks.d.ts +9 -0
- package/es/HTableBody/RowCheckBox/hooks.js +73 -0
- package/es/HTableBody/RowRadioBoxSelection.d.ts +10 -0
- package/es/HTableBody/RowRadioBoxSelection.js +37 -0
- package/es/HTableBody/hooks/colsMk.d.ts +17 -0
- package/es/HTableBody/hooks/colsMk.js +51 -0
- package/es/HTableBody/hooks/useColData.js +25 -44
- package/es/HTableBody/hooks/useControl.d.ts +2 -0
- package/es/HTableBody/hooks/useControl.js +13 -1
- package/es/HTableBody/index.js +2 -7
- package/es/Table.js +5 -4
- package/es/hooks/useRowObj.d.ts +1 -0
- package/es/hooks/useRowObj.js +14 -3
- package/es/render/Text.d.ts +0 -1
- package/lib/HTableBody/RowCheckBox/RowItem.d.ts +10 -0
- package/lib/HTableBody/RowCheckBox/RowItem.js +65 -0
- package/lib/HTableBody/RowCheckBox/Title.d.ts +4 -0
- package/lib/HTableBody/RowCheckBox/Title.js +84 -0
- package/lib/HTableBody/RowCheckBox/hooks.d.ts +9 -0
- package/lib/HTableBody/RowCheckBox/hooks.js +75 -0
- package/lib/HTableBody/RowRadioBoxSelection.d.ts +10 -0
- package/lib/HTableBody/RowRadioBoxSelection.js +38 -0
- package/lib/HTableBody/hooks/colsMk.d.ts +17 -0
- package/lib/HTableBody/hooks/colsMk.js +53 -0
- package/lib/HTableBody/hooks/useColData.js +25 -44
- package/lib/HTableBody/hooks/useControl.d.ts +2 -0
- package/lib/HTableBody/hooks/useControl.js +13 -0
- package/lib/HTableBody/index.js +1 -6
- package/lib/Table.js +5 -4
- package/lib/hooks/useRowObj.d.ts +1 -0
- package/lib/hooks/useRowObj.js +13 -2
- package/lib/render/Text.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/HTableBody/RowCheckBox/RowItem.tsx +49 -0
- package/src/components/HTableBody/RowCheckBox/Title.tsx +66 -0
- package/src/components/HTableBody/RowCheckBox/hooks.ts +64 -0
- package/src/components/HTableBody/RowRadioBoxSelection.tsx +27 -0
- package/src/components/HTableBody/hooks/colsMk.tsx +51 -0
- package/src/components/HTableBody/hooks/useColData.tsx +11 -35
- package/src/components/HTableBody/hooks/useControl.tsx +12 -0
- package/src/components/HTableBody/index.tsx +5 -9
- package/src/components/Table.tsx +4 -5
- package/src/components/hooks/useRowObj.ts +11 -1
- package/src/pages/DwTable/index.tsx +7 -2
- package/src/pages/Table/index.tsx +2 -7
- package/es/HTableBody/RowSelection.d.ts +0 -11
- package/es/HTableBody/RowSelection.js +0 -172
- package/lib/HTableBody/RowSelection.d.ts +0 -11
- package/lib/HTableBody/RowSelection.js +0 -174
- package/src/components/HTableBody/RowSelection.tsx +0 -150
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useHTableContext } from "../../context";
|
|
2
|
+
import { Checkbox } from "antd";
|
|
3
|
+
import type { HRowSelection } from "../../modal";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
interface RowSelectionBoxProps {
|
|
7
|
+
data: any;
|
|
8
|
+
onChange?: HRowSelection["onChange"];
|
|
9
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
10
|
+
index: number;
|
|
11
|
+
}
|
|
12
|
+
export default ({
|
|
13
|
+
data,
|
|
14
|
+
onChange,
|
|
15
|
+
index,
|
|
16
|
+
getCheckboxProps,
|
|
17
|
+
}: RowSelectionBoxProps) => {
|
|
18
|
+
const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
|
|
19
|
+
const { rowData = [], keys = [] } = selectedRowData;
|
|
20
|
+
const key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
|
|
21
|
+
const add = () => {
|
|
22
|
+
const newKeys = [...keys];
|
|
23
|
+
const newRowData = [...rowData];
|
|
24
|
+
newKeys.push(key);
|
|
25
|
+
newRowData.push(data);
|
|
26
|
+
rowOnChange(newKeys, newRowData);
|
|
27
|
+
onChange?.(newKeys, newRowData);
|
|
28
|
+
};
|
|
29
|
+
const cancel = () => {
|
|
30
|
+
const newKeys = [...keys];
|
|
31
|
+
const newRowData = [...rowData];
|
|
32
|
+
const keyIndex = newKeys.indexOf(key);
|
|
33
|
+
newKeys.splice(keyIndex, 1);
|
|
34
|
+
newRowData.splice(keyIndex, 1);
|
|
35
|
+
rowOnChange(newKeys, newRowData);
|
|
36
|
+
onChange?.(newKeys, newRowData);
|
|
37
|
+
};
|
|
38
|
+
const check = (e) => {
|
|
39
|
+
const checked = e.target.checked;
|
|
40
|
+
if (checked) {
|
|
41
|
+
add();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
cancel();
|
|
45
|
+
};
|
|
46
|
+
const { disabled = false } = getCheckboxProps?.(data) || {};
|
|
47
|
+
const checked = keys.indexOf(key) !== -1;
|
|
48
|
+
return <Checkbox checked={checked} onChange={check} disabled={disabled} />;
|
|
49
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {HRowSelection} from "@/components/modal";
|
|
2
|
+
import {useHTableContext} from "@/components/context";
|
|
3
|
+
import {useMemo} from "react";
|
|
4
|
+
import {Checkbox, Dropdown, Menu} from "antd";
|
|
5
|
+
import {useAllChecked, useCheckControl} from "./hooks";
|
|
6
|
+
export default ({
|
|
7
|
+
allPageCheck = true,
|
|
8
|
+
onChange,
|
|
9
|
+
getCheckboxProps,
|
|
10
|
+
}: HRowSelection) => {
|
|
11
|
+
const {
|
|
12
|
+
data,
|
|
13
|
+
selectedRowData,
|
|
14
|
+
rowKey = "id",
|
|
15
|
+
} = useHTableContext();
|
|
16
|
+
const { records = [] } = data || {};
|
|
17
|
+
const newData = records?.filter((item) => {
|
|
18
|
+
const { disabled = false } = getCheckboxProps?.(item) || {};
|
|
19
|
+
return !disabled;
|
|
20
|
+
});
|
|
21
|
+
const { keys, selectAll } = selectedRowData;
|
|
22
|
+
const {checkChange,menuClick}=useCheckControl(newData,onChange);
|
|
23
|
+
const dataLen = newData?.length || 0;
|
|
24
|
+
const checked = useAllChecked(keys,newData);
|
|
25
|
+
const configItems = useMemo(() => {
|
|
26
|
+
const fsArray = checked
|
|
27
|
+
? {
|
|
28
|
+
label: "取消此页数据",
|
|
29
|
+
key: "cancel",
|
|
30
|
+
}
|
|
31
|
+
: {
|
|
32
|
+
label: "选择此页数据",
|
|
33
|
+
key: "check",
|
|
34
|
+
};
|
|
35
|
+
const enArray = selectAll
|
|
36
|
+
? {
|
|
37
|
+
label: "取消全部数据",
|
|
38
|
+
key: "cancelAll",
|
|
39
|
+
}
|
|
40
|
+
: {
|
|
41
|
+
label: "选择全部数据",
|
|
42
|
+
key: "checkAll",
|
|
43
|
+
};
|
|
44
|
+
return [fsArray, enArray];
|
|
45
|
+
}, [checked, selectAll]);
|
|
46
|
+
|
|
47
|
+
const menu = () => {
|
|
48
|
+
const MenuEle = Menu as any;
|
|
49
|
+
return <MenuEle onClick={menuClick} items={configItems} />;
|
|
50
|
+
};
|
|
51
|
+
const disabled = dataLen === 0;
|
|
52
|
+
if (allPageCheck) {
|
|
53
|
+
return (
|
|
54
|
+
<Dropdown overlay={menu} arrow placement={"bottom"} disabled={disabled}>
|
|
55
|
+
<Checkbox
|
|
56
|
+
checked={checked}
|
|
57
|
+
onChange={checkChange}
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
/>
|
|
60
|
+
</Dropdown>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return (
|
|
64
|
+
<Checkbox checked={checked} onChange={checkChange} disabled={disabled} />
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {HTableProps} from "@/components/modal";
|
|
2
|
+
import {Key} from "react";
|
|
3
|
+
import {useHTableContext} from "@/components/context";
|
|
4
|
+
import type { HRowSelection } from "../../modal";
|
|
5
|
+
|
|
6
|
+
const getRowKey=(item:any,index:number,rowKey:HTableProps["rowKey"])=>{
|
|
7
|
+
return typeof rowKey === "function" ? rowKey(item, index) : item[rowKey as string];
|
|
8
|
+
}
|
|
9
|
+
export const useAllChecked=(keys:Key[]=[],data:any[]=[])=>{
|
|
10
|
+
const {rowKey = "id"} = useHTableContext();
|
|
11
|
+
return data.every((item,index)=>{
|
|
12
|
+
const itemKey=getRowKey(item,index,rowKey);
|
|
13
|
+
return keys.indexOf(itemKey)!==-1;
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const useCheckControl=(data:any[]=[],onChange:HRowSelection["onChange"])=>{
|
|
18
|
+
const {
|
|
19
|
+
rowOnChange,
|
|
20
|
+
rowKey = "id",
|
|
21
|
+
allSelectChange,
|
|
22
|
+
} = useHTableContext();
|
|
23
|
+
const allCheck = () => {
|
|
24
|
+
const setKeys = data.map((item, index) => {
|
|
25
|
+
return getRowKey(item,index,rowKey);
|
|
26
|
+
});
|
|
27
|
+
rowOnChange(setKeys, data);
|
|
28
|
+
onChange?.(setKeys, data);
|
|
29
|
+
};
|
|
30
|
+
const allCancel = () => {
|
|
31
|
+
rowOnChange([], []);
|
|
32
|
+
onChange?.([], []);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const checkChange = (e) => {
|
|
36
|
+
const checked = e.target.checked;
|
|
37
|
+
if (checked) {
|
|
38
|
+
allCheck();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
allCancel();
|
|
42
|
+
};
|
|
43
|
+
const menuClick = ({ key }) => {
|
|
44
|
+
if (key === "check") {
|
|
45
|
+
allCheck();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (key === "cancel") {
|
|
49
|
+
allCancel();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (key === "checkAll") {
|
|
53
|
+
allSelectChange?.(true);
|
|
54
|
+
onChange?.([], []);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
allSelectChange?.(false);
|
|
58
|
+
onChange?.([], []);
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
checkChange,
|
|
62
|
+
menuClick
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {HRowSelection} from "@/components/modal";
|
|
2
|
+
import {useHTableContext} from "@/components/context";
|
|
3
|
+
import {Radio} from "antd";
|
|
4
|
+
|
|
5
|
+
interface RowRadioSelection {
|
|
6
|
+
data: any;
|
|
7
|
+
onChange?: HRowSelection["onChange"];
|
|
8
|
+
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
9
|
+
index: number;
|
|
10
|
+
}
|
|
11
|
+
export const RowRadioSelection = ({
|
|
12
|
+
data,
|
|
13
|
+
onChange,
|
|
14
|
+
index,
|
|
15
|
+
getCheckboxProps,
|
|
16
|
+
}: RowRadioSelection) => {
|
|
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
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {HRowSelection} from "@/components/modal";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import {RowRadioSelection} from "@/components/HTableBody/RowRadioBoxSelection";
|
|
4
|
+
import RowCheckBoxSelectionTitle from '@/components/HTableBody/RowCheckBox/Title';
|
|
5
|
+
import RowCheckBoxSelection from '@/components/HTableBody/RowCheckBox/RowItem';
|
|
6
|
+
export const checkBoxSelectionCol = (rowSelection: HRowSelection) => {
|
|
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
|
+
};
|
|
32
|
+
|
|
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
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useHTableContext } from "@/components/context";
|
|
2
|
-
import
|
|
3
|
-
import { GetRowKey } from "rc-table/lib/interface";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
4
3
|
import type {
|
|
5
4
|
ConfigDataModal,
|
|
6
5
|
ConfigItemModal,
|
|
@@ -12,41 +11,17 @@ import { useClassName } from "@/components/hooks";
|
|
|
12
11
|
import { useHTableConfigContext } from "@/components/TableConfig";
|
|
13
12
|
import { textTypes } from "@/components/render/config";
|
|
14
13
|
import configRender from "@/components/render";
|
|
15
|
-
import {
|
|
16
|
-
RowSelectionBox,
|
|
17
|
-
RowSelectionTitle,
|
|
18
|
-
} from "@/components/HTableBody/RowSelection";
|
|
19
14
|
import type { ColumnsState } from "@ant-design/pro-table/es/container";
|
|
20
15
|
import { mkChangeValue, outColSetting } from "@/components/HTableBody/utils";
|
|
21
16
|
import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
getCheckboxProps={getCheckboxProps}
|
|
31
|
-
/>
|
|
32
|
-
),
|
|
33
|
-
width: 36,
|
|
34
|
-
rowSelectionTitle: true,
|
|
35
|
-
fixed: "left",
|
|
36
|
-
align: "center",
|
|
37
|
-
render: (dom, data, index) => {
|
|
38
|
-
return (
|
|
39
|
-
<RowSelectionBox
|
|
40
|
-
data={data}
|
|
41
|
-
index={index}
|
|
42
|
-
onChange={onChange}
|
|
43
|
-
getCheckboxProps={getCheckboxProps}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
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
|
+
}
|
|
50
25
|
export const useCols = ({
|
|
51
26
|
configData,
|
|
52
27
|
rowSelection,
|
|
@@ -93,7 +68,7 @@ export const useCols = ({
|
|
|
93
68
|
return !item.hideInTable;
|
|
94
69
|
});
|
|
95
70
|
if (rowSelection !== false) {
|
|
96
|
-
colsArray.splice(0, 0,
|
|
71
|
+
colsArray.splice(0, 0, checkBoxMk(rowSelection||{}) as any);
|
|
97
72
|
}
|
|
98
73
|
return colsArray.map((item, index) => {
|
|
99
74
|
const lastItem = colsArray[index - 1];
|
|
@@ -107,6 +82,7 @@ export const useCols = ({
|
|
|
107
82
|
cols,
|
|
108
83
|
};
|
|
109
84
|
};
|
|
85
|
+
|
|
110
86
|
interface useColumnsStateTypeModal {
|
|
111
87
|
columnsState?: ColumnsStateType;
|
|
112
88
|
columns: ConfigDataModal;
|
|
@@ -4,6 +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
8
|
|
|
8
9
|
export const useSize = (size: SizeType) => {
|
|
9
10
|
const [cuSize, setCuSize] = useState(size);
|
|
@@ -104,3 +105,14 @@ export const useSynchronousKeys = ({
|
|
|
104
105
|
}
|
|
105
106
|
}, [selectedRowKeys, records, rowKey]);
|
|
106
107
|
};
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
export const useAlwaysShowAlert=(selectedRowData:RowObj,alwaysShowAlert?:boolean)=>{
|
|
111
|
+
const { keys = [], selectAll } = selectedRowData;
|
|
112
|
+
return useMemo(()=>{
|
|
113
|
+
if (typeof alwaysShowAlert!=="undefined"){
|
|
114
|
+
return alwaysShowAlert
|
|
115
|
+
}
|
|
116
|
+
return keys.length > 0 || selectAll;
|
|
117
|
+
},[selectedRowData,alwaysShowAlert])
|
|
118
|
+
}
|
|
@@ -2,7 +2,7 @@ import ProTable from "@ant-design/pro-table";
|
|
|
2
2
|
import {
|
|
3
3
|
useSize,
|
|
4
4
|
useTableChange,
|
|
5
|
-
useSynchronousKeys,
|
|
5
|
+
useSynchronousKeys, useAlwaysShowAlert,
|
|
6
6
|
} from "./hooks/useControl";
|
|
7
7
|
import { useCols, useColumnsStateType } from "./hooks/useColData";
|
|
8
8
|
import { useHTableContext } from "../context";
|
|
@@ -44,8 +44,7 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
44
44
|
bordered,
|
|
45
45
|
...props
|
|
46
46
|
} = bodyProps;
|
|
47
|
-
const { selectedRowKeys, alwaysShowAlert: configAlwaysShowAlert } =
|
|
48
|
-
rowSelection || {};
|
|
47
|
+
const { selectedRowKeys, alwaysShowAlert: configAlwaysShowAlert } = rowSelection || {};
|
|
49
48
|
const {
|
|
50
49
|
tableInstance: contextTableInstance,
|
|
51
50
|
configData: contextConfigData,
|
|
@@ -89,11 +88,8 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
89
88
|
reset={reset}
|
|
90
89
|
/>
|
|
91
90
|
);
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
? optionsRender(optionsNode)
|
|
95
|
-
: optionsNode;
|
|
96
|
-
const alwaysShowAlert = keys.length > 0 || selectAll || configAlwaysShowAlert;
|
|
91
|
+
const defaultOptionsNode = optionsRender ? optionsRender(optionsNode) : optionsNode;
|
|
92
|
+
const alwaysShowAlert = useAlwaysShowAlert(selectedRowData,configAlwaysShowAlert);
|
|
97
93
|
const className = useClassName("hw-table-body");
|
|
98
94
|
const { tableStyle: defaultTableStyle } = useHTableConfigContext({
|
|
99
95
|
tableStyle,
|
|
@@ -104,6 +100,7 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
104
100
|
table: tableInstance,
|
|
105
101
|
localSorter,
|
|
106
102
|
});
|
|
103
|
+
|
|
107
104
|
return (
|
|
108
105
|
<div style={defaultTableStyle} className={`hw_table_body ${className}`}>
|
|
109
106
|
<Space size={16} direction={"vertical"} style={{ width: "100%" }}>
|
|
@@ -138,7 +135,6 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
138
135
|
paddingBottom: 0,
|
|
139
136
|
}}
|
|
140
137
|
options={false}
|
|
141
|
-
rowSelection={false}
|
|
142
138
|
loading={loading}
|
|
143
139
|
rowKey={rowKey}
|
|
144
140
|
dataSource={records}
|
package/src/components/Table.tsx
CHANGED
|
@@ -44,19 +44,18 @@ export default ({
|
|
|
44
44
|
reload,
|
|
45
45
|
});
|
|
46
46
|
const dispatch = useDispatch(action);
|
|
47
|
-
const { selectedRowData, rowOnChange, allSelectChange, setSelectedRowData } =
|
|
48
|
-
useRowObj(rowSelection);
|
|
47
|
+
const { selectedRowData, rowOnChange, allSelectChange, setSelectedRowData,rowSelectionReload } = useRowObj(rowSelection);
|
|
49
48
|
const [open, setOpen] = useState<boolean | undefined>();
|
|
50
49
|
const tableInstance = useCurrentTable({
|
|
51
50
|
table,
|
|
52
51
|
reload: (params) => {
|
|
53
|
-
|
|
52
|
+
rowSelectionReload();
|
|
54
53
|
return run(params);
|
|
55
54
|
},
|
|
56
55
|
changeRowData: rowOnChange,
|
|
57
56
|
dispatch,
|
|
58
57
|
reloadWithParams: (reloadParams = {}) => {
|
|
59
|
-
|
|
58
|
+
rowSelectionReload();
|
|
60
59
|
return run({ ...saveParams.old, ...reloadParams });
|
|
61
60
|
},
|
|
62
61
|
getTableParams: () => {
|
|
@@ -79,7 +78,7 @@ export default ({
|
|
|
79
78
|
action,
|
|
80
79
|
configData,
|
|
81
80
|
onFinish: (value) => {
|
|
82
|
-
|
|
81
|
+
rowSelectionReload();
|
|
83
82
|
return run({ ...saveParams.old, ...value, current: 1 });
|
|
84
83
|
},
|
|
85
84
|
onPageChange: tableInstance.table.reloadWithParams,
|
|
@@ -13,7 +13,6 @@ export default (rowSelection?: HRowSelection | false) => {
|
|
|
13
13
|
};
|
|
14
14
|
const [selectedRowData, setSelectedRowData] = useState<RowObj>({});
|
|
15
15
|
const { selectAll = false } = selectedRowData;
|
|
16
|
-
const selectedRowDataSource = useMemo(() => {}, []);
|
|
17
16
|
const rowOnChange = (keys: React.Key[], rowData: any[]) => {
|
|
18
17
|
setSelectedRowData({
|
|
19
18
|
keys,
|
|
@@ -27,10 +26,21 @@ export default (rowSelection?: HRowSelection | false) => {
|
|
|
27
26
|
selectAll: newChecked,
|
|
28
27
|
});
|
|
29
28
|
};
|
|
29
|
+
const rowSelectionReload=()=>{
|
|
30
|
+
if (rowSelection===false){
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const {preserveSelectedRowKeys}=rowSelection||{};
|
|
34
|
+
if (preserveSelectedRowKeys){
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
rowOnChange([],[]);
|
|
38
|
+
}
|
|
30
39
|
return {
|
|
31
40
|
rowOnChange,
|
|
32
41
|
selectedRowData,
|
|
33
42
|
allSelectChange,
|
|
34
43
|
setSelectedRowData,
|
|
44
|
+
rowSelectionReload
|
|
35
45
|
};
|
|
36
46
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button } from "antd";
|
|
2
|
-
import {
|
|
2
|
+
import {HDwTable, HModalTable, HTable, useHDialogTable} from "@/components";
|
|
3
3
|
const configData = [
|
|
4
4
|
{
|
|
5
5
|
title: "座位",
|
|
@@ -95,10 +95,15 @@ const Test = () => {
|
|
|
95
95
|
|
|
96
96
|
return (
|
|
97
97
|
<>
|
|
98
|
-
<
|
|
98
|
+
<HModalTable
|
|
99
99
|
dialogTable={dialogTable1}
|
|
100
100
|
title="111"
|
|
101
101
|
configData={configData}
|
|
102
|
+
tableProps={{
|
|
103
|
+
rowSelection:{
|
|
104
|
+
type:"radio"
|
|
105
|
+
}
|
|
106
|
+
}}
|
|
102
107
|
request={req2}
|
|
103
108
|
contentRender={(node) => {
|
|
104
109
|
return (
|
|
@@ -181,6 +181,7 @@ export default () => {
|
|
|
181
181
|
size: "10",
|
|
182
182
|
current: "1",
|
|
183
183
|
});
|
|
184
|
+
const [keys,setKeys]=useState([]);
|
|
184
185
|
return (
|
|
185
186
|
<HFormConfigProvider>
|
|
186
187
|
<div>
|
|
@@ -192,12 +193,6 @@ export default () => {
|
|
|
192
193
|
>
|
|
193
194
|
获取
|
|
194
195
|
</div>
|
|
195
|
-
{/*<ProTable*/}
|
|
196
|
-
{/* columns={configData}*/}
|
|
197
|
-
{/* scroll={{ x: 1000 }}*/}
|
|
198
|
-
{/* loading={loading}*/}
|
|
199
|
-
{/* dataSource={data}*/}
|
|
200
|
-
{/*/>*/}
|
|
201
196
|
<HTable
|
|
202
197
|
configData={configData}
|
|
203
198
|
rowKey={(rowData, index) => {
|
|
@@ -212,6 +207,7 @@ export default () => {
|
|
|
212
207
|
}}
|
|
213
208
|
rowSelection={{
|
|
214
209
|
allPageCheck: false,
|
|
210
|
+
preserveSelectedRowKeys:true,
|
|
215
211
|
}}
|
|
216
212
|
affixProps={{
|
|
217
213
|
target: () => document.querySelector(".body"),
|
|
@@ -227,7 +223,6 @@ export default () => {
|
|
|
227
223
|
mobileList: "mobileList",
|
|
228
224
|
}}
|
|
229
225
|
request={(params) => {
|
|
230
|
-
console.log(params);
|
|
231
226
|
return Promise.resolve({
|
|
232
227
|
current: 1,
|
|
233
228
|
records: maker(`第${100}页`),
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { HRowSelection } from "../modal";
|
|
3
|
-
export declare const RowSelectionTitle: ({ allPageCheck, onChange, getCheckboxProps, }: HRowSelection) => JSX.Element;
|
|
4
|
-
interface RowSelectionBoxProps {
|
|
5
|
-
data: any;
|
|
6
|
-
onChange?: HRowSelection["onChange"];
|
|
7
|
-
getCheckboxProps?: HRowSelection["getCheckboxProps"];
|
|
8
|
-
index: number;
|
|
9
|
-
}
|
|
10
|
-
export declare const RowSelectionBox: ({ data, onChange, index, getCheckboxProps, }: RowSelectionBoxProps) => JSX.Element;
|
|
11
|
-
export {};
|