@lingxiteam/ebe-utils 0.2.22 → 0.2.24
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/Layout/index.tsx +2 -2
- 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 +6 -4
- 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
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
|
+
import CustomModule from '../../utils/CustomModule';
|
|
2
3
|
import { Popover, Skeleton, Table, Tooltip } from 'antd';
|
|
3
4
|
import type { ColumnProps } from 'antd/lib/table';
|
|
4
5
|
import { FilterDropdownProps } from 'antd/lib/table/interface';
|
|
5
6
|
import classnames from 'classnames';
|
|
6
7
|
import { cloneDeep, get, set } from 'lodash';
|
|
7
8
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
|
-
import { isDynamicProperty } from '../../utils/common';
|
|
9
|
-
import CustomModule from '../../utils/CustomModule';
|
|
10
9
|
import EditComponent from '../EditComponent';
|
|
11
10
|
import HeaderCellTitle from '../HeaderCell/HeaderCellTitle';
|
|
12
|
-
import OperationCell from '../OperationCell';
|
|
13
11
|
import { compareFn, handleExpandColumn, handleMergeHeader, handleMultiLevelHeader, handleRecursiveParseColumns, treeRootName } from '../utils';
|
|
14
12
|
import { getOrSaveData } from '../utils/indexedDBHelper';
|
|
13
|
+
import OperationCell from '../OperationCell';
|
|
14
|
+
import { isDynamicProperty } from '../../utils/common';
|
|
15
|
+
import { TH_CELL_KEY } from '../constant';
|
|
16
|
+
import { translateStaticData } from '../utils/translate';
|
|
15
17
|
|
|
16
18
|
const ACTION_COL_KEY = '_actions';
|
|
17
19
|
|
|
@@ -73,7 +75,6 @@ const useColumns = (props: any) => {
|
|
|
73
75
|
filterDropdownOpen,
|
|
74
76
|
onFilterDropdownVisibleChange,
|
|
75
77
|
renderFilterDropDown,
|
|
76
|
-
rowSelection,
|
|
77
78
|
tableGroupColorInfo,
|
|
78
79
|
getLocale,
|
|
79
80
|
onTableCellClick,
|
|
@@ -83,7 +84,10 @@ const useColumns = (props: any) => {
|
|
|
83
84
|
} = props;
|
|
84
85
|
const actionsMap: any = actionsMapFn(getLocale);
|
|
85
86
|
|
|
86
|
-
const {
|
|
87
|
+
const {
|
|
88
|
+
customEngineApi,
|
|
89
|
+
getUserInfo,
|
|
90
|
+
} = engineApis || {};
|
|
87
91
|
|
|
88
92
|
const { userId = '' } = getUserInfo?.() || {};
|
|
89
93
|
const fatherBOFramerId = customEngineApi?.getFatherComId?.();
|
|
@@ -93,7 +97,9 @@ const useColumns = (props: any) => {
|
|
|
93
97
|
const tableRef = useRef<any>();
|
|
94
98
|
const [colCustomOrder, setColCustomOrder] = useState<any>([]); // 自定义列顺序记录
|
|
95
99
|
const [customSelectedCols, setCustomSelectedCols] = useState<any>(); // 自定义列显隐记录
|
|
96
|
-
const [columnWidth, setColumnWidth] = useState<
|
|
100
|
+
const [columnWidth, setColumnWidth] = useState<Record<string, number>>({});
|
|
101
|
+
|
|
102
|
+
const initRef = useRef(false);
|
|
97
103
|
// 初始加载列宽
|
|
98
104
|
const [initLoadColWidth, setInitLoadColWidth] = useState(false);
|
|
99
105
|
const { hasCustom, defaultColumn } = showCustom || {};
|
|
@@ -136,139 +142,130 @@ const useColumns = (props: any) => {
|
|
|
136
142
|
return [typeof propsVisibleFn[rowAction.type] === 'function' ? getEditVisible(row) : visible, clickText];
|
|
137
143
|
};
|
|
138
144
|
|
|
139
|
-
const getRealRowActions = useCallback(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
case 'detail': {
|
|
154
|
-
detailVisible = visible;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
case 'delete': {
|
|
158
|
-
deleteVisible = visible;
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
default:
|
|
145
|
+
const getRealRowActions = useCallback((row: any, index: number | null) => {
|
|
146
|
+
const rowId = row[currentRowKey];
|
|
147
|
+
if (Array.isArray(rowActions) && rowActions.length) {
|
|
148
|
+
let editVisible = false;
|
|
149
|
+
let detailVisible = false;
|
|
150
|
+
let deleteVisible = false;
|
|
151
|
+
rowActions.forEach((rowAction) => {
|
|
152
|
+
const [visible] = getInnerRowAction(rowAction, row, index, rowId);
|
|
153
|
+
switch (rowAction.type) {
|
|
154
|
+
case 'edit': {
|
|
155
|
+
editVisible = visible;
|
|
156
|
+
break;
|
|
162
157
|
}
|
|
163
|
-
|
|
158
|
+
case 'detail': {
|
|
159
|
+
detailVisible = visible;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case 'delete': {
|
|
163
|
+
deleteVisible = visible;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
default:
|
|
167
|
+
}
|
|
168
|
+
});
|
|
164
169
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
editVisible = typeof getEditVisible === 'function' ? getEditVisible(row) : editVisible;
|
|
171
|
+
detailVisible =
|
|
172
|
+
typeof getDetailVisible === 'function' ? getDetailVisible(row) : detailVisible;
|
|
173
|
+
deleteVisible =
|
|
174
|
+
typeof getDeleteVisible === 'function' ? getDeleteVisible(row) : deleteVisible;
|
|
168
175
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
row,
|
|
186
|
-
index,
|
|
187
|
-
rowId,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
return {
|
|
191
|
-
...item,
|
|
192
|
-
disabled: disabledFunc(row, index, rowId),
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
return item;
|
|
176
|
+
// 过滤掉隐藏的按钮,得到真正的按钮数据
|
|
177
|
+
const actualRowActions = (rowActions || []).filter((btn) => {
|
|
178
|
+
if (typeof btn === 'string' ? btn === 'delete' : btn.type === 'delete') {
|
|
179
|
+
return deleteVisible && btn.checked;
|
|
180
|
+
}
|
|
181
|
+
if (typeof btn === 'string' ? btn === 'detail' : btn.type === 'detail') {
|
|
182
|
+
return detailVisible && btn.checked;
|
|
183
|
+
}
|
|
184
|
+
return editVisible && btn.checked;
|
|
185
|
+
}).map(item => {
|
|
186
|
+
if (item.disabled) {
|
|
187
|
+
const disabledFunc = (row: any, index: number | null, rowId: string | number) => sandBoxSafeRun(item.disabled, {
|
|
188
|
+
...row,
|
|
189
|
+
row,
|
|
190
|
+
index,
|
|
191
|
+
rowId,
|
|
196
192
|
});
|
|
197
193
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
194
|
+
return {
|
|
195
|
+
...item,
|
|
196
|
+
disabled: disabledFunc(row, index, rowId),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return item;
|
|
200
|
+
});
|
|
204
201
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
202
|
+
return actualRowActions;
|
|
203
|
+
}
|
|
204
|
+
return [];
|
|
205
|
+
}, [rowActions, sandBoxSafeRun, getEditVisible, getDetailVisible, getDeleteVisible]);
|
|
206
|
+
|
|
207
|
+
const getRealExtendRowActions = useCallback((row: any, index: number | null) => {
|
|
208
|
+
const rowId = row[currentRowKey];
|
|
209
|
+
if (Array.isArray(extend) && extend.length) {
|
|
210
|
+
const btnVisible: any = [];
|
|
211
|
+
let eventIndex = 0;
|
|
212
|
+
extend.forEach((item, i) => { // 扩展的按钮事件改成动态生成,而不是固定的5个
|
|
213
|
+
if (!item.type) {
|
|
214
|
+
eventIndex += 1;
|
|
215
|
+
}
|
|
216
|
+
const visibleText = `getBtn${eventIndex}Visible`;
|
|
217
|
+
let clickText = item?.value || `onClickBtn${eventIndex}`; // 兼容旧数据
|
|
218
|
+
let visible;
|
|
219
|
+
if (props[visibleText] && typeof props[visibleText] === 'function') {
|
|
220
|
+
visible = props[visibleText](row);
|
|
221
|
+
} else if (item.type) {
|
|
222
|
+
// 内置按钮合并到extend中,当存在type时,表示为内置按钮
|
|
223
|
+
[visible, clickText] = getInnerRowAction(item, row, index, rowId);
|
|
224
|
+
}
|
|
225
|
+
btnVisible.push(visible);
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
227
|
+
if (props[clickText]) {
|
|
228
|
+
item.onClick = props[clickText];
|
|
229
|
+
}
|
|
230
|
+
item.btnType = 'extend';
|
|
231
|
+
});
|
|
232
|
+
// 过滤掉隐藏的扩展按钮,得到真正的扩展按钮数据
|
|
233
|
+
const actualExtendData = extend.filter((extd, i) => {
|
|
234
|
+
if (typeof extd.rule === 'string') {
|
|
235
|
+
const stringrule = extd.rule;
|
|
236
|
+
extd.rule = (row: any, index: number, id: string | number) => sandBoxSafeRun(stringrule, {
|
|
237
|
+
...row,
|
|
238
|
+
row,
|
|
239
|
+
index,
|
|
240
|
+
rowId: id,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
244
243
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
return {
|
|
260
|
-
...item,
|
|
261
|
-
disabled: disabledFunc(row, index, rowId),
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
return item;
|
|
244
|
+
const ruleVis = typeof extd.rule === 'function' ? !extd.rule(row, index, rowId) : !extd.rule;
|
|
245
|
+
|
|
246
|
+
return btnVisible[i] === undefined
|
|
247
|
+
? ruleVis
|
|
248
|
+
: btnVisible[i];
|
|
249
|
+
}).map(item => {
|
|
250
|
+
if (item.disabled) {
|
|
251
|
+
const disabledFunc = (row: any, index: number | null, rowId: string | number) => sandBoxSafeRun(item.disabled, {
|
|
252
|
+
...row,
|
|
253
|
+
row,
|
|
254
|
+
index,
|
|
255
|
+
rowId,
|
|
265
256
|
});
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
257
|
+
|
|
258
|
+
return {
|
|
259
|
+
...item,
|
|
260
|
+
disabled: disabledFunc(row, index, rowId),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return item;
|
|
264
|
+
});
|
|
265
|
+
return actualExtendData;
|
|
266
|
+
}
|
|
267
|
+
return [];
|
|
268
|
+
}, [extend, sandBoxSafeRun]);
|
|
272
269
|
|
|
273
270
|
const calcRowActionWidth = useCallback(
|
|
274
271
|
(actions = []) => {
|
|
@@ -298,25 +295,27 @@ const useColumns = (props: any) => {
|
|
|
298
295
|
const defaultPadding = 20; // 默认左右 padding
|
|
299
296
|
const mdsmPadding = 16; // 中小尺寸左右 padding
|
|
300
297
|
const dividerWidth = 17; // 分割线占位宽度(含margin)
|
|
301
|
-
const realPadding = ['small', 'middle'].includes(size || '')
|
|
298
|
+
const realPadding = ['small', 'middle'].includes(size || '')
|
|
299
|
+
? mdsmPadding
|
|
300
|
+
: defaultPadding;
|
|
302
301
|
const realFontWidth = size === 'small' ? smFontWidth : fontWidth;
|
|
303
302
|
const realDividerWidth = dividerWidth * (titleArr.length - 1);
|
|
304
|
-
width =
|
|
303
|
+
width =
|
|
304
|
+
realDividerWidth +
|
|
305
|
+
(defaultIconWidth + space) * iconNum +
|
|
306
|
+
realFontWidth * titleArr.join('').length +
|
|
307
|
+
realPadding;
|
|
305
308
|
return width;
|
|
306
309
|
},
|
|
307
|
-
[size]
|
|
310
|
+
[size],
|
|
308
311
|
);
|
|
309
312
|
|
|
310
|
-
const handleResize =
|
|
311
|
-
(
|
|
312
|
-
|
|
313
|
-
const newColumns = [...columnWidth];
|
|
314
|
-
newColumns[index] = Number.isNaN(size.width) ? 200 : size.width;
|
|
315
|
-
setColumnWidth(newColumns);
|
|
316
|
-
};
|
|
313
|
+
const handleResize = (key: string) => (_: React.SyntheticEvent<Element>, { size }: any) => {
|
|
314
|
+
setColumnWidth(pre => ({ ...pre, [key]: Number.isNaN(size.width) ? 200 : size.width }));
|
|
315
|
+
};
|
|
317
316
|
|
|
318
317
|
// 处理cell props
|
|
319
|
-
const createCellProps = (record: any, col: {
|
|
318
|
+
const createCellProps = (record: any, col: {dataIndex: string | string[], [key:string]: any}, rowIndex:number) => {
|
|
320
319
|
const __rowSpan = rowSpanMap?.get(record) || {};
|
|
321
320
|
const __rowClass = rowClassMap?.get(record) || {};
|
|
322
321
|
const dataIndex = `${col.dataIndex}`;
|
|
@@ -343,10 +342,10 @@ const useColumns = (props: any) => {
|
|
|
343
342
|
rowId: record[currentRowKey],
|
|
344
343
|
rowIndex,
|
|
345
344
|
editable:
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
345
|
+
!!col.editoption &&
|
|
346
|
+
currentRowKey &&
|
|
347
|
+
// 整表或当前行编辑时
|
|
348
|
+
((nowInlineEditKey && record[currentRowKey] === nowInlineEditKey) || editMode === 'multiple'),
|
|
350
349
|
isExtend: col.isExtend,
|
|
351
350
|
dataIndex: col.dataIndex,
|
|
352
351
|
colorFormatInfo: [...(colorFormatInfo || []), ...(col.colorFormatInfo || [])],
|
|
@@ -365,17 +364,13 @@ const useColumns = (props: any) => {
|
|
|
365
364
|
cellProps['td-dataIndex'] = col.dataIndex;
|
|
366
365
|
}
|
|
367
366
|
|
|
368
|
-
const { translateContent } = parseTranslateContent(col, {
|
|
369
|
-
text: get(record, col.dataIndex),
|
|
370
|
-
row: record,
|
|
371
|
-
index: rowIndex,
|
|
372
|
-
});
|
|
367
|
+
const { translateContent } = parseTranslateContent(col, { text: get(record, col.dataIndex), row: record, index: rowIndex });
|
|
373
368
|
|
|
374
369
|
// 单元格提示 -> 默认提示
|
|
375
370
|
if (
|
|
376
371
|
col?.editContent?.edittype === 'title' &&
|
|
377
|
-
|
|
378
|
-
|
|
372
|
+
col?.editContent?.title &&
|
|
373
|
+
col.key !== ACTION_COL_KEY // 操作列不需要默认提示
|
|
379
374
|
) {
|
|
380
375
|
if (col?.editContent?.title?.code && col?.editContent?.title?.jsx) {
|
|
381
376
|
cellProps.title = undefined;
|
|
@@ -414,33 +409,33 @@ const useColumns = (props: any) => {
|
|
|
414
409
|
|
|
415
410
|
// 递归解析列信息
|
|
416
411
|
const recursiveColumns = (columns: any) => {
|
|
417
|
-
const resolveColumns = columns
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
412
|
+
const resolveColumns = columns.map((col: any, index: number) => {
|
|
413
|
+
if (col === Table.EXPAND_COLUMN) {
|
|
414
|
+
return col;
|
|
415
|
+
}
|
|
422
416
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
417
|
+
if (col?.children?.length) {
|
|
418
|
+
col.children = recursiveColumns(col?.children);
|
|
419
|
+
}
|
|
426
420
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
}
|
|
421
|
+
return {
|
|
422
|
+
...col,
|
|
423
|
+
onCell: (record: any, rowIndex: number) => {
|
|
424
|
+
const cellProps = createCellProps(record, col, rowIndex);
|
|
425
|
+
return cellProps;
|
|
426
|
+
},
|
|
427
|
+
onHeaderCell: (record: any) => ({
|
|
428
|
+
width: record.width,
|
|
429
|
+
isFlexColumn,
|
|
430
|
+
onResize: handleResize(col?.key),
|
|
431
|
+
style: record?.style,
|
|
432
|
+
columnIndex: record?.columnIndex,
|
|
433
|
+
[TH_CELL_KEY]: col?.key,
|
|
434
|
+
}),
|
|
435
|
+
};
|
|
436
|
+
})
|
|
442
437
|
.reduce((prev: any, curr: any) => {
|
|
443
|
-
|
|
438
|
+
// 将动态列的列配置数组数据打平
|
|
444
439
|
if (Array.isArray(curr)) {
|
|
445
440
|
return [...prev, ...curr];
|
|
446
441
|
}
|
|
@@ -458,7 +453,10 @@ const useColumns = (props: any) => {
|
|
|
458
453
|
// 过滤掉隐藏的扩展按钮,得到真正的扩展按钮数据
|
|
459
454
|
const actualExtendRowActions = getRealExtendRowActions(row, index);
|
|
460
455
|
|
|
461
|
-
const currRowActionWidth = calcRowActionWidth([
|
|
456
|
+
const currRowActionWidth = calcRowActionWidth([
|
|
457
|
+
...actualRowActions,
|
|
458
|
+
...actualExtendRowActions,
|
|
459
|
+
]);
|
|
462
460
|
width = currRowActionWidth > width ? currRowActionWidth : width;
|
|
463
461
|
});
|
|
464
462
|
|
|
@@ -489,7 +487,7 @@ const useColumns = (props: any) => {
|
|
|
489
487
|
const extendCols: any[] = [];
|
|
490
488
|
// 记录每层分组的数量
|
|
491
489
|
const group = new Map<number, number>();
|
|
492
|
-
|
|
490
|
+
|
|
493
491
|
// 解析column
|
|
494
492
|
const parseCol = (c: any) => {
|
|
495
493
|
try {
|
|
@@ -516,7 +514,7 @@ const useColumns = (props: any) => {
|
|
|
516
514
|
extendCols.push(newCol);
|
|
517
515
|
}
|
|
518
516
|
}
|
|
519
|
-
if (!isHidden && newCol?.group) {
|
|
517
|
+
if (!isHidden && Array.isArray(newCol?.group)) {
|
|
520
518
|
newCol.group.forEach((c: string, gi: number) => {
|
|
521
519
|
if (!group.has(gi)) {
|
|
522
520
|
group.set(gi, 0);
|
|
@@ -542,7 +540,7 @@ const useColumns = (props: any) => {
|
|
|
542
540
|
dataIndex,
|
|
543
541
|
title: c[col.title],
|
|
544
542
|
};
|
|
545
|
-
|
|
543
|
+
|
|
546
544
|
// 动态列标记一下,合计行需要根据key处理
|
|
547
545
|
realCol.dynamicOriginKey = realCol.key;
|
|
548
546
|
// key增强,拼接index,防止重复
|
|
@@ -572,20 +570,22 @@ const useColumns = (props: any) => {
|
|
|
572
570
|
});
|
|
573
571
|
}
|
|
574
572
|
// 只展示选中列
|
|
575
|
-
let customCols = customizableCols.filter(
|
|
576
|
-
|
|
577
|
-
if (
|
|
578
|
-
if (
|
|
579
|
-
|
|
580
|
-
|
|
573
|
+
let customCols = customizableCols.filter(
|
|
574
|
+
(c) => {
|
|
575
|
+
if (hasCustom) {
|
|
576
|
+
if (customSelectedCols === undefined) {
|
|
577
|
+
if (defaultColumn) {
|
|
578
|
+
// 没有缓存列,使用默认列
|
|
579
|
+
return defaultColumnSet.has(c.key);
|
|
580
|
+
}
|
|
581
|
+
} else {
|
|
582
|
+
// 有缓存列,使用缓存列
|
|
583
|
+
return customSelectedCols?.includes(`${c.dataIndex}`);
|
|
581
584
|
}
|
|
582
|
-
} else {
|
|
583
|
-
// 有缓存列,使用缓存列
|
|
584
|
-
return customSelectedCols?.includes(`${c.dataIndex}`);
|
|
585
585
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
586
|
+
return true;
|
|
587
|
+
},
|
|
588
|
+
);
|
|
589
589
|
// 固定列与自定义列拼接在一起组成最终展示列
|
|
590
590
|
customCols = fixedLeft.concat(customCols).concat(fixedRight);
|
|
591
591
|
return [customCols, customizableCols, group];
|
|
@@ -659,18 +659,10 @@ const useColumns = (props: any) => {
|
|
|
659
659
|
// 静态数据翻译
|
|
660
660
|
if (Array.isArray(staticDataSource)) {
|
|
661
661
|
// 支持数组或逗号分支字符翻译
|
|
662
|
-
translateContent = (
|
|
663
|
-
.map(n => {
|
|
664
|
-
// 弱等保证 Number 与 String 可比较
|
|
665
|
-
const obj = staticDataSource.find(o => o.value == n); // eslint-disable-line
|
|
666
|
-
return obj ? obj.label : n;
|
|
667
|
-
})
|
|
668
|
-
.join(',');
|
|
662
|
+
translateContent = translateStaticData(text, staticDataSource);
|
|
669
663
|
} else if (editoption && editoption?.__staticService__ && editoption.edittype === 'SuperSelect') {
|
|
670
664
|
// 高级选择框选用后端翻译好的字段值
|
|
671
|
-
const realDataIndex = Array.isArray(dataIndex)
|
|
672
|
-
? [...dataIndex.slice(0, dataIndex.length - 1), `${dataIndex[dataIndex.length - 1]}_introduce`]
|
|
673
|
-
: `${dataIndex}_introduce`;
|
|
665
|
+
const realDataIndex = Array.isArray(dataIndex) ? [...(dataIndex.slice(0, dataIndex.length - 1)), `${dataIndex[dataIndex.length - 1]}_introduce`] : `${dataIndex}_introduce`;
|
|
674
666
|
const _introduce = get(row, realDataIndex);
|
|
675
667
|
translateContent = _introduce ? (Array.isArray(_introduce) ? _introduce : [_introduce]).join(',') : text;
|
|
676
668
|
}
|
|
@@ -690,9 +682,7 @@ const useColumns = (props: any) => {
|
|
|
690
682
|
}
|
|
691
683
|
}
|
|
692
684
|
if (editoption?.edittype === 'ModalSelect') {
|
|
693
|
-
const realDataIndex = Array.isArray(dataIndex)
|
|
694
|
-
? [...dataIndex.slice(0, dataIndex.length - 1), `${dataIndex[dataIndex.length - 1]}_introduce`]
|
|
695
|
-
: `${dataIndex}_introduce`;
|
|
685
|
+
const realDataIndex = Array.isArray(dataIndex) ? [...(dataIndex.slice(0, dataIndex.length - 1)), `${dataIndex[dataIndex.length - 1]}_introduce`] : `${dataIndex}_introduce`;
|
|
696
686
|
const _introduce = get(row, realDataIndex);
|
|
697
687
|
translateContent = _introduce ? (Array.isArray(_introduce) ? _introduce : [_introduce]).join(',') : text;
|
|
698
688
|
}
|
|
@@ -713,31 +703,33 @@ const useColumns = (props: any) => {
|
|
|
713
703
|
// 处理普通列和动态列属性、渲染逻辑
|
|
714
704
|
const generateTableCol = (colInfo: any) => {
|
|
715
705
|
const c = colInfo;
|
|
716
|
-
const {
|
|
706
|
+
const {
|
|
707
|
+
editoption,
|
|
708
|
+
dataIndex,
|
|
709
|
+
editContent,
|
|
710
|
+
} = c;
|
|
717
711
|
|
|
718
712
|
c.render = (text: any, row: any, index: any) => {
|
|
719
713
|
const rowId = row[currentRowKey];
|
|
720
|
-
const { translateContent, rowEditoption } = parseTranslateContent(c, {
|
|
721
|
-
text,
|
|
722
|
-
row,
|
|
723
|
-
index,
|
|
724
|
-
});
|
|
714
|
+
const { translateContent, rowEditoption } = parseTranslateContent(c, { text, row, index });
|
|
725
715
|
|
|
726
716
|
// 编辑内容
|
|
727
717
|
if (editoption && editoption.edittype) {
|
|
728
|
-
|
|
718
|
+
// 行编辑规则
|
|
729
719
|
const isRowEditableCanUse = !!handleIsRowEditableCanUse && handleIsRowEditableCanUse(row, index);
|
|
730
720
|
|
|
731
721
|
// 列可编辑规则
|
|
732
722
|
let isColEditable = true;
|
|
733
723
|
if (typeof editoption.editable === 'string') {
|
|
734
724
|
const editoptionEditableRule = editoption.editable;
|
|
735
|
-
editoption.editable = (row: any, rowId: string | number, index: number) =>
|
|
736
|
-
|
|
725
|
+
editoption.editable = (row: any, rowId: string | number, index: number) => sandBoxSafeRun(
|
|
726
|
+
editoptionEditableRule,
|
|
727
|
+
{
|
|
737
728
|
row,
|
|
738
729
|
rowId,
|
|
739
730
|
index,
|
|
740
|
-
}
|
|
731
|
+
}
|
|
732
|
+
);
|
|
741
733
|
}
|
|
742
734
|
|
|
743
735
|
if (typeof editoption.editable === 'function') {
|
|
@@ -746,25 +738,33 @@ const useColumns = (props: any) => {
|
|
|
746
738
|
|
|
747
739
|
// 弹窗选择控件,组件状态入参处理
|
|
748
740
|
const responseObj = editoption?.modalInfo?.responseObj;
|
|
749
|
-
if (
|
|
741
|
+
if (
|
|
742
|
+
Array.isArray(responseObj) &&
|
|
743
|
+
editoption?.edittype === 'ModalSelect' &&
|
|
744
|
+
responseObj?.length
|
|
745
|
+
) {
|
|
750
746
|
// 保留原有配置 不然会导致首次解析结果会被再次解析
|
|
751
|
-
editoption.modalInfo.responseObjRun = (row: any, rowId: string | number, index: number) =>
|
|
747
|
+
editoption.modalInfo.responseObjRun = (row: any, rowId: string | number, index: number) => (
|
|
752
748
|
responseObj?.map((_d: any) => {
|
|
753
749
|
const d = { ..._d };
|
|
754
750
|
if (typeof d?.value === 'string') {
|
|
755
751
|
const rule = d.value;
|
|
756
|
-
d.value = sandBoxSafeRun(
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
752
|
+
d.value = sandBoxSafeRun(
|
|
753
|
+
rule,
|
|
754
|
+
{
|
|
755
|
+
row,
|
|
756
|
+
rowId,
|
|
757
|
+
index,
|
|
758
|
+
}
|
|
759
|
+
);
|
|
761
760
|
// 如果为空说明sandBoxSafeRun 执行异常应该直接给rule,不然直接输入字符串不行
|
|
762
761
|
if (d.value === undefined && rule) {
|
|
763
762
|
d.value = rule;
|
|
764
763
|
}
|
|
765
764
|
}
|
|
766
765
|
return d;
|
|
767
|
-
})
|
|
766
|
+
})
|
|
767
|
+
);
|
|
768
768
|
}
|
|
769
769
|
|
|
770
770
|
let modalSelectParams = [];
|
|
@@ -824,10 +824,10 @@ const useColumns = (props: any) => {
|
|
|
824
824
|
let controllLineStyle = {};
|
|
825
825
|
const isLineNumSet = c.lineNum && typeof c.lineNum === 'number' && c.lineNum > 0;
|
|
826
826
|
if (isLineNumSet) {
|
|
827
|
-
|
|
827
|
+
// const lineHeight = size === 'small' ? 16 : 20;
|
|
828
828
|
controllLineStyle = {
|
|
829
|
-
|
|
830
|
-
|
|
829
|
+
// lineHeight: `${lineHeight}px`,
|
|
830
|
+
// maxHeight: `${lineHeight * c.lineNum}px`,
|
|
831
831
|
WebkitLineClamp: c.lineNum,
|
|
832
832
|
};
|
|
833
833
|
}
|
|
@@ -836,8 +836,8 @@ const useColumns = (props: any) => {
|
|
|
836
836
|
|
|
837
837
|
if (
|
|
838
838
|
c?.editContent?.edittype === 'title' &&
|
|
839
|
-
|
|
840
|
-
|
|
839
|
+
c?.editContent?.title &&
|
|
840
|
+
c.key !== ACTION_COL_KEY // 操作列不需要默认提示
|
|
841
841
|
) {
|
|
842
842
|
if (c?.editContent?.title?.code && c?.editContent?.title?.jsx) {
|
|
843
843
|
shouldRenderEdittypeTitle = true;
|
|
@@ -861,7 +861,7 @@ const useColumns = (props: any) => {
|
|
|
861
861
|
index,
|
|
862
862
|
}}
|
|
863
863
|
/>
|
|
864
|
-
|
|
864
|
+
}
|
|
865
865
|
>
|
|
866
866
|
<span>{translateContent}</span>
|
|
867
867
|
</Tooltip>
|
|
@@ -897,7 +897,7 @@ const useColumns = (props: any) => {
|
|
|
897
897
|
} else if (c.customRendering && funcExpExecute) {
|
|
898
898
|
content = (
|
|
899
899
|
<span
|
|
900
|
-
|
|
900
|
+
// eslint-disable-next-line react/no-danger
|
|
901
901
|
dangerouslySetInnerHTML={{
|
|
902
902
|
__html: funcExpExecute(c.customRendering, [
|
|
903
903
|
{
|
|
@@ -929,15 +929,20 @@ const useColumns = (props: any) => {
|
|
|
929
929
|
const pageRule = page.rule;
|
|
930
930
|
if (pageRule) {
|
|
931
931
|
if (typeof pageRule === 'string') {
|
|
932
|
-
page.rule = (row: any, rowId: string, index: number) =>
|
|
933
|
-
|
|
932
|
+
page.rule = (row: any, rowId: string, index: number) => sandBoxSafeRun(
|
|
933
|
+
pageRule,
|
|
934
|
+
{
|
|
934
935
|
row,
|
|
935
936
|
rowId,
|
|
936
937
|
index,
|
|
937
|
-
}
|
|
938
|
+
}
|
|
939
|
+
);
|
|
938
940
|
}
|
|
939
941
|
|
|
940
|
-
if (
|
|
942
|
+
if (
|
|
943
|
+
typeof page?.rule === 'function' &&
|
|
944
|
+
page.rule(row, rowId, index)
|
|
945
|
+
) {
|
|
941
946
|
return content;
|
|
942
947
|
}
|
|
943
948
|
}
|
|
@@ -956,12 +961,14 @@ const useColumns = (props: any) => {
|
|
|
956
961
|
const stateParamRule = c?.paramFunc ?? c?.stateParam;
|
|
957
962
|
if (stateParamRule) {
|
|
958
963
|
if (typeof stateParamRule === 'string') {
|
|
959
|
-
c.paramFunc = (row: any, rowId: string, index: number) =>
|
|
960
|
-
|
|
964
|
+
c.paramFunc = (row: any, rowId: string, index: number) => sandBoxSafeRun(
|
|
965
|
+
stateParamRule,
|
|
966
|
+
{
|
|
961
967
|
row,
|
|
962
968
|
rowId,
|
|
963
969
|
index,
|
|
964
|
-
}
|
|
970
|
+
}
|
|
971
|
+
);
|
|
965
972
|
}
|
|
966
973
|
|
|
967
974
|
if (typeof c.paramFunc === 'function') {
|
|
@@ -988,23 +995,26 @@ const useColumns = (props: any) => {
|
|
|
988
995
|
},
|
|
989
996
|
uid: compId,
|
|
990
997
|
});
|
|
991
|
-
} else if (options.content) {
|
|
992
|
-
// 自定义
|
|
998
|
+
} else if (options.content) { // 自定义
|
|
993
999
|
const { maxWidth, content: popContent, rule: popRule, ...resOptions } = options;
|
|
994
1000
|
|
|
995
1001
|
// 隐藏规则
|
|
996
1002
|
try {
|
|
997
1003
|
if (popRule) {
|
|
998
1004
|
if (typeof popRule === 'string') {
|
|
999
|
-
options.rule = (row: any, rowId: string, index: number) =>
|
|
1000
|
-
|
|
1005
|
+
options.rule = (row: any, rowId: string, index: number) => sandBoxSafeRun(
|
|
1006
|
+
popRule,
|
|
1007
|
+
{
|
|
1001
1008
|
row,
|
|
1002
1009
|
rowId,
|
|
1003
1010
|
index,
|
|
1004
|
-
}
|
|
1011
|
+
}
|
|
1012
|
+
);
|
|
1005
1013
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1014
|
+
if (
|
|
1015
|
+
typeof options?.rule === 'function' &&
|
|
1016
|
+
options.rule(row, rowId, index)
|
|
1017
|
+
) {
|
|
1008
1018
|
return content;
|
|
1009
1019
|
}
|
|
1010
1020
|
}
|
|
@@ -1017,12 +1027,14 @@ const useColumns = (props: any) => {
|
|
|
1017
1027
|
if (popContent) {
|
|
1018
1028
|
let popoverContent = popContent;
|
|
1019
1029
|
if (typeof popContent === 'string') {
|
|
1020
|
-
popoverContent = (row: any, rowId: string, index: number) =>
|
|
1021
|
-
|
|
1030
|
+
popoverContent = (row: any, rowId: string, index: number) => sandBoxSafeRun(
|
|
1031
|
+
popContent,
|
|
1032
|
+
{
|
|
1022
1033
|
row,
|
|
1023
1034
|
rowId,
|
|
1024
1035
|
index,
|
|
1025
|
-
}
|
|
1036
|
+
}
|
|
1037
|
+
);
|
|
1026
1038
|
}
|
|
1027
1039
|
|
|
1028
1040
|
if (typeof popoverContent === 'function') {
|
|
@@ -1039,10 +1051,7 @@ const useColumns = (props: any) => {
|
|
|
1039
1051
|
|
|
1040
1052
|
content = (
|
|
1041
1053
|
<Popover
|
|
1042
|
-
overlayStyle={{
|
|
1043
|
-
maxWidth: maxWidth || 'none',
|
|
1044
|
-
wordBreak: 'break-word',
|
|
1045
|
-
}}
|
|
1054
|
+
overlayStyle={{ maxWidth: maxWidth || 'none', wordBreak: 'break-word' }}
|
|
1046
1055
|
content={newPopContent}
|
|
1047
1056
|
{...resOptions}
|
|
1048
1057
|
arrowPointAtCenter
|
|
@@ -1057,7 +1066,7 @@ const useColumns = (props: any) => {
|
|
|
1057
1066
|
};
|
|
1058
1067
|
// 是否开启排序(判断标准:1、配置态配置 sorter: true 2、存量数据存在 defaultSortOrder)
|
|
1059
1068
|
if (c.sorter || c.defaultSortOrder) {
|
|
1060
|
-
|
|
1069
|
+
// 判断是根据前端默认排序函数排序,还是受控排序
|
|
1061
1070
|
if (hasSortEvent || Object.keys(rowSpanColMap).length > 0) {
|
|
1062
1071
|
c.sorter = true;
|
|
1063
1072
|
} else {
|
|
@@ -1078,7 +1087,9 @@ const useColumns = (props: any) => {
|
|
|
1078
1087
|
};
|
|
1079
1088
|
|
|
1080
1089
|
newColumns.forEach((c, i) => {
|
|
1081
|
-
const {
|
|
1090
|
+
const {
|
|
1091
|
+
dataIndex,
|
|
1092
|
+
} = c;
|
|
1082
1093
|
|
|
1083
1094
|
newColumns[i].columnIndex = i;
|
|
1084
1095
|
|
|
@@ -1094,10 +1105,16 @@ const useColumns = (props: any) => {
|
|
|
1094
1105
|
}
|
|
1095
1106
|
|
|
1096
1107
|
newColumns[i].title = () => (
|
|
1097
|
-
<HeaderCellTitle
|
|
1108
|
+
<HeaderCellTitle
|
|
1109
|
+
size={size}
|
|
1110
|
+
column={{ ...c, title: c.originTitle }}
|
|
1111
|
+
mode="engine"
|
|
1112
|
+
funcExpExecute={funcExpExecute}
|
|
1113
|
+
engineApis={engineApis}
|
|
1114
|
+
/>
|
|
1098
1115
|
);
|
|
1099
1116
|
|
|
1100
|
-
if (c?.group) {
|
|
1117
|
+
if (Array.isArray(c?.group)) {
|
|
1101
1118
|
// 过滤掉整层为空的分组
|
|
1102
1119
|
c.group = c.group.filter((_: string, gi: number) => groupMark.get(gi) !== 0);
|
|
1103
1120
|
}
|
|
@@ -1116,7 +1133,10 @@ const useColumns = (props: any) => {
|
|
|
1116
1133
|
// 处理表头分组合并
|
|
1117
1134
|
finalCols = handleMergeHeader(finalCols as any[]) || finalCols;
|
|
1118
1135
|
|
|
1119
|
-
if (
|
|
1136
|
+
if (
|
|
1137
|
+
!hiddenAction &&
|
|
1138
|
+
((rowActions && rowActions.length) || (extend && extend.length))
|
|
1139
|
+
) {
|
|
1120
1140
|
actionRowFlag.current = true;
|
|
1121
1141
|
const isSmallPopover = innerDataSource?.length < 4;
|
|
1122
1142
|
const actionColumn: any = {
|
|
@@ -1172,8 +1192,8 @@ const useColumns = (props: any) => {
|
|
|
1172
1192
|
|
|
1173
1193
|
// 处理表头背景色
|
|
1174
1194
|
if (tableGroupColorInfo) {
|
|
1175
|
-
const { colIdMap }: any =
|
|
1176
|
-
|
|
1195
|
+
const { colIdMap }: any = tableGroupColorInfo?.colorType === 'single' ? {}
|
|
1196
|
+
: handleRecursiveParseColumns(tableGroupColorInfo?.customColorColumns);
|
|
1177
1197
|
handleRecursiveParseColumns(finalCols, 1, {
|
|
1178
1198
|
colorType: tableGroupColorInfo?.colorType,
|
|
1179
1199
|
customColorSetting: colIdMap,
|
|
@@ -1245,27 +1265,37 @@ const useColumns = (props: any) => {
|
|
|
1245
1265
|
}, [finalcolumns]);
|
|
1246
1266
|
|
|
1247
1267
|
useEffect(() => {
|
|
1248
|
-
if (
|
|
1268
|
+
if (!initRef.current) {
|
|
1269
|
+
if (tableRef.current && isFlexColumn) {
|
|
1249
1270
|
// 如果开启了内容滚动, 但是没有配置内容宽度,则取表格项配置里的宽度,否则通过计算表格最终th渲染的宽度
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
const rowWidth = thList[i].offsetWidth;
|
|
1259
|
-
columnWidth[i] = rowWidth;
|
|
1260
|
-
}
|
|
1261
|
-
// TODO: 这里是啥意思??
|
|
1262
|
-
if (rowSelection) {
|
|
1263
|
-
columnWidth.shift();
|
|
1264
|
-
}
|
|
1265
|
-
setColumnWidth([...columnWidth]);
|
|
1271
|
+
if (scroll && !scroll.x) {
|
|
1272
|
+
setColumnWidth(pre => {
|
|
1273
|
+
const obj = { ...pre };
|
|
1274
|
+
finalcolumns.forEach(item => {
|
|
1275
|
+
obj[item.key] = item.width || 100;
|
|
1276
|
+
});
|
|
1277
|
+
return pre;
|
|
1278
|
+
});
|
|
1266
1279
|
setInitLoadColWidth(true);
|
|
1267
|
-
}
|
|
1280
|
+
} else {
|
|
1281
|
+
// 当前执行时,antd表格列虽展示,但列宽按指定宽度渲染,需等下一次render,目前解决办法先延迟执行
|
|
1282
|
+
setTimeout(() => {
|
|
1283
|
+
setColumnWidth(pre => {
|
|
1284
|
+
const p = { ...pre };
|
|
1285
|
+
const thList = tableRef?.current?.querySelectorAll('.pcfactory-table-thead th.react-resizable') || [];
|
|
1286
|
+
for (let i = 0; i < thList.length; i += 1) {
|
|
1287
|
+
const rowWidth = thList[i].offsetWidth;
|
|
1288
|
+
// 根据唯一key标识拖拽宽度
|
|
1289
|
+
const cellKey = thList[i].getAttribute(TH_CELL_KEY);
|
|
1290
|
+
p[cellKey] = rowWidth;
|
|
1291
|
+
}
|
|
1292
|
+
return p;
|
|
1293
|
+
});
|
|
1294
|
+
setInitLoadColWidth(true);
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1268
1297
|
}
|
|
1298
|
+
initRef.current = true;
|
|
1269
1299
|
}
|
|
1270
1300
|
}, [tableRef.current, isFlexColumn]);
|
|
1271
1301
|
|