@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,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { TreeSelect } from 'antd';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import IconFont from '../IconFont';
|
|
6
|
+
import { flattenTreeData, renderCommonList } from '../utils/renderReadOnly';
|
|
7
|
+
import { LingxiForwardRef } from '@lingxiteam/types';
|
|
6
8
|
import { FormFields, getFieldsProps, useCommonImperativeHandle, useListenProps } from '../utils';
|
|
7
9
|
import EmptyComp from '../utils/Empty';
|
|
8
10
|
import { useLocale } from '../utils/hooks/useLocale';
|
|
9
|
-
import { flattenTreeData, renderCommonList } from '../utils/renderReadOnly';
|
|
10
11
|
|
|
11
12
|
const { TreeNode } = TreeSelect;
|
|
12
13
|
|
|
@@ -177,7 +178,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
177
178
|
// isGetAll 是否获取所有节点keys,否则只获取父级的,展开时使用
|
|
178
179
|
const recursive = (arr: any[], keys: any[], map?: any, isGetAll = false, parentNode?: any) => {
|
|
179
180
|
if (Array.isArray(arr)) {
|
|
180
|
-
arr.forEach(a => {
|
|
181
|
+
arr.forEach((a) => {
|
|
181
182
|
if (map) {
|
|
182
183
|
map[a.key] = { ...a, data: { ...(a.data || {}), parentNode } };
|
|
183
184
|
}
|
|
@@ -229,8 +230,19 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
229
230
|
}, [data, asyncService, treeDefaultExpandAll]);
|
|
230
231
|
|
|
231
232
|
const getParams = (service: any, key: any) => {
|
|
232
|
-
const {
|
|
233
|
-
|
|
233
|
+
const {
|
|
234
|
+
providerId,
|
|
235
|
+
appId,
|
|
236
|
+
serviceCode,
|
|
237
|
+
_source,
|
|
238
|
+
loadKey,
|
|
239
|
+
_serviceId,
|
|
240
|
+
serviceVersion,
|
|
241
|
+
sceneCode,
|
|
242
|
+
linkCode,
|
|
243
|
+
busiObjectId,
|
|
244
|
+
versionCode,
|
|
245
|
+
} = service || {};
|
|
234
246
|
let params: any = { [loadKey]: key };
|
|
235
247
|
// 特殊服务参数处理
|
|
236
248
|
if (_source === SERVICE_SOURCE.ATOM) {
|
|
@@ -297,20 +309,20 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
297
309
|
const { key, title, children, selectable = 'selectable' } = service || {};
|
|
298
310
|
const getTreeData = (arr: any[]) => {
|
|
299
311
|
if (Array.isArray(arr)) {
|
|
300
|
-
return arr.map(c => {
|
|
312
|
+
return arr.map((c) => {
|
|
301
313
|
// _isReload 标识节点数据是通过加载子节点动作设置的,此时取该动作配置好的key/title/selectable
|
|
302
314
|
const originData = c._isReload ? c.data : c;
|
|
303
315
|
const isSelectable = transformBoolean(originData[selectable] ?? originData.selectable);
|
|
304
316
|
// 如果加载子节点配置了映射,优先取加载子节点的,否则取当时加载数据的映射,若都没有则取数据上的默认字段
|
|
305
|
-
const nodeSelectable = c._isReload ? c.selectable ?? isSelectable : isSelectable;
|
|
317
|
+
const nodeSelectable = c._isReload ? (c.selectable ?? isSelectable) : isSelectable;
|
|
306
318
|
const node: any = {
|
|
307
|
-
key: c._isReload ? c.key ?? originData[key] : originData[key] ?? originData.key,
|
|
308
|
-
title: c._isReload ? c.title ?? originData[title] : originData[title] ?? originData.title,
|
|
309
|
-
selectable: c._isReload ? c.selectable ?? isSelectable : isSelectable,
|
|
319
|
+
key: c._isReload ? (c.key ?? originData[key]) : (originData[key] ?? originData.key),
|
|
320
|
+
title: c._isReload ? (c.title ?? originData[title]) : (originData[title] ?? originData.title),
|
|
321
|
+
selectable: c._isReload ? (c.selectable ?? isSelectable) : isSelectable,
|
|
310
322
|
disableCheckbox: c.disabled ?? c.disableCheckbox ?? (nodeSelectable !== undefined ? !nodeSelectable : undefined),
|
|
311
323
|
disabled: c.disabled ?? c.disableCheckbox ?? (nodeSelectable !== undefined ? !nodeSelectable : undefined),
|
|
312
324
|
isLeaf: c.isLeaf ?? originData.isLeaf ?? false,
|
|
313
|
-
data: c.data || c,
|
|
325
|
+
data: (c.data || c),
|
|
314
326
|
};
|
|
315
327
|
// 优先取配置的children字段,若配置错误则子节点为空,若无配置默认访问数据自身children
|
|
316
328
|
const childrenKey = children || 'children';
|
|
@@ -328,12 +340,10 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
328
340
|
// 加载数据配置子节点映射,或者数据上也有children数据,则视为同步加载
|
|
329
341
|
// 目前不处理加载子节点数据动作返回来的数据里面的children
|
|
330
342
|
// -null是叶子 -[]是叶子 -属性不存在是叶子 -[有值]是非叶子
|
|
331
|
-
if (
|
|
332
|
-
c[childrenKey] === null ||
|
|
343
|
+
if (c[childrenKey] === null ||
|
|
333
344
|
c[childrenKey] === undefined ||
|
|
334
345
|
!(childrenKey in c) ||
|
|
335
|
-
(Array.isArray(c[childrenKey]) && c[childrenKey]?.length === 0)
|
|
336
|
-
) {
|
|
346
|
+
(Array.isArray(c[childrenKey]) && c[childrenKey]?.length === 0)) {
|
|
337
347
|
node.isLeaf = true;
|
|
338
348
|
}
|
|
339
349
|
}
|
|
@@ -349,7 +359,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
349
359
|
|
|
350
360
|
const loadNodeData = (node: any) => {
|
|
351
361
|
const { children, eventKey } = node.props;
|
|
352
|
-
return new Promise<void>(resolve => {
|
|
362
|
+
return new Promise<void>((resolve) => {
|
|
353
363
|
if (children && children.length) {
|
|
354
364
|
resolve();
|
|
355
365
|
return;
|
|
@@ -373,10 +383,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
373
383
|
(res: string | any[]) => {
|
|
374
384
|
if (Array.isArray(res) && res.length) {
|
|
375
385
|
const source = loadTreeData(res, asyncService);
|
|
376
|
-
node.props.dataRef.children = source.map(c => ({
|
|
377
|
-
...c,
|
|
378
|
-
isLeaf: false,
|
|
379
|
-
}));
|
|
386
|
+
node.props.dataRef.children = source.map((c) => ({ ...c, isLeaf: false }));
|
|
380
387
|
node.props.dataRef.isLeaf = false;
|
|
381
388
|
} else {
|
|
382
389
|
node.props.dataRef.children = undefined;
|
|
@@ -390,7 +397,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
390
397
|
node.props.dataRef.isLeaf = true;
|
|
391
398
|
setData([...data]);
|
|
392
399
|
resolve(err);
|
|
393
|
-
}
|
|
400
|
+
},
|
|
394
401
|
);
|
|
395
402
|
});
|
|
396
403
|
};
|
|
@@ -409,7 +416,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
409
416
|
|
|
410
417
|
const createNodes = (nodes: any[], parentNode?: any) =>
|
|
411
418
|
Array.isArray(nodes) && nodes.length > 0
|
|
412
|
-
? nodes.map(c => (
|
|
419
|
+
? nodes.map((c) => (
|
|
413
420
|
<TreeNode
|
|
414
421
|
key={c.key}
|
|
415
422
|
title={c.title}
|
|
@@ -451,9 +458,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
451
458
|
} else if (filter === 'remote') {
|
|
452
459
|
// 根据配置的‘搜索’事件过滤
|
|
453
460
|
setFilterObject({
|
|
454
|
-
filterTreeNode: () => {
|
|
455
|
-
return true;
|
|
456
|
-
},
|
|
461
|
+
filterTreeNode: () => { return true; },
|
|
457
462
|
onSearch: _.debounce((input: any) => {
|
|
458
463
|
try {
|
|
459
464
|
if (typeof onSearch === 'function') {
|
|
@@ -467,9 +472,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
467
472
|
} else if (filter === 'none') {
|
|
468
473
|
// 不过滤
|
|
469
474
|
setFilterObject({
|
|
470
|
-
filterTreeNode: () => {
|
|
471
|
-
return true;
|
|
472
|
-
},
|
|
475
|
+
filterTreeNode: () => { return true; },
|
|
473
476
|
});
|
|
474
477
|
}
|
|
475
478
|
}, [filter, treeProps.showSearch]);
|
|
@@ -482,22 +485,23 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
482
485
|
required={required}
|
|
483
486
|
wrapperClassName={TREESELECT_WRAPPER_CLASSNAME}
|
|
484
487
|
rules={finalRules}
|
|
485
|
-
render={val =>
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
})
|
|
491
|
-
}
|
|
488
|
+
render={(val) => renderCommonList(val, flattenTreeData(data), {
|
|
489
|
+
labelKey: 'title',
|
|
490
|
+
valueKey: 'value',
|
|
491
|
+
childrenKey: 'children',
|
|
492
|
+
})}
|
|
492
493
|
ref={formFieldsRef}
|
|
493
494
|
value={value}
|
|
494
495
|
// @ts-ignore
|
|
495
|
-
afterComponent={
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
496
|
+
afterComponent={treeProps.showSearch && (treeProps.multiple || treeProps.treeCheckable) ? (
|
|
497
|
+
<IconFont
|
|
498
|
+
width={14}
|
|
499
|
+
height={14}
|
|
500
|
+
className="ued-treeSelect-icon"
|
|
501
|
+
iconClass="lcdp-icon-flow-single-record"
|
|
502
|
+
/>
|
|
503
|
+
) : null}
|
|
504
|
+
handleFormValue={(val) => {
|
|
501
505
|
if (val !== undefined) {
|
|
502
506
|
let newValue = val;
|
|
503
507
|
if (restProps.treeCheckable) {
|
|
@@ -532,7 +536,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
532
536
|
resetSelectAll();
|
|
533
537
|
}}
|
|
534
538
|
notFoundContent={<EmptyComp getLocale={getLocale} dataState={dataState} clsName="pcfactory-empty-small" />}
|
|
535
|
-
onTreeExpand={keys => {
|
|
539
|
+
onTreeExpand={(keys) => {
|
|
536
540
|
setExpandedKeys(keys);
|
|
537
541
|
// 展开的时候触发
|
|
538
542
|
if (keys?.length - expandedKeys?.length === 1) {
|
|
@@ -543,7 +547,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
543
547
|
nodeKey,
|
|
544
548
|
(node.children || []).map((c: any) => c.key),
|
|
545
549
|
node?.data?.parentNode?.key,
|
|
546
|
-
node?.data?.parentNode
|
|
550
|
+
node?.data?.parentNode,
|
|
547
551
|
);
|
|
548
552
|
} else {
|
|
549
553
|
node.isLeaf = !(node.children?.length > 0);
|
|
@@ -0,0 +1,264 @@
|
|
|
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, { useMemo, useRef } from 'react';
|
|
9
|
+
import BodyCell from '../Table/BodyCell';
|
|
10
|
+
import HeaderCell from '../Table/HeaderCell';
|
|
11
|
+
import TableHead from '../Table/TableHead';
|
|
12
|
+
import { useFuncExpExecute } from '../utils/hooks/useFuncExpExecute';
|
|
13
|
+
import {
|
|
14
|
+
useColumns,
|
|
15
|
+
useSelection,
|
|
16
|
+
useDataSource,
|
|
17
|
+
useRowEdit,
|
|
18
|
+
useCommon,
|
|
19
|
+
useScroll,
|
|
20
|
+
} from '../Table/hooks';
|
|
21
|
+
import { useCMDAction, useExpandable } from './hooks';
|
|
22
|
+
import type { MyTableProps } from '../Table/types/prop';
|
|
23
|
+
import EmptyComp from '../utils/Empty';
|
|
24
|
+
import { useLocale } from '../utils/hooks/useLocale';
|
|
25
|
+
import { useCreation } from '../utils/ahooks';
|
|
26
|
+
import useBackgroundStyle from '../View/useBackgroundStyle';
|
|
27
|
+
|
|
28
|
+
type WrapperTableProps = ReturnType<typeof useCommon>
|
|
29
|
+
& ReturnType<typeof useCMDAction>
|
|
30
|
+
& ReturnType<typeof useSelection>
|
|
31
|
+
& ReturnType<typeof useExpandable>
|
|
32
|
+
& ReturnType<typeof useRowEdit>
|
|
33
|
+
& ReturnType<typeof useDataSource>;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const TreeTable = React.forwardRef<any, Omit<MyTableProps, keyof WrapperTableProps> & WrapperTableProps>((props, ref) => {
|
|
37
|
+
const {
|
|
38
|
+
dataSource: boundDataSource,
|
|
39
|
+
visible = true,
|
|
40
|
+
style: styles,
|
|
41
|
+
className,
|
|
42
|
+
onChange,
|
|
43
|
+
$$componentItem,
|
|
44
|
+
getEngineApis,
|
|
45
|
+
backgroundType,
|
|
46
|
+
innerDataSource,
|
|
47
|
+
currentRowKey,
|
|
48
|
+
outerDataSource,
|
|
49
|
+
setInnerDataSource,
|
|
50
|
+
selectedRows,
|
|
51
|
+
onRowSelected,
|
|
52
|
+
colServiceData,
|
|
53
|
+
loading,
|
|
54
|
+
rowSelection,
|
|
55
|
+
innerClassName,
|
|
56
|
+
isBordered,
|
|
57
|
+
expandable: realExpandable,
|
|
58
|
+
onRowSelectClick,
|
|
59
|
+
...restProps
|
|
60
|
+
} = props;
|
|
61
|
+
|
|
62
|
+
const { uid: compId } = $$componentItem;
|
|
63
|
+
const [form] = Form.useForm();
|
|
64
|
+
|
|
65
|
+
const engineApis = getEngineApis?.();
|
|
66
|
+
const {
|
|
67
|
+
sandBoxSafeRun,
|
|
68
|
+
dataState,
|
|
69
|
+
} = engineApis || {};
|
|
70
|
+
|
|
71
|
+
const { getLocale } = useLocale(engineApis);
|
|
72
|
+
|
|
73
|
+
const funcExpExecute = useFuncExpExecute(sandBoxSafeRun as any, getLocale);
|
|
74
|
+
|
|
75
|
+
const appId = props?.appId || $$componentItem?.appId;
|
|
76
|
+
const pageId = props?.pageId || $$componentItem?.pageId;
|
|
77
|
+
|
|
78
|
+
const { backgroundStyle } = useBackgroundStyle({ backgroundType, engineApis, appId: $$componentItem?.appId, mode: 'engine' });
|
|
79
|
+
|
|
80
|
+
// 根据id获取真实的下标,避免过滤和排序后影响下标
|
|
81
|
+
const { getRealIndexById } = useCreation(() => {
|
|
82
|
+
const indexMap = new Map<string | number, number>();
|
|
83
|
+
return {
|
|
84
|
+
getRealIndexById: (id: string | number) => {
|
|
85
|
+
if (indexMap.has(id)) {
|
|
86
|
+
return indexMap.get(id);
|
|
87
|
+
}
|
|
88
|
+
const index = (innerDataSource || []).findIndex((c: any) => c[currentRowKey] === id);
|
|
89
|
+
if (index !== -1) {
|
|
90
|
+
indexMap.set(id, index);
|
|
91
|
+
}
|
|
92
|
+
return index;
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}, [innerDataSource, currentRowKey]);
|
|
96
|
+
|
|
97
|
+
const {
|
|
98
|
+
onRowDeleteClick,
|
|
99
|
+
onRowEditClick,
|
|
100
|
+
onRowDetailClick,
|
|
101
|
+
onRowClick,
|
|
102
|
+
onRowDoubleClick,
|
|
103
|
+
} = useRowEdit({
|
|
104
|
+
...props,
|
|
105
|
+
funcExpExecute,
|
|
106
|
+
innerDataSource,
|
|
107
|
+
outerDataSource,
|
|
108
|
+
setInnerDataSource,
|
|
109
|
+
currentRowKey,
|
|
110
|
+
selectedRows,
|
|
111
|
+
onRowSelected,
|
|
112
|
+
engineApis,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const {
|
|
116
|
+
tableRef,
|
|
117
|
+
finalcolumns,
|
|
118
|
+
columnWidth,
|
|
119
|
+
setColumnWidth,
|
|
120
|
+
initLoadColWidth,
|
|
121
|
+
fixedAction,
|
|
122
|
+
} = useColumns({
|
|
123
|
+
...props,
|
|
124
|
+
sandBoxSafeRun,
|
|
125
|
+
funcExpExecute,
|
|
126
|
+
engineApis,
|
|
127
|
+
form,
|
|
128
|
+
appId,
|
|
129
|
+
pageId,
|
|
130
|
+
compId,
|
|
131
|
+
innerDataSource,
|
|
132
|
+
currentRowKey,
|
|
133
|
+
colServiceData,
|
|
134
|
+
onRowDetailClick,
|
|
135
|
+
onRowDeleteClick,
|
|
136
|
+
onRowEditClick,
|
|
137
|
+
loading,
|
|
138
|
+
rowSelection,
|
|
139
|
+
getLocale,
|
|
140
|
+
getRealIndexById,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const {
|
|
144
|
+
scroll,
|
|
145
|
+
tableWrapRef,
|
|
146
|
+
initTableWrapWidthRef,
|
|
147
|
+
getTableWrapWidth,
|
|
148
|
+
} = useScroll({
|
|
149
|
+
...props,
|
|
150
|
+
initLoadColWidth,
|
|
151
|
+
finalcolumns,
|
|
152
|
+
columnWidth,
|
|
153
|
+
setColumnWidth,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const superSelectTranslationMapRef: any = useRef(); // 防止state更新不及时,导致翻译无法获取翻译数据
|
|
157
|
+
if (!superSelectTranslationMapRef.current) {
|
|
158
|
+
superSelectTranslationMapRef.current = {};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const innerTableStyle: any = {};
|
|
162
|
+
if (styles?.overflowY) {
|
|
163
|
+
// 通过自定义样式给表格设置y轴滚动时, 认为希望只有表格滚动,但分页栏固定在底部
|
|
164
|
+
innerTableStyle.overflowY = styles.overflowY;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const handleTableChange = (
|
|
168
|
+
newPagination: any,
|
|
169
|
+
newFilters: any,
|
|
170
|
+
newSorter: any,
|
|
171
|
+
newExtra: any,
|
|
172
|
+
) => {
|
|
173
|
+
if (typeof onChange === 'function') {
|
|
174
|
+
onChange(newPagination, newFilters, newSorter, newExtra);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// 表格宽度需要根据列宽度赋值
|
|
179
|
+
const finalStyles = useMemo(() => {
|
|
180
|
+
const tmpStyle = { ...backgroundStyle, ...styles };
|
|
181
|
+
const tableWidth = getTableWrapWidth();
|
|
182
|
+
if (tableWrapRef.current && tableWidth) {
|
|
183
|
+
const realTableWidth = tableWidth >= initTableWrapWidthRef.current - 10 ? initTableWrapWidthRef.current - 9 : tableWidth;
|
|
184
|
+
tmpStyle.width = `${realTableWidth}px`;
|
|
185
|
+
}
|
|
186
|
+
return tmpStyle;
|
|
187
|
+
}, [columnWidth, backgroundStyle]);
|
|
188
|
+
|
|
189
|
+
return visible ? (
|
|
190
|
+
<div
|
|
191
|
+
// appId={appId} // TODO:先注释,不知道什么场景用到
|
|
192
|
+
// pageId={pageId} // TODO:先注释,不知道什么场景用到
|
|
193
|
+
data-compid={(props as any)?.['data-compid']}
|
|
194
|
+
style={finalStyles}
|
|
195
|
+
className={classnames(
|
|
196
|
+
'ued-table-wrap',
|
|
197
|
+
className,
|
|
198
|
+
)}
|
|
199
|
+
ref={tableWrapRef}
|
|
200
|
+
>
|
|
201
|
+
<TableHead
|
|
202
|
+
{...restProps} // 涉及到不确定的事件,所以要这么传
|
|
203
|
+
source="engine"
|
|
204
|
+
columns={[]}
|
|
205
|
+
sandBoxSafeRun={sandBoxSafeRun}
|
|
206
|
+
engineApis={engineApis}
|
|
207
|
+
/>
|
|
208
|
+
<Form form={form}>
|
|
209
|
+
<Table
|
|
210
|
+
locale={{
|
|
211
|
+
emptyText: <EmptyComp dataState={dataState} getLocale={getLocale} />,
|
|
212
|
+
}}
|
|
213
|
+
ref={tableRef}
|
|
214
|
+
bordered={isBordered}
|
|
215
|
+
className={innerClassName}
|
|
216
|
+
style={innerTableStyle}
|
|
217
|
+
components={{
|
|
218
|
+
body: {
|
|
219
|
+
cell: BodyCell,
|
|
220
|
+
},
|
|
221
|
+
header: {
|
|
222
|
+
cell: (info: any) => <HeaderCell
|
|
223
|
+
{...info}
|
|
224
|
+
tableData={innerDataSource}
|
|
225
|
+
childrenColumnName={realExpandable.childrenColumnName}
|
|
226
|
+
/>,
|
|
227
|
+
},
|
|
228
|
+
}}
|
|
229
|
+
columns={finalcolumns.map((item, index) => {
|
|
230
|
+
// 固定列最后一项宽度根据本身计算返回
|
|
231
|
+
if (fixedAction && finalcolumns.length - 1 === index) {
|
|
232
|
+
return item;
|
|
233
|
+
}
|
|
234
|
+
item.width = columnWidth[index] || item.width;
|
|
235
|
+
return item;
|
|
236
|
+
})}
|
|
237
|
+
rowKey={currentRowKey}
|
|
238
|
+
scroll={scroll}
|
|
239
|
+
onChange={handleTableChange}
|
|
240
|
+
onRow={(record, index?: number) => {
|
|
241
|
+
return ({
|
|
242
|
+
onClick: (event) => {
|
|
243
|
+
const hasOnRowClick = onRowClick(event, record, index);
|
|
244
|
+
!hasOnRowClick && onRowSelectClick(record, index);
|
|
245
|
+
}, // 点击行
|
|
246
|
+
onDoubleClick: (event) => {
|
|
247
|
+
onRowDoubleClick(event, record, index);
|
|
248
|
+
},
|
|
249
|
+
onContextMenu: (event) => { },
|
|
250
|
+
onMouseEnter: (event) => { }, // 鼠标移入行
|
|
251
|
+
onMouseLeave: (event) => { },
|
|
252
|
+
});
|
|
253
|
+
}}
|
|
254
|
+
rowSelection={rowSelection}
|
|
255
|
+
dataSource={innerDataSource}
|
|
256
|
+
expandable={realExpandable}
|
|
257
|
+
pagination={false}
|
|
258
|
+
/>
|
|
259
|
+
</Form>
|
|
260
|
+
</div>
|
|
261
|
+
) : null;
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
export default TreeTable;
|
|
@@ -14,14 +14,17 @@ const useCMDAction = (props: any) => {
|
|
|
14
14
|
expandTableData,
|
|
15
15
|
} = props;
|
|
16
16
|
|
|
17
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
loading,
|
|
19
|
+
colServiceData,
|
|
20
|
+
} = useCommonCMDAction(props);
|
|
18
21
|
|
|
19
22
|
useImperativeHandle(ref, () => ({
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* 加载树形表格数据(加载完之后,表格就脱离了数据源的控制了)
|
|
23
26
|
*/
|
|
24
|
-
reloadTreeTableData: (data: { dataSource: any[]; childrenKey: string; childrenSync: boolean }) => {
|
|
27
|
+
reloadTreeTableData: (data: { dataSource: any[]; childrenKey: string; childrenSync: boolean; }) => {
|
|
25
28
|
/**
|
|
26
29
|
* 注意,不是直接使用 setInnerDataSource
|
|
27
30
|
* 而是通过 setOuterDataSource 间接驱动 -> setInnerDataSource
|
|
@@ -37,7 +40,10 @@ const useCMDAction = (props: any) => {
|
|
|
37
40
|
* 理论上,只更新内部数据
|
|
38
41
|
*/
|
|
39
42
|
reloadTreeTableChildData: (data: { children: any[]; expandRowKey: string }) => {
|
|
40
|
-
const {
|
|
43
|
+
const {
|
|
44
|
+
children,
|
|
45
|
+
expandRowKey,
|
|
46
|
+
} = data;
|
|
41
47
|
|
|
42
48
|
// 异步加载限制为 children
|
|
43
49
|
const realChildrenColumnName = childrenColumnName || 'children';
|
|
@@ -2,10 +2,15 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import { useExpandable as useTableExpandable } from '../../Table/hooks';
|
|
3
3
|
|
|
4
4
|
const useExpandable = (props: any) => {
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
setInnerDataSource,
|
|
7
|
+
} = props;
|
|
6
8
|
|
|
7
9
|
const useTableExpandableReturn = useTableExpandable(props);
|
|
8
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
childrenColumnName,
|
|
12
|
+
expandable,
|
|
13
|
+
} = useTableExpandableReturn;
|
|
9
14
|
|
|
10
15
|
const [mode, setMode] = useState('all');
|
|
11
16
|
|
|
@@ -30,13 +35,14 @@ const useExpandable = (props: any) => {
|
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
|
-
|
|
38
|
+
|
|
34
39
|
return expandable?.expandIcon({
|
|
35
40
|
...props,
|
|
36
41
|
isLeaf,
|
|
37
42
|
});
|
|
38
43
|
};
|
|
39
44
|
|
|
45
|
+
|
|
40
46
|
useEffect(() => {
|
|
41
47
|
// 当模式为异步时,
|
|
42
48
|
if (mode === 'sync') {
|