@hw-component/table 1.9.91 → 1.9.92
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/Content.d.ts +1 -1
- package/es/HTableBody/Options/Content.js +93 -85
- package/es/HTableBody/Options/ContentTree.d.ts +7 -0
- package/es/HTableBody/Options/ContentTree.js +41 -0
- package/es/HTableBody/Options/Title.d.ts +1 -1
- package/es/HTableBody/Options/hooks.d.ts +17 -0
- package/es/HTableBody/Options/hooks.js +53 -1
- package/es/HTableBody/Options/index.d.ts +1 -1
- package/es/HTableBody/Options/utils.d.ts +8 -1
- package/es/HTableBody/Options/utils.js +29 -2
- package/es/HTableBody/hooks/useColData.d.ts +2 -1
- package/es/HTableBody/hooks/useColData.js +7 -3
- package/es/HTableBody/index.js +8 -4
- package/es/index.css +4 -0
- package/lib/HTableBody/Options/Content.d.ts +1 -1
- package/lib/HTableBody/Options/Content.js +91 -83
- package/lib/HTableBody/Options/ContentTree.d.ts +7 -0
- package/lib/HTableBody/Options/ContentTree.js +44 -0
- package/lib/HTableBody/Options/Title.d.ts +1 -1
- package/lib/HTableBody/Options/hooks.d.ts +17 -0
- package/lib/HTableBody/Options/hooks.js +54 -0
- package/lib/HTableBody/Options/index.d.ts +1 -1
- package/lib/HTableBody/Options/utils.d.ts +8 -1
- package/lib/HTableBody/Options/utils.js +29 -1
- package/lib/HTableBody/hooks/useColData.d.ts +2 -1
- package/lib/HTableBody/hooks/useColData.js +7 -3
- package/lib/HTableBody/index.js +8 -4
- package/lib/index.css +4 -0
- package/package.json +1 -1
- package/src/components/HTableBody/Options/Content.tsx +81 -76
- package/src/components/HTableBody/Options/ContentTree.tsx +38 -0
- package/src/components/HTableBody/Options/Title.tsx +6 -1
- package/src/components/HTableBody/Options/hooks.tsx +79 -0
- package/src/components/HTableBody/Options/index.tsx +1 -3
- package/src/components/HTableBody/Options/modal.d.ts +2 -2
- package/src/components/HTableBody/Options/utils.ts +28 -0
- package/src/components/HTableBody/hooks/useColData.tsx +12 -7
- package/src/components/HTableBody/index.tsx +11 -7
- package/src/components/index.less +4 -0
- package/src/pages/Table/index.tsx +36 -5
- package/src/components/HTableBody/Options/hooks.ts +0 -24
|
@@ -4,12 +4,14 @@ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
|
4
4
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
5
5
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
6
6
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
7
|
-
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
8
7
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
9
8
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
10
9
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
10
|
+
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
11
11
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
12
12
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
13
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
14
|
+
var _spliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/splice');
|
|
13
15
|
var React = require('react');
|
|
14
16
|
|
|
15
17
|
var _excluded = ["dataIndex", "title", "titleStr"];
|
|
@@ -29,6 +31,32 @@ var getItemValue = function getItemValue(data) {
|
|
|
29
31
|
dataIndex: dataIndex
|
|
30
32
|
}, oData);
|
|
31
33
|
};
|
|
34
|
+
var moveCol = function moveCol(_ref) {
|
|
35
|
+
var startKey = _ref.startKey,
|
|
36
|
+
endKey = _ref.endKey,
|
|
37
|
+
data = _ref.data;
|
|
38
|
+
var indexArray = [-1, -1];
|
|
39
|
+
_forEachInstanceProperty(data).call(data, function (item, index) {
|
|
40
|
+
var dataIndex = item.dataIndex;
|
|
41
|
+
if (!dataIndex) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (dataIndex === startKey) {
|
|
45
|
+
indexArray[0] = index;
|
|
46
|
+
}
|
|
47
|
+
if (dataIndex === endKey) {
|
|
48
|
+
indexArray[1] = index;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
var oldIndex = indexArray[0],
|
|
52
|
+
newIndex = indexArray[1];
|
|
53
|
+
var newData = _toConsumableArray(data);
|
|
54
|
+
var oldItem = data[oldIndex];
|
|
55
|
+
_spliceInstanceProperty(newData).call(newData, oldIndex, 1);
|
|
56
|
+
_spliceInstanceProperty(newData).call(newData, newIndex, 0, oldItem);
|
|
57
|
+
return newData;
|
|
58
|
+
};
|
|
32
59
|
|
|
33
60
|
exports.getItemValue = getItemValue;
|
|
61
|
+
exports.moveCol = moveCol;
|
|
34
62
|
// powered by h
|
|
@@ -5,6 +5,7 @@ import type { ColumnsStateType } from "@ant-design/pro-table/es/typing";
|
|
|
5
5
|
export declare const useCols: ({ configData, rowSelection, table, bordered, }: HTableProps) => {
|
|
6
6
|
cols: ConfigDataModal;
|
|
7
7
|
setCols: import("react").Dispatch<import("react").SetStateAction<ConfigDataModal>>;
|
|
8
|
+
resetCols: () => void;
|
|
8
9
|
};
|
|
9
10
|
interface useColumnsStateTypeModal {
|
|
10
11
|
columnsState?: ColumnsStateType;
|
|
@@ -15,6 +16,6 @@ export declare const useColumnsStateType: ({ columnsState, columns, }: useColumn
|
|
|
15
16
|
persistenceKey: string | undefined;
|
|
16
17
|
value: Record<string, ColumnsState> | undefined;
|
|
17
18
|
onChange: (keys: string[], notCheck: string[]) => void;
|
|
18
|
-
|
|
19
|
+
resetCheckCol: () => void;
|
|
19
20
|
};
|
|
20
21
|
export {};
|
|
@@ -93,9 +93,13 @@ var useCols = function useCols(_ref) {
|
|
|
93
93
|
React.useEffect(function () {
|
|
94
94
|
setCols(changeConfigData(configData));
|
|
95
95
|
}, [configData, table, rowSelection]);
|
|
96
|
+
var resetCols = function resetCols() {
|
|
97
|
+
setCols(changeConfigData(configData));
|
|
98
|
+
};
|
|
96
99
|
return {
|
|
97
100
|
cols: cols,
|
|
98
|
-
setCols: setCols
|
|
101
|
+
setCols: setCols,
|
|
102
|
+
resetCols: resetCols
|
|
99
103
|
};
|
|
100
104
|
};
|
|
101
105
|
var useColumnsStateType = function useColumnsStateType(_ref3) {
|
|
@@ -134,7 +138,7 @@ var useColumnsStateType = function useColumnsStateType(_ref3) {
|
|
|
134
138
|
setSelfValue(newObj);
|
|
135
139
|
onChange === null || onChange === void 0 || onChange(newObj);
|
|
136
140
|
};
|
|
137
|
-
var
|
|
141
|
+
var resetCheckCol = function resetCheckCol() {
|
|
138
142
|
setSelfValue(initTableColsVal);
|
|
139
143
|
};
|
|
140
144
|
return {
|
|
@@ -142,7 +146,7 @@ var useColumnsStateType = function useColumnsStateType(_ref3) {
|
|
|
142
146
|
persistenceKey: persistenceKey,
|
|
143
147
|
value: selfValue,
|
|
144
148
|
onChange: change,
|
|
145
|
-
|
|
149
|
+
resetCheckCol: resetCheckCol
|
|
146
150
|
};
|
|
147
151
|
};
|
|
148
152
|
|
package/lib/HTableBody/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var defaultRender = require('./defaultRender.js');
|
|
|
28
28
|
var useRowClassName = require('./hooks/useRowClassName.js');
|
|
29
29
|
|
|
30
30
|
var _excluded = ["configData", "pagination", "onPageChange", "rowSelection", "rowKey", "emptyRender", "errorRender", "tableStyle", "paginationStyle", "headerTitle", "options", "actionRender", "affixProps", "goTop", "size", "optionsRender", "paginationActionRender", "localSorter", "columnsState", "tableExtraRender", "table", "onChange", "bordered", "rowClassName"],
|
|
31
|
-
_excluded2 = ["value", "onChange", "
|
|
31
|
+
_excluded2 = ["value", "onChange", "resetCheckCol"];
|
|
32
32
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
33
33
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
34
34
|
var Body = (function (bodyProps) {
|
|
@@ -93,14 +93,15 @@ var Body = (function (bodyProps) {
|
|
|
93
93
|
bordered: bordered
|
|
94
94
|
}),
|
|
95
95
|
cols = _useCols.cols,
|
|
96
|
-
setCols = _useCols.setCols
|
|
96
|
+
setCols = _useCols.setCols,
|
|
97
|
+
resetCols = _useCols.resetCols;
|
|
97
98
|
var _useColumnsStateType = useColData.useColumnsStateType({
|
|
98
99
|
columnsState: columnsState,
|
|
99
100
|
columns: cols
|
|
100
101
|
}),
|
|
101
102
|
value = _useColumnsStateType.value,
|
|
102
103
|
onChange = _useColumnsStateType.onChange,
|
|
103
|
-
|
|
104
|
+
resetCheckCol = _useColumnsStateType.resetCheckCol,
|
|
104
105
|
selfColStatus = _objectWithoutProperties(_useColumnsStateType, _excluded2);
|
|
105
106
|
useControl.useSynchronousKeys({
|
|
106
107
|
selectedRowKeys: selectedRowKeys,
|
|
@@ -117,7 +118,10 @@ var Body = (function (bodyProps) {
|
|
|
117
118
|
setSizeChange: setCuSize,
|
|
118
119
|
colStatusValue: value || {},
|
|
119
120
|
onChange: onChange,
|
|
120
|
-
reset: reset
|
|
121
|
+
reset: function reset() {
|
|
122
|
+
resetCheckCol();
|
|
123
|
+
resetCols();
|
|
124
|
+
},
|
|
121
125
|
onDrop: setCols
|
|
122
126
|
}));
|
|
123
127
|
var defaultOptionsNode = optionsRender ? optionsRender(optionsNode) : optionsNode;
|
package/lib/index.css
CHANGED
package/package.json
CHANGED
|
@@ -1,68 +1,40 @@
|
|
|
1
1
|
import { useClassName } from "../../hooks";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import type { ConfigDataModal } from "../../modal";
|
|
4
|
-
import { Tree } from "antd";
|
|
5
2
|
import type { ItemProps } from "./modal";
|
|
6
|
-
import {
|
|
3
|
+
import { moveCol } from "./utils";
|
|
4
|
+
import ContentTree from "./ContentTree";
|
|
5
|
+
import { useContentTree, useTreeKeys } from "./hooks";
|
|
7
6
|
|
|
8
|
-
interface MoveArrayProps {
|
|
9
|
-
startKey:string;
|
|
10
|
-
endKey:string;
|
|
11
|
-
data: ConfigDataModal;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const moveArray=({startKey,endKey,data}:MoveArrayProps)=>{
|
|
16
|
-
const indexArray=[-1,-1];
|
|
17
|
-
data.forEach((item,index)=>{
|
|
18
|
-
const{dataIndex}=item;
|
|
19
|
-
if(!dataIndex){
|
|
20
|
-
return;
|
|
21
|
-
};
|
|
22
|
-
if(dataIndex===startKey){
|
|
23
|
-
indexArray[0]=index;
|
|
24
|
-
}
|
|
25
|
-
if(dataIndex===endKey){
|
|
26
|
-
indexArray[1]=index;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
const [oldIndex,newIndex]=indexArray;
|
|
30
|
-
const newData = [...data];
|
|
31
|
-
const oldItem = data[oldIndex];
|
|
32
|
-
newData.splice(oldIndex, 1);
|
|
33
|
-
newData.splice(newIndex, 0, oldItem);
|
|
34
|
-
return newData;
|
|
35
|
-
};
|
|
36
7
|
export const ColsSettingContent = ({
|
|
37
8
|
columns,
|
|
38
9
|
onCheck,
|
|
39
10
|
checkKeys,
|
|
40
|
-
onDrop
|
|
11
|
+
onDrop,
|
|
41
12
|
}: ItemProps) => {
|
|
42
13
|
const content = useClassName("hw-table-body-option-setting-content");
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return treeData;
|
|
61
|
-
}, [columns]);
|
|
14
|
+
const norContentTreeData = useContentTree({ columns });
|
|
15
|
+
const leftContentTreeData = useContentTree({ columns, matchKey: "left" });
|
|
16
|
+
const rightContentTreeData = useContentTree({ columns, matchKey: "right" });
|
|
17
|
+
const norCheckKeys = useTreeKeys({
|
|
18
|
+
treeData: norContentTreeData,
|
|
19
|
+
checkKeys,
|
|
20
|
+
});
|
|
21
|
+
const leftCheckKeys = useTreeKeys({
|
|
22
|
+
treeData: leftContentTreeData,
|
|
23
|
+
checkKeys,
|
|
24
|
+
});
|
|
25
|
+
const rightCheckKeys = useTreeKeys({
|
|
26
|
+
treeData: rightContentTreeData,
|
|
27
|
+
checkKeys,
|
|
28
|
+
});
|
|
62
29
|
|
|
63
30
|
const check = (keys: string[]) => {
|
|
64
31
|
const notCheck: string[] = [];
|
|
65
|
-
|
|
32
|
+
const allTreeData = [
|
|
33
|
+
...leftContentTreeData,
|
|
34
|
+
...norContentTreeData,
|
|
35
|
+
...rightContentTreeData,
|
|
36
|
+
];
|
|
37
|
+
allTreeData.forEach(({ key }) => {
|
|
66
38
|
const cuKey = key as string;
|
|
67
39
|
const index = keys.indexOf(cuKey);
|
|
68
40
|
if (index === -1) {
|
|
@@ -71,31 +43,64 @@ export const ColsSettingContent = ({
|
|
|
71
43
|
});
|
|
72
44
|
onCheck(keys, notCheck);
|
|
73
45
|
};
|
|
74
|
-
const onDropEnd=({dragNodesKeys,dropPosition})=>{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
46
|
+
const onDropEnd = ({ dragNodesKeys, dropPosition }) => {
|
|
47
|
+
if (dropPosition < 1) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const allTreeData = [
|
|
51
|
+
...leftContentTreeData,
|
|
52
|
+
...norContentTreeData,
|
|
53
|
+
...rightContentTreeData,
|
|
54
|
+
];
|
|
55
|
+
const [key] = dragNodesKeys;
|
|
56
|
+
const sourceKey = allTreeData[dropPosition - 1].key;
|
|
57
|
+
const newData = moveCol({
|
|
58
|
+
startKey: key,
|
|
59
|
+
endKey: sourceKey as string,
|
|
60
|
+
data: columns,
|
|
61
|
+
});
|
|
62
|
+
onDrop(newData);
|
|
63
|
+
};
|
|
83
64
|
return (
|
|
84
65
|
<div className={content}>
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
66
|
+
<ContentTree
|
|
67
|
+
title="固定在左侧"
|
|
68
|
+
treeData={leftContentTreeData}
|
|
69
|
+
checkedKeys={leftCheckKeys}
|
|
70
|
+
onDrop={onDropEnd}
|
|
71
|
+
onCheck={(key) => {
|
|
72
|
+
const curKey = key as string[];
|
|
73
|
+
check([...curKey,...norCheckKeys,...rightCheckKeys]);
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
<ContentTree
|
|
77
|
+
title="不固定"
|
|
78
|
+
treeData={norContentTreeData}
|
|
79
|
+
checkedKeys={norCheckKeys}
|
|
80
|
+
onDrop={({ dragNodesKeys, dropPosition })=>{
|
|
81
|
+
const cuDropPosition=leftContentTreeData.length+dropPosition;
|
|
82
|
+
onDropEnd({dragNodesKeys, dropPosition:cuDropPosition});
|
|
83
|
+
}}
|
|
84
|
+
onCheck={(key) => {
|
|
85
|
+
const curKey = key as string[];
|
|
86
|
+
check([...leftCheckKeys,...curKey,...rightCheckKeys]);
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
<ContentTree
|
|
90
|
+
title="固定在右侧"
|
|
91
|
+
treeData={rightContentTreeData}
|
|
92
|
+
checkedKeys={rightCheckKeys}
|
|
93
|
+
onDrop={({ dragNodesKeys, dropPosition })=>{
|
|
94
|
+
const leftLen=leftContentTreeData.length;
|
|
95
|
+
const norLen=norContentTreeData.length;
|
|
96
|
+
const cuDropPosition=leftLen+norLen+dropPosition;
|
|
97
|
+
onDropEnd({dragNodesKeys, dropPosition:cuDropPosition});
|
|
98
|
+
}}
|
|
99
|
+
onCheck={(key) => {
|
|
100
|
+
const curKey = key as string[];
|
|
101
|
+
check([...leftCheckKeys,...norCheckKeys,...curKey]);
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
99
104
|
</div>
|
|
100
105
|
);
|
|
101
106
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Space, Tree, Typography } from "antd";
|
|
3
|
+
import { useClassName } from "@/components/hooks";
|
|
4
|
+
import type { TreeProps } from "antd/lib/tree/Tree";
|
|
5
|
+
|
|
6
|
+
interface IProps extends TreeProps {
|
|
7
|
+
title: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default ({ treeData, checkedKeys, onDrop, onCheck, title }: IProps) => {
|
|
11
|
+
const treeClass = useClassName("hw-table-body-option-tree");
|
|
12
|
+
const treeItemContent = useClassName("hw-table-op-tree-content");
|
|
13
|
+
|
|
14
|
+
if (!treeData?.length) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return (
|
|
18
|
+
<Space
|
|
19
|
+
className={treeItemContent}
|
|
20
|
+
direction="vertical"
|
|
21
|
+
size={12}
|
|
22
|
+
>
|
|
23
|
+
<Typography.Text type={"secondary"} style={{ paddingLeft: 24 }}>
|
|
24
|
+
{title}
|
|
25
|
+
</Typography.Text>
|
|
26
|
+
<Tree
|
|
27
|
+
checkable
|
|
28
|
+
className={treeClass}
|
|
29
|
+
draggable
|
|
30
|
+
checkedKeys={checkedKeys}
|
|
31
|
+
onDrop={onDrop}
|
|
32
|
+
onCheck={onCheck}
|
|
33
|
+
height={268}
|
|
34
|
+
treeData={treeData}
|
|
35
|
+
/>
|
|
36
|
+
</Space>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -4,7 +4,12 @@ import type { ItemProps } from "./modal";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
|
|
6
6
|
const { Link } = Typography;
|
|
7
|
-
export const Title = ({
|
|
7
|
+
export const Title = ({
|
|
8
|
+
columns,
|
|
9
|
+
onCheck,
|
|
10
|
+
checkKeys,
|
|
11
|
+
reset,
|
|
12
|
+
}: Omit<ItemProps, "onDrop">) => {
|
|
8
13
|
const title = useClassName("hw-table-body-option-setting-title");
|
|
9
14
|
const relArrayKeys = useMemo(() => {
|
|
10
15
|
const keys: string[] = [];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import type { IProps, ItemProps } from "@/components/HTableBody/Options/modal";
|
|
3
|
+
import type { ConfigDataModal } from "@/components/modal";
|
|
4
|
+
import { getItemValue } from "@/components/HTableBody/Options/utils";
|
|
5
|
+
import { useClassName } from "@/components/hooks";
|
|
6
|
+
|
|
7
|
+
export const useCheckKeys = ({
|
|
8
|
+
columns,
|
|
9
|
+
colStatusValue,
|
|
10
|
+
}: Pick<IProps, "colStatusValue" | "columns">) => {
|
|
11
|
+
return useMemo(() => {
|
|
12
|
+
const keys: string[] = [];
|
|
13
|
+
columns.forEach((value) => {
|
|
14
|
+
const { dataIndex, hideInTable } = value;
|
|
15
|
+
if (hideInTable || !dataIndex) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const dataIndexStr = dataIndex.toString();
|
|
19
|
+
const { show = true } = colStatusValue[dataIndexStr] || {};
|
|
20
|
+
if (!show) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
keys.push(dataIndexStr);
|
|
24
|
+
});
|
|
25
|
+
return keys;
|
|
26
|
+
}, [colStatusValue, columns]);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
interface UseContentTreeModal {
|
|
30
|
+
columns: ConfigDataModal;
|
|
31
|
+
matchKey?: "right" | "left";
|
|
32
|
+
}
|
|
33
|
+
interface ColDataNode {
|
|
34
|
+
title: React.ReactNode;
|
|
35
|
+
key: string;
|
|
36
|
+
}
|
|
37
|
+
export const useContentTree = ({ columns, matchKey }: UseContentTreeModal) => {
|
|
38
|
+
const titleClass = useClassName("hw-table-body-option-setting-content-title");
|
|
39
|
+
return useMemo<ColDataNode[]>(() => {
|
|
40
|
+
const treeData: ColDataNode[] = [];
|
|
41
|
+
columns.forEach(({ dataIndex, title, titleStr, fixed }) => {
|
|
42
|
+
if (!dataIndex) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (fixed !== matchKey) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const { title: cuTitleStr } = getItemValue({
|
|
49
|
+
titleStr,
|
|
50
|
+
title,
|
|
51
|
+
});
|
|
52
|
+
treeData.push({
|
|
53
|
+
title: <div className={titleClass}>{cuTitleStr}</div>,
|
|
54
|
+
key: dataIndex.toString(),
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
return treeData;
|
|
58
|
+
}, [columns]);
|
|
59
|
+
};
|
|
60
|
+
interface UseTreeKeysModal {
|
|
61
|
+
treeData:ColDataNode[];
|
|
62
|
+
checkKeys:string[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const useTreeKeys = ({
|
|
66
|
+
treeData,
|
|
67
|
+
checkKeys,
|
|
68
|
+
}: UseTreeKeysModal) => {
|
|
69
|
+
return useMemo(()=>{
|
|
70
|
+
const newKeys: string[] = [];
|
|
71
|
+
treeData.forEach(({ key }) => {
|
|
72
|
+
const index = checkKeys.indexOf(key);
|
|
73
|
+
if (index !== -1) {
|
|
74
|
+
newKeys.push(key);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return newKeys;
|
|
78
|
+
},[treeData, checkKeys])
|
|
79
|
+
};
|
|
@@ -12,8 +12,6 @@ import { Title } from "./Title";
|
|
|
12
12
|
import type { IProps } from "./modal";
|
|
13
13
|
import { useCheckKeys } from "@/components/HTableBody/Options/hooks";
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
15
|
export default ({
|
|
18
16
|
reload,
|
|
19
17
|
size = "middle",
|
|
@@ -24,7 +22,7 @@ export default ({
|
|
|
24
22
|
colStatusValue,
|
|
25
23
|
reset,
|
|
26
24
|
settingRender,
|
|
27
|
-
|
|
25
|
+
onDrop,
|
|
28
26
|
}: IProps) => {
|
|
29
27
|
const pointer = useClassName([
|
|
30
28
|
"hw-table-pointer",
|
|
@@ -12,7 +12,7 @@ export interface IProps extends OptionConfig {
|
|
|
12
12
|
colStatusValue: Record<string, ColumnsState>;
|
|
13
13
|
reset: VoidFunction;
|
|
14
14
|
settingRender?: () => React.ReactNode;
|
|
15
|
-
onDrop:(columns:ConfigDataModal)=>void;
|
|
15
|
+
onDrop: (columns: ConfigDataModal) => void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface ItemProps {
|
|
@@ -20,5 +20,5 @@ export interface ItemProps {
|
|
|
20
20
|
onCheck: (keys: string[], notCheck: string[]) => void;
|
|
21
21
|
columns: ConfigDataModal;
|
|
22
22
|
reset?: VoidFunction;
|
|
23
|
-
onDrop:(columns:ConfigDataModal)=>void;
|
|
23
|
+
onDrop: (columns: ConfigDataModal) => void;
|
|
24
24
|
}
|
|
@@ -13,3 +13,31 @@ export const getItemValue = (data: ConfigItemModal) => {
|
|
|
13
13
|
...oData,
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
|
|
17
|
+
interface MoveColProps {
|
|
18
|
+
startKey: string;
|
|
19
|
+
endKey: string;
|
|
20
|
+
data: ConfigDataModal;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const moveCol = ({ startKey, endKey, data }: MoveColProps) => {
|
|
24
|
+
const indexArray = [-1, -1];
|
|
25
|
+
data.forEach((item, index) => {
|
|
26
|
+
const { dataIndex } = item;
|
|
27
|
+
if (!dataIndex) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (dataIndex === startKey) {
|
|
31
|
+
indexArray[0] = index;
|
|
32
|
+
}
|
|
33
|
+
if (dataIndex === endKey) {
|
|
34
|
+
indexArray[1] = index;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const [oldIndex, newIndex] = indexArray;
|
|
38
|
+
const newData = [...data];
|
|
39
|
+
const oldItem = data[oldIndex];
|
|
40
|
+
newData.splice(oldIndex, 1);
|
|
41
|
+
newData.splice(newIndex, 0, oldItem);
|
|
42
|
+
return newData;
|
|
43
|
+
};
|
|
@@ -78,14 +78,16 @@ export const useCols = ({
|
|
|
78
78
|
useEffect(() => {
|
|
79
79
|
setCols(changeConfigData(configData));
|
|
80
80
|
}, [configData, table, rowSelection]);
|
|
81
|
-
|
|
81
|
+
const resetCols = () => {
|
|
82
|
+
setCols(changeConfigData(configData));
|
|
83
|
+
};
|
|
82
84
|
return {
|
|
83
85
|
cols,
|
|
84
|
-
setCols
|
|
86
|
+
setCols,
|
|
87
|
+
resetCols,
|
|
85
88
|
};
|
|
86
89
|
};
|
|
87
90
|
|
|
88
|
-
|
|
89
91
|
interface useColumnsStateTypeModal {
|
|
90
92
|
columnsState?: ColumnsStateType;
|
|
91
93
|
columns: ConfigDataModal;
|
|
@@ -96,8 +98,11 @@ export const useColumnsStateType = ({
|
|
|
96
98
|
columns,
|
|
97
99
|
}: useColumnsStateTypeModal) => {
|
|
98
100
|
const { tableInstance } = useHTableContext();
|
|
99
|
-
const { persistenceType, persistenceKey, value, defaultValue, onChange } =
|
|
100
|
-
|
|
101
|
+
const { persistenceType, persistenceKey, value, defaultValue, onChange } =
|
|
102
|
+
columnsState || {};
|
|
103
|
+
const [selfValue, setSelfValue] = useState<
|
|
104
|
+
Record<string, ColumnsState> | undefined
|
|
105
|
+
>(defaultValue);
|
|
101
106
|
|
|
102
107
|
const initTableColsVal = useMemo(() => {
|
|
103
108
|
return selfValue || {};
|
|
@@ -120,7 +125,7 @@ export const useColumnsStateType = ({
|
|
|
120
125
|
onChange?.(newObj);
|
|
121
126
|
};
|
|
122
127
|
|
|
123
|
-
const
|
|
128
|
+
const resetCheckCol = () => {
|
|
124
129
|
setSelfValue(initTableColsVal);
|
|
125
130
|
};
|
|
126
131
|
return {
|
|
@@ -128,6 +133,6 @@ export const useColumnsStateType = ({
|
|
|
128
133
|
persistenceKey,
|
|
129
134
|
value: selfValue,
|
|
130
135
|
onChange: change,
|
|
131
|
-
|
|
136
|
+
resetCheckCol,
|
|
132
137
|
};
|
|
133
138
|
}; //设置选项
|
|
@@ -66,18 +66,19 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
66
66
|
const { records } = data || {};
|
|
67
67
|
const tableInstance = table || contextTableInstance;
|
|
68
68
|
|
|
69
|
-
const { cols ,
|
|
69
|
+
const { cols, setCols, resetCols } = useCols({
|
|
70
70
|
configData: bodyConfigData,
|
|
71
71
|
table: tableInstance,
|
|
72
72
|
rowSelection,
|
|
73
73
|
bordered,
|
|
74
74
|
});
|
|
75
|
-
const { value, onChange,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
const { value, onChange, resetCheckCol, ...selfColStatus } =
|
|
76
|
+
useColumnsStateType({
|
|
77
|
+
columnsState,
|
|
78
|
+
columns: cols,
|
|
79
|
+
});
|
|
80
80
|
useSynchronousKeys({ selectedRowKeys, records, rowKey });
|
|
81
|
+
|
|
81
82
|
const optionsNode = options && (
|
|
82
83
|
<Options
|
|
83
84
|
reload={() => {
|
|
@@ -89,7 +90,10 @@ export default (bodyProps: HTableBodyProps) => {
|
|
|
89
90
|
setSizeChange={setCuSize}
|
|
90
91
|
colStatusValue={value || {}}
|
|
91
92
|
onChange={onChange}
|
|
92
|
-
reset={
|
|
93
|
+
reset={() => {
|
|
94
|
+
resetCheckCol();
|
|
95
|
+
resetCols();
|
|
96
|
+
}}
|
|
93
97
|
onDrop={setCols}
|
|
94
98
|
/>
|
|
95
99
|
);
|
|
@@ -85,6 +85,10 @@
|
|
|
85
85
|
.@{ant-prefix}-hw-table-body-option-setting-content-title{
|
|
86
86
|
display: flex;
|
|
87
87
|
}
|
|
88
|
+
.@{ant-prefix}-hw-table-op-tree-content{
|
|
89
|
+
padding: 6px 6px 6px 0px;
|
|
90
|
+
width: 100%;
|
|
91
|
+
}
|
|
88
92
|
.@{ant-prefix}-hw-table-body-option-tree{
|
|
89
93
|
.@{ant-prefix}-tree-treenode{
|
|
90
94
|
width: 100%;
|