@lingxiteam/ebe-utils 0.2.22 → 0.2.23
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/lib/h5public/yarn.lock +7 -8
- package/lib/pcpublic/src/components/pcfactory/src/Button/index.tsx +11 -10
- package/lib/pcpublic/src/components/pcfactory/src/Card/CardTitle/index.tsx +31 -24
- package/lib/pcpublic/src/components/pcfactory/src/Card/index.tsx +32 -14
- package/lib/pcpublic/src/components/pcfactory/src/Card/useExtendBtn.tsx +85 -48
- package/lib/pcpublic/src/components/pcfactory/src/ChartLine/ChartLine.tsx +24 -6
- package/lib/pcpublic/src/components/pcfactory/src/ChartLine/PropsType.ts +31 -5
- package/lib/pcpublic/src/components/pcfactory/src/ChartLine/index.tsx +3 -2
- package/lib/pcpublic/src/components/pcfactory/src/ChartLine/loader.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/Form/Form.tsx +153 -129
- package/lib/pcpublic/src/components/pcfactory/src/Form/index.tsx +2 -5
- package/lib/pcpublic/src/components/pcfactory/src/Form/useFormStatus.ts +8 -4
- package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/LXPieChart.tsx +15 -3
- package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/PropsType.ts +4 -3
- package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/loader.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/LXRadarChat.tsx +18 -4
- package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/PropsType.ts +2 -1
- package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/loader.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/BaseModalSelect.tsx +7 -2
- package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/index.tsx +60 -26
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/LcdpUeditorMain.tsx +62 -55
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditor.tsx +2 -6
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditorMain.tsx +5 -5
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/index.tsx +9 -2
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/loader.ts +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/Select/index.tsx +145 -66
- package/lib/pcpublic/src/components/pcfactory/src/Select/selectUtils.ts +13 -9
- package/lib/pcpublic/src/components/pcfactory/src/Table/BodyCell/index.tsx +36 -26
- package/lib/pcpublic/src/components/pcfactory/src/Table/EditComponent/index.tsx +69 -94
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/GhostTag/index.tsx +12 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Hyperlink/index.tsx +9 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PointTag/index.tsx +11 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureColourFill/index.tsx +11 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureFadeColourTag/index.tsx +14 -7
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Thumbnail/index.tsx +30 -31
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/index.tsx +89 -41
- package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/HeaderCellTitle/index.tsx +25 -12
- package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/index.tsx +12 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/PopoverWrapper.tsx +220 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/SingleBtn.tsx +39 -32
- package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/index.tsx +178 -148
- package/lib/pcpublic/src/components/pcfactory/src/Table/Table.tsx +439 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/TableHead/index.tsx +159 -72
- package/lib/pcpublic/src/components/pcfactory/src/Table/TableSummaryRow/index.tsx +12 -20
- package/lib/pcpublic/src/components/pcfactory/src/Table/constant.ts +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/index.ts +4 -4
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +32 -28
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCheckStrict.ts +44 -57
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +306 -276
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCommon.ts +9 -6
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useDataSource.ts +30 -21
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useExpandable.tsx +33 -27
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFilter.tsx +84 -77
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFormatCell.tsx +33 -16
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/usePagination.ts +15 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowEdit.ts +33 -33
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowMerge.ts +13 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useScroll.ts +94 -28
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSelection.ts +108 -99
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSort.ts +8 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +27 -43
- package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +73 -394
- package/lib/pcpublic/src/components/pcfactory/src/Table/loader.tsx +15 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/OperationCell.d.ts +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/event.d.ts +12 -8
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/headerCell.d.ts +2 -1
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/prop.d.ts +24 -11
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/SequenceId.ts +2 -1
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +90 -82
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/indexedDBHelper.ts +9 -22
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/translate.ts +59 -0
- package/lib/pcpublic/src/components/pcfactory/src/Transfer/Transfer.tsx +644 -0
- package/lib/pcpublic/src/components/pcfactory/src/Transfer/index.tsx +49 -637
- package/lib/pcpublic/src/components/pcfactory/src/Transfer/loader.tsx +11 -0
- package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeEllipsisIcon.tsx +38 -0
- package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeNodeMenu/index.tsx +34 -35
- package/lib/pcpublic/src/components/pcfactory/src/Tree/index.tsx +213 -149
- package/lib/pcpublic/src/components/pcfactory/src/TreeSelect/index.tsx +47 -43
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/TreeTable.tsx +264 -0
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/index.ts +4 -1
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useCMDAction.ts +9 -3
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useExpandable.tsx +9 -3
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +52 -191
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/loader.tsx +16 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/index.tsx +34 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/svg/quadrate.tsx +20 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/svg/roundness.tsx +14 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/svg/semicircle.tsx +15 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/svg/verticalLine.tsx +12 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/common.less +17 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Card.less +57 -11
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Form.less +101 -12
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/ModalSelect.less +6 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Select.less +70 -6
- package/lib/pcpublic/src/components/pcfactory/src/utils/ChannelContainer.tsx +20 -14
- package/lib/pcpublic/src/components/pcfactory/src/utils/ChildRender.ts +6 -8
- package/lib/pcpublic/src/components/pcfactory/src/utils/CustomModule.tsx +4 -6
- package/lib/pcpublic/src/components/pcfactory/src/utils/DummyFormContext.ts +9 -13
- package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/empty.tsx +5 -17
- package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/index.tsx +3 -3
- package/lib/pcpublic/src/components/pcfactory/src/utils/Holidays.ts +11 -39
- package/lib/pcpublic/src/components/pcfactory/src/utils/HolidaysFormat.ts +83 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/index.tsx +47 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/scheduler.ts +74 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/LoaderHelper.tsx +4 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/Spin/index.tsx +8 -7
- package/lib/pcpublic/src/components/pcfactory/src/utils/WithSyncValue.ts +25 -23
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/index.ts +10 -7
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMap.ts +9 -6
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMemoizedFn.ts +4 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/usePersistFn.ts +17 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSafeState.ts +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSetState.ts +7 -5
- package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +23 -50
- package/lib/pcpublic/src/components/pcfactory/src/utils/constant.ts +53 -57
- package/lib/pcpublic/src/components/pcfactory/src/utils/dynamicUtils/DynamicContext.tsx +12 -17
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormContext.tsx +22 -12
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormFields.tsx +50 -19
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/WrapperContainer.tsx +58 -37
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/cmdHelper.ts +33 -30
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/common.ts +2 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/generatorDisabledCallback.ts +121 -113
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCommonImperativeHandle.ts +16 -14
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCompState.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDataMask.ts +7 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDoubleClick.ts +3 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useFuncExpExecute.ts +16 -14
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useGetStaticAttrData.ts +9 -3
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useHiddenStyle.ts +4 -5
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInit.ts +11 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInitReactQuill.ts +3 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useListenState.ts +1 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useLocale.ts +5 -3
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/usePrintMode.tsx +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useRules.ts +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useTestHelper.ts +2 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useToggleBoolean.ts +8 -4
- package/lib/pcpublic/src/components/pcfactory/src/utils/index.ts +10 -10
- package/lib/pcpublic/src/components/pcfactory/src/utils/polyfill.js +29 -31
- package/lib/pcpublic/src/components/pcfactory/src/utils/renderReadOnly.tsx +29 -26
- package/lib/public/public/iconfont.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
|
2
|
+
/* eslint-disable eqeqeq */
|
|
3
|
+
/* eslint-disable array-callback-return */
|
|
4
|
+
/* eslint-disable no-param-reassign */
|
|
5
|
+
/* eslint-disable no-underscore-dangle */
|
|
6
|
+
import { Table, Form } from 'antd';
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
import React, { useRef, useMemo } from 'react';
|
|
9
|
+
import BodyCell from './BodyCell';
|
|
10
|
+
import HeaderCell from './HeaderCell';
|
|
11
|
+
import TableHead from './TableHead';
|
|
12
|
+
import { useFuncExpExecute } from '../utils/hooks/useFuncExpExecute';
|
|
13
|
+
import {
|
|
14
|
+
useColumns,
|
|
15
|
+
useRowMerge,
|
|
16
|
+
useScroll,
|
|
17
|
+
} from './hooks';
|
|
18
|
+
import type { MyTableProps, WrapperTablePropsTypes } from './types/prop';
|
|
19
|
+
import EmptyComp from '../utils/Empty';
|
|
20
|
+
import { usePrintMode, PrintContainer } from '../utils';
|
|
21
|
+
import { useLocale } from '../utils/hooks/useLocale';
|
|
22
|
+
import { useCreation } from '../utils/ahooks';
|
|
23
|
+
import TableSummaryRow from './TableSummaryRow';
|
|
24
|
+
import { LingxiForwardRef } from '@lingxiteam/types';
|
|
25
|
+
import useBackgroundStyle from '../View/useBackgroundStyle';
|
|
26
|
+
|
|
27
|
+
const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTablePropsTypes> & WrapperTablePropsTypes>((props) => {
|
|
28
|
+
const {
|
|
29
|
+
dataSource: boundDataSource,
|
|
30
|
+
visible = true,
|
|
31
|
+
style: styles,
|
|
32
|
+
className,
|
|
33
|
+
onChange,
|
|
34
|
+
$$componentItem,
|
|
35
|
+
getEngineApis,
|
|
36
|
+
backgroundType,
|
|
37
|
+
isBordered,
|
|
38
|
+
innerClassName,
|
|
39
|
+
setCurrentPageSize,
|
|
40
|
+
onPageChange,
|
|
41
|
+
filters,
|
|
42
|
+
filterDropdownOpen,
|
|
43
|
+
renderFilterDropDown,
|
|
44
|
+
onFilterDropdownVisibleChange,
|
|
45
|
+
setSortOrder,
|
|
46
|
+
onSortChange,
|
|
47
|
+
hasSortEvent,
|
|
48
|
+
hasExpandContent,
|
|
49
|
+
rowSelection,
|
|
50
|
+
onRowSelectClick,
|
|
51
|
+
nowInlineEditKey,
|
|
52
|
+
nowEditingData,
|
|
53
|
+
onRowAttrValsChange,
|
|
54
|
+
onRowCancelClick,
|
|
55
|
+
onRowDeleteClick,
|
|
56
|
+
onRowEditClick,
|
|
57
|
+
onRowDetailClick,
|
|
58
|
+
onRowClick,
|
|
59
|
+
onRowDoubleClick,
|
|
60
|
+
handleIsRowEditableCanUse,
|
|
61
|
+
currentPageDataSource,
|
|
62
|
+
currentRowKey,
|
|
63
|
+
innerDataSource,
|
|
64
|
+
colServiceData,
|
|
65
|
+
colServiceDataForEdit,
|
|
66
|
+
loading,
|
|
67
|
+
page,
|
|
68
|
+
pagination,
|
|
69
|
+
onRowSaveClick,
|
|
70
|
+
expandable: realExpandable,
|
|
71
|
+
sortDataSource,
|
|
72
|
+
hasPageChangeEvent,
|
|
73
|
+
setCurrentPage,
|
|
74
|
+
form,
|
|
75
|
+
...restProps
|
|
76
|
+
} = props;
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const { uid: compId } = $$componentItem;
|
|
80
|
+
const { size, sortDirections, sticky, summary, tableLayout, title, rowClassName, showHeader = true } = restProps || {};
|
|
81
|
+
const tableProps = {
|
|
82
|
+
size,
|
|
83
|
+
sortDirections,
|
|
84
|
+
sticky,
|
|
85
|
+
summary,
|
|
86
|
+
tableLayout,
|
|
87
|
+
title,
|
|
88
|
+
rowClassName,
|
|
89
|
+
} as any;
|
|
90
|
+
|
|
91
|
+
const engineApis = getEngineApis?.();
|
|
92
|
+
const { backgroundStyle } = useBackgroundStyle({ backgroundType, engineApis, appId: $$componentItem?.appId, mode: 'engine' });
|
|
93
|
+
|
|
94
|
+
const {
|
|
95
|
+
sandBoxSafeRun,
|
|
96
|
+
dataState,
|
|
97
|
+
} = engineApis || {};
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
const { getLocale } = useLocale(engineApis || {});
|
|
101
|
+
|
|
102
|
+
const funcExpExecute = useFuncExpExecute(sandBoxSafeRun as any, getLocale);
|
|
103
|
+
|
|
104
|
+
const appId = props?.appId || $$componentItem?.appId;
|
|
105
|
+
const pageId = props?.pageId || $$componentItem?.pageId;
|
|
106
|
+
|
|
107
|
+
const {
|
|
108
|
+
rowSpanColMap,
|
|
109
|
+
rowSpanMap,
|
|
110
|
+
rowClassMap,
|
|
111
|
+
} = useRowMerge({
|
|
112
|
+
...props,
|
|
113
|
+
currentPageDataSource,
|
|
114
|
+
nowInlineEditKey,
|
|
115
|
+
currentRowKey,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const { showPrintContainer, selectorKey, printData } = usePrintMode(props.$$componentItem.uid);
|
|
119
|
+
|
|
120
|
+
// 根据id获取真实的下标,避免过滤和排序后影响下标
|
|
121
|
+
const { getRealIndexById } = useCreation(() => {
|
|
122
|
+
const indexMap = new Map<string | number, number>();
|
|
123
|
+
return {
|
|
124
|
+
getRealIndexById: (id: string | number) => {
|
|
125
|
+
if (indexMap.has(id)) {
|
|
126
|
+
return indexMap.get(id);
|
|
127
|
+
}
|
|
128
|
+
const index = (innerDataSource || []).findIndex((c: any) => c[currentRowKey] === id);
|
|
129
|
+
if (index !== -1) {
|
|
130
|
+
indexMap.set(id, index);
|
|
131
|
+
}
|
|
132
|
+
return index;
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}, [innerDataSource, currentRowKey]);
|
|
136
|
+
|
|
137
|
+
const {
|
|
138
|
+
tableRef,
|
|
139
|
+
finalcolumns,
|
|
140
|
+
customizableCols,
|
|
141
|
+
customSelectedCols,
|
|
142
|
+
setCustomSelectedCols,
|
|
143
|
+
setColCustomOrder,
|
|
144
|
+
columnWidth,
|
|
145
|
+
setColumnWidth,
|
|
146
|
+
initLoadColWidth,
|
|
147
|
+
printColumns,
|
|
148
|
+
fixedAction,
|
|
149
|
+
} = useColumns({
|
|
150
|
+
...props,
|
|
151
|
+
sandBoxSafeRun,
|
|
152
|
+
funcExpExecute,
|
|
153
|
+
engineApis,
|
|
154
|
+
form,
|
|
155
|
+
appId,
|
|
156
|
+
pageId,
|
|
157
|
+
compId,
|
|
158
|
+
innerDataSource,
|
|
159
|
+
currentRowKey,
|
|
160
|
+
nowInlineEditKey,
|
|
161
|
+
nowEditingData,
|
|
162
|
+
colServiceData,
|
|
163
|
+
colServiceDataForEdit,
|
|
164
|
+
hasSortEvent,
|
|
165
|
+
page,
|
|
166
|
+
pagination,
|
|
167
|
+
rowSpanMap,
|
|
168
|
+
rowClassMap,
|
|
169
|
+
rowSpanColMap,
|
|
170
|
+
onRowDetailClick,
|
|
171
|
+
onRowDeleteClick,
|
|
172
|
+
onRowEditClick,
|
|
173
|
+
onRowSaveClick,
|
|
174
|
+
onRowCancelClick,
|
|
175
|
+
onRowAttrValsChange,
|
|
176
|
+
loading,
|
|
177
|
+
handleIsRowEditableCanUse,
|
|
178
|
+
filters,
|
|
179
|
+
filterDropdownOpen,
|
|
180
|
+
onFilterDropdownVisibleChange,
|
|
181
|
+
renderFilterDropDown,
|
|
182
|
+
rowSelection,
|
|
183
|
+
getLocale,
|
|
184
|
+
getRealIndexById,
|
|
185
|
+
childrenColumnName: realExpandable.childrenColumnName,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const {
|
|
189
|
+
scroll,
|
|
190
|
+
tableWrapRef,
|
|
191
|
+
// initTableWrapWidthRef,
|
|
192
|
+
// getTableWrapWidth,
|
|
193
|
+
} = useScroll({
|
|
194
|
+
...props,
|
|
195
|
+
initLoadColWidth,
|
|
196
|
+
finalcolumns,
|
|
197
|
+
columnWidth,
|
|
198
|
+
setColumnWidth,
|
|
199
|
+
sortDataSource,
|
|
200
|
+
pageId,
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const superSelectTranslationMapRef: any = useRef(); // 防止state更新不及时,导致翻译无法获取翻译数据
|
|
204
|
+
if (!superSelectTranslationMapRef.current) {
|
|
205
|
+
superSelectTranslationMapRef.current = {};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const innerTableStyle: any = {};
|
|
209
|
+
if (styles?.overflowY) {
|
|
210
|
+
// 通过自定义样式给表格设置y轴滚动时, 认为希望只有表格滚动,但分页栏固定在底部
|
|
211
|
+
innerTableStyle.overflowY = styles.overflowY;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const handleTableChange = (
|
|
215
|
+
newPagination: any,
|
|
216
|
+
newFilters: any,
|
|
217
|
+
newSorter: any,
|
|
218
|
+
newExtra: any,
|
|
219
|
+
) => {
|
|
220
|
+
if (typeof onChange === 'function') {
|
|
221
|
+
onChange(newPagination, newFilters, newSorter, newExtra);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (newExtra.action === 'paginate') {
|
|
225
|
+
if (hasPageChangeEvent) {
|
|
226
|
+
onPageChange(
|
|
227
|
+
newPagination?.current,
|
|
228
|
+
newPagination?.pageSize,
|
|
229
|
+
newSorter?.order === 'ascend' ? newSorter?.field : undefined,
|
|
230
|
+
newSorter?.order === 'descend' ? newSorter?.field : undefined,
|
|
231
|
+
);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
setCurrentPage(newPagination?.current);
|
|
236
|
+
setCurrentPageSize(newPagination?.pageSize);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (newExtra.action === 'sort' && hasSortEvent) {
|
|
240
|
+
// order 取值 ['ascend', 'descend']
|
|
241
|
+
const { field: colName, order } = newSorter;
|
|
242
|
+
if (order === 'ascend') {
|
|
243
|
+
onSortChange(colName, undefined, newPagination?.pageSize);
|
|
244
|
+
} else if (order === 'descend') {
|
|
245
|
+
onSortChange(undefined, colName, newPagination?.pageSize);
|
|
246
|
+
} else {
|
|
247
|
+
onSortChange(undefined, undefined, newPagination?.pageSize);
|
|
248
|
+
}
|
|
249
|
+
} else if (Object.keys(rowSpanColMap).length > 0) {
|
|
250
|
+
if (newSorter?.field) {
|
|
251
|
+
setSortOrder(newSorter);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// 表格宽度需要根据列宽度赋值
|
|
257
|
+
// 2024.04.09, 表格开启拖拽后宽度不能伸缩,屏蔽表格宽度计算
|
|
258
|
+
// const finalStyles = useMemo(() => {
|
|
259
|
+
// const tmpStyle = { ...styles };
|
|
260
|
+
// const tableWidth = getTableWrapWidth();
|
|
261
|
+
// if (tableWrapRef.current && tableWidth) {
|
|
262
|
+
// const realTableWidth = tableWidth >= initTableWrapWidthRef.current - 10 ? initTableWrapWidthRef.current - 9 : tableWidth;
|
|
263
|
+
// tmpStyle.width = `${realTableWidth}px`;
|
|
264
|
+
// }
|
|
265
|
+
// return tmpStyle;
|
|
266
|
+
// }, [columnWidth]);
|
|
267
|
+
|
|
268
|
+
const InnerHeaderCell = useMemo(() => {
|
|
269
|
+
return (info: any) => <HeaderCell
|
|
270
|
+
{...info}
|
|
271
|
+
key={info.columnIndex}
|
|
272
|
+
tableData={sortDataSource}
|
|
273
|
+
hasExpandContent={hasExpandContent}
|
|
274
|
+
childrenColumnName={realExpandable.childrenColumnName}
|
|
275
|
+
/>;
|
|
276
|
+
}, [sortDataSource, hasExpandContent, realExpandable.childrenColumnName]);
|
|
277
|
+
const eleProps = {
|
|
278
|
+
appId,
|
|
279
|
+
pageId,
|
|
280
|
+
'data-compid': (props as any)?.['data-compid'],
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const isEmptyLoading = useMemo(() => loading && sortDataSource?.length === 0, [loading, sortDataSource]);
|
|
284
|
+
|
|
285
|
+
return visible ? (
|
|
286
|
+
<>
|
|
287
|
+
<div
|
|
288
|
+
{...eleProps}
|
|
289
|
+
style={{ ...backgroundStyle, ...styles }}
|
|
290
|
+
className={classnames(
|
|
291
|
+
'ued-table-wrap',
|
|
292
|
+
className,
|
|
293
|
+
)}
|
|
294
|
+
ref={tableWrapRef}
|
|
295
|
+
>
|
|
296
|
+
<TableHead
|
|
297
|
+
{...restProps}
|
|
298
|
+
source="engine"
|
|
299
|
+
columns={customizableCols}
|
|
300
|
+
selectedCols={customSelectedCols}
|
|
301
|
+
setSelectedCols={setCustomSelectedCols}
|
|
302
|
+
setColOrder={setColCustomOrder}
|
|
303
|
+
sandBoxSafeRun={sandBoxSafeRun}
|
|
304
|
+
getEngineApis={getEngineApis}
|
|
305
|
+
/>
|
|
306
|
+
<Form form={form}>
|
|
307
|
+
<Table
|
|
308
|
+
// {...restProps} // TODO: 不要这么透传,需要什么传什么,先注释,之后缺什么再补
|
|
309
|
+
{...tableProps}
|
|
310
|
+
showHeader={showHeader}
|
|
311
|
+
locale={{
|
|
312
|
+
emptyText: <EmptyComp dataState={dataState} getLocale={getLocale} />,
|
|
313
|
+
}}
|
|
314
|
+
ref={tableRef}
|
|
315
|
+
// loading={loading}
|
|
316
|
+
bordered={isBordered}
|
|
317
|
+
className={innerClassName}
|
|
318
|
+
style={innerTableStyle}
|
|
319
|
+
components={{
|
|
320
|
+
body: {
|
|
321
|
+
cell: BodyCell,
|
|
322
|
+
},
|
|
323
|
+
header: {
|
|
324
|
+
cell: InnerHeaderCell,
|
|
325
|
+
},
|
|
326
|
+
}}
|
|
327
|
+
columns={finalcolumns.map((item, index) => {
|
|
328
|
+
// 固定列最后一项宽度根据本身计算返回
|
|
329
|
+
if (fixedAction && finalcolumns.length - 1 === index) {
|
|
330
|
+
return item;
|
|
331
|
+
}
|
|
332
|
+
item.width = columnWidth[item?.key] || item.width;
|
|
333
|
+
return item;
|
|
334
|
+
})}
|
|
335
|
+
rowKey={currentRowKey}
|
|
336
|
+
scroll={scroll}
|
|
337
|
+
onChange={handleTableChange}
|
|
338
|
+
onRow={(record) => {
|
|
339
|
+
return ({
|
|
340
|
+
onClick: (event) => {
|
|
341
|
+
const hasOnRowClick = onRowClick(event, record, getRealIndexById(record[currentRowKey]));
|
|
342
|
+
!hasOnRowClick && onRowSelectClick(record, getRealIndexById(record[currentRowKey]));
|
|
343
|
+
}, // 点击行
|
|
344
|
+
onDoubleClick: (event) => {
|
|
345
|
+
onRowDoubleClick(event, record, getRealIndexById(record[currentRowKey]));
|
|
346
|
+
},
|
|
347
|
+
onContextMenu: (event) => { },
|
|
348
|
+
onMouseEnter: (event) => { }, // 鼠标移入行
|
|
349
|
+
onMouseLeave: (event) => { },
|
|
350
|
+
});
|
|
351
|
+
}}
|
|
352
|
+
rowSelection={rowSelection}
|
|
353
|
+
// loading没有数据的时候模拟3个数据,当数据为空时依然展示骨架屏
|
|
354
|
+
dataSource={isEmptyLoading ? [{}, {}, {}] : sortDataSource}
|
|
355
|
+
expandable={realExpandable}
|
|
356
|
+
pagination={isEmptyLoading ? false : page && pagination}
|
|
357
|
+
summary={(pageData: any[]) => (
|
|
358
|
+
<Table.Summary fixed={!!props?.scroll}>
|
|
359
|
+
<TableSummaryRow
|
|
360
|
+
columns={finalcolumns}
|
|
361
|
+
dataSource={pageData as any[]}
|
|
362
|
+
summary={props.summary}
|
|
363
|
+
summaryConfig={props?.summaryTotal}
|
|
364
|
+
selectionType={rowSelection?.type}
|
|
365
|
+
/>
|
|
366
|
+
</Table.Summary>
|
|
367
|
+
)}
|
|
368
|
+
/>
|
|
369
|
+
</Form>
|
|
370
|
+
</div>
|
|
371
|
+
{showPrintContainer && (
|
|
372
|
+
<PrintContainer
|
|
373
|
+
containerProps={{
|
|
374
|
+
style: { ...backgroundStyle, ...styles },
|
|
375
|
+
className: classnames('ued-table-wrap', className),
|
|
376
|
+
...selectorKey,
|
|
377
|
+
}}
|
|
378
|
+
>
|
|
379
|
+
<TableHead
|
|
380
|
+
source="engine"
|
|
381
|
+
// @ts-ignore
|
|
382
|
+
columns={customizableCols}
|
|
383
|
+
selectedCols={customSelectedCols}
|
|
384
|
+
setSelectedCols={setCustomSelectedCols}
|
|
385
|
+
setColOrder={setColCustomOrder}
|
|
386
|
+
sandBoxSafeRun={sandBoxSafeRun}
|
|
387
|
+
{...restProps}
|
|
388
|
+
headExtends={[]}
|
|
389
|
+
engineApis={engineApis}
|
|
390
|
+
/>
|
|
391
|
+
<Form form={form}>
|
|
392
|
+
{/** @ts-ignore */}
|
|
393
|
+
<Table
|
|
394
|
+
{...restProps}
|
|
395
|
+
showHeader={showHeader}
|
|
396
|
+
bordered={isBordered}
|
|
397
|
+
className={innerClassName}
|
|
398
|
+
style={innerTableStyle}
|
|
399
|
+
components={{
|
|
400
|
+
body: {
|
|
401
|
+
cell: BodyCell,
|
|
402
|
+
},
|
|
403
|
+
header: {
|
|
404
|
+
cell: (info: any) => <HeaderCell
|
|
405
|
+
{...info}
|
|
406
|
+
tableData={printData?.dataSource?.length > 0 ? printData.dataSource : sortDataSource}
|
|
407
|
+
childrenColumnName={realExpandable.childrenColumnName}
|
|
408
|
+
hasExpandContent={hasExpandContent}
|
|
409
|
+
/>,
|
|
410
|
+
},
|
|
411
|
+
}}
|
|
412
|
+
columns={printColumns.map((item, index) => {
|
|
413
|
+
item.width = columnWidth[item.key] || item.width;
|
|
414
|
+
return item;
|
|
415
|
+
})}
|
|
416
|
+
rowKey={currentRowKey}
|
|
417
|
+
dataSource={printData?.dataSource?.length > 0 ? printData.dataSource : sortDataSource}
|
|
418
|
+
expandable={realExpandable}
|
|
419
|
+
pagination={false}
|
|
420
|
+
summary={(pageData: readonly any[]) => (
|
|
421
|
+
<Table.Summary fixed={!!props?.scroll}>
|
|
422
|
+
<TableSummaryRow
|
|
423
|
+
columns={finalcolumns}
|
|
424
|
+
dataSource={pageData as any[]}
|
|
425
|
+
summary={props.summary}
|
|
426
|
+
summaryConfig={props?.summaryTotal}
|
|
427
|
+
selectionType={rowSelection?.type}
|
|
428
|
+
/>
|
|
429
|
+
</Table.Summary>
|
|
430
|
+
)}
|
|
431
|
+
/>
|
|
432
|
+
</Form>
|
|
433
|
+
</PrintContainer>
|
|
434
|
+
)}
|
|
435
|
+
</>
|
|
436
|
+
) : null;
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
export default MyTable;
|