@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.
Files changed (144) hide show
  1. package/lib/h5public/yarn.lock +7 -8
  2. package/lib/pcpublic/src/components/pcfactory/src/Button/index.tsx +11 -10
  3. package/lib/pcpublic/src/components/pcfactory/src/Card/CardTitle/index.tsx +31 -24
  4. package/lib/pcpublic/src/components/pcfactory/src/Card/index.tsx +32 -14
  5. package/lib/pcpublic/src/components/pcfactory/src/Card/useExtendBtn.tsx +85 -48
  6. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/ChartLine.tsx +24 -6
  7. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/PropsType.ts +31 -5
  8. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/index.tsx +3 -2
  9. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/loader.tsx +1 -1
  10. package/lib/pcpublic/src/components/pcfactory/src/Form/Form.tsx +153 -129
  11. package/lib/pcpublic/src/components/pcfactory/src/Form/index.tsx +2 -5
  12. package/lib/pcpublic/src/components/pcfactory/src/Form/useFormStatus.ts +8 -4
  13. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/LXPieChart.tsx +15 -3
  14. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/PropsType.ts +4 -3
  15. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/index.tsx +1 -1
  16. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/loader.tsx +1 -1
  17. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/LXRadarChat.tsx +18 -4
  18. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/PropsType.ts +2 -1
  19. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/index.tsx +1 -1
  20. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/loader.tsx +1 -1
  21. package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/BaseModalSelect.tsx +7 -2
  22. package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/index.tsx +60 -26
  23. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/LcdpUeditorMain.tsx +62 -55
  24. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditor.tsx +2 -6
  25. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditorMain.tsx +5 -5
  26. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/index.tsx +9 -2
  27. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/loader.ts +1 -1
  28. package/lib/pcpublic/src/components/pcfactory/src/Select/index.tsx +145 -66
  29. package/lib/pcpublic/src/components/pcfactory/src/Select/selectUtils.ts +13 -9
  30. package/lib/pcpublic/src/components/pcfactory/src/Table/BodyCell/index.tsx +36 -26
  31. package/lib/pcpublic/src/components/pcfactory/src/Table/EditComponent/index.tsx +69 -94
  32. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/GhostTag/index.tsx +12 -5
  33. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Hyperlink/index.tsx +9 -5
  34. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PointTag/index.tsx +11 -5
  35. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureColourFill/index.tsx +11 -5
  36. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureFadeColourTag/index.tsx +14 -7
  37. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Thumbnail/index.tsx +30 -31
  38. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/index.tsx +89 -41
  39. package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/HeaderCellTitle/index.tsx +25 -12
  40. package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/index.tsx +12 -5
  41. package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/PopoverWrapper.tsx +220 -0
  42. package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/SingleBtn.tsx +39 -32
  43. package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/index.tsx +178 -148
  44. package/lib/pcpublic/src/components/pcfactory/src/Table/Table.tsx +439 -0
  45. package/lib/pcpublic/src/components/pcfactory/src/Table/TableHead/index.tsx +159 -72
  46. package/lib/pcpublic/src/components/pcfactory/src/Table/TableSummaryRow/index.tsx +12 -20
  47. package/lib/pcpublic/src/components/pcfactory/src/Table/constant.ts +3 -0
  48. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/index.ts +4 -4
  49. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +32 -28
  50. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCheckStrict.ts +44 -57
  51. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +306 -276
  52. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCommon.ts +9 -6
  53. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useDataSource.ts +30 -21
  54. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useExpandable.tsx +33 -27
  55. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFilter.tsx +84 -77
  56. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFormatCell.tsx +33 -16
  57. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/usePagination.ts +15 -5
  58. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowEdit.ts +33 -33
  59. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowMerge.ts +13 -5
  60. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useScroll.ts +94 -28
  61. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSelection.ts +108 -99
  62. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSort.ts +8 -5
  63. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +27 -43
  64. package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +73 -394
  65. package/lib/pcpublic/src/components/pcfactory/src/Table/loader.tsx +15 -0
  66. package/lib/pcpublic/src/components/pcfactory/src/Table/types/OperationCell.d.ts +2 -2
  67. package/lib/pcpublic/src/components/pcfactory/src/Table/types/event.d.ts +12 -8
  68. package/lib/pcpublic/src/components/pcfactory/src/Table/types/headerCell.d.ts +2 -1
  69. package/lib/pcpublic/src/components/pcfactory/src/Table/types/prop.d.ts +24 -11
  70. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/SequenceId.ts +2 -1
  71. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +90 -82
  72. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/indexedDBHelper.ts +9 -22
  73. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/translate.ts +59 -0
  74. package/lib/pcpublic/src/components/pcfactory/src/Transfer/Transfer.tsx +644 -0
  75. package/lib/pcpublic/src/components/pcfactory/src/Transfer/index.tsx +49 -637
  76. package/lib/pcpublic/src/components/pcfactory/src/Transfer/loader.tsx +11 -0
  77. package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeEllipsisIcon.tsx +38 -0
  78. package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeNodeMenu/index.tsx +34 -35
  79. package/lib/pcpublic/src/components/pcfactory/src/Tree/index.tsx +213 -149
  80. package/lib/pcpublic/src/components/pcfactory/src/TreeSelect/index.tsx +47 -43
  81. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/TreeTable.tsx +264 -0
  82. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/index.ts +4 -1
  83. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useCMDAction.ts +9 -3
  84. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useExpandable.tsx +9 -3
  85. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +52 -191
  86. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/loader.tsx +16 -0
  87. package/lib/pcpublic/src/components/pcfactory/src/assets/index.tsx +34 -0
  88. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/quadrate.tsx +20 -0
  89. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/roundness.tsx +14 -0
  90. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/semicircle.tsx +15 -0
  91. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/verticalLine.tsx +12 -0
  92. package/lib/pcpublic/src/components/pcfactory/src/styles/common.less +17 -0
  93. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Card.less +57 -11
  94. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Form.less +101 -12
  95. package/lib/pcpublic/src/components/pcfactory/src/styles/components/ModalSelect.less +6 -0
  96. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Select.less +70 -6
  97. package/lib/pcpublic/src/components/pcfactory/src/utils/ChannelContainer.tsx +20 -14
  98. package/lib/pcpublic/src/components/pcfactory/src/utils/ChildRender.ts +6 -8
  99. package/lib/pcpublic/src/components/pcfactory/src/utils/CustomModule.tsx +4 -6
  100. package/lib/pcpublic/src/components/pcfactory/src/utils/DummyFormContext.ts +9 -13
  101. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/empty.tsx +5 -17
  102. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/index.tsx +3 -3
  103. package/lib/pcpublic/src/components/pcfactory/src/utils/Holidays.ts +11 -39
  104. package/lib/pcpublic/src/components/pcfactory/src/utils/HolidaysFormat.ts +83 -0
  105. package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/index.tsx +47 -0
  106. package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/scheduler.ts +74 -0
  107. package/lib/pcpublic/src/components/pcfactory/src/utils/LoaderHelper.tsx +4 -1
  108. package/lib/pcpublic/src/components/pcfactory/src/utils/Spin/index.tsx +8 -7
  109. package/lib/pcpublic/src/components/pcfactory/src/utils/WithSyncValue.ts +25 -23
  110. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/index.ts +10 -7
  111. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMap.ts +9 -6
  112. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMemoizedFn.ts +4 -1
  113. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/usePersistFn.ts +17 -0
  114. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSafeState.ts +2 -2
  115. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSetState.ts +7 -5
  116. package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +23 -50
  117. package/lib/pcpublic/src/components/pcfactory/src/utils/constant.ts +53 -57
  118. package/lib/pcpublic/src/components/pcfactory/src/utils/dynamicUtils/DynamicContext.tsx +12 -17
  119. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormContext.tsx +22 -12
  120. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormFields.tsx +50 -19
  121. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/WrapperContainer.tsx +58 -37
  122. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/cmdHelper.ts +33 -30
  123. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/common.ts +2 -0
  124. package/lib/pcpublic/src/components/pcfactory/src/utils/generatorDisabledCallback.ts +121 -113
  125. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCommonImperativeHandle.ts +16 -14
  126. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCompState.tsx +1 -1
  127. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDataMask.ts +7 -2
  128. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDoubleClick.ts +3 -1
  129. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useFuncExpExecute.ts +16 -14
  130. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useGetStaticAttrData.ts +9 -3
  131. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useHiddenStyle.ts +4 -5
  132. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInit.ts +11 -0
  133. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInitReactQuill.ts +3 -1
  134. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useListenState.ts +1 -0
  135. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useLocale.ts +5 -3
  136. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/usePrintMode.tsx +2 -2
  137. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useRules.ts +1 -1
  138. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useTestHelper.ts +2 -0
  139. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useToggleBoolean.ts +8 -4
  140. package/lib/pcpublic/src/components/pcfactory/src/utils/index.ts +10 -10
  141. package/lib/pcpublic/src/components/pcfactory/src/utils/polyfill.js +29 -31
  142. package/lib/pcpublic/src/components/pcfactory/src/utils/renderReadOnly.tsx +29 -26
  143. package/lib/public/public/iconfont.js +1 -0
  144. package/package.json +2 -2
@@ -0,0 +1,644 @@
1
+ import { Table, Transfer, Tree } from 'antd';
2
+ import type { FormItemProps } from 'antd/lib/form';
3
+ import { TableRowSelection } from 'antd/lib/table/interface';
4
+ import { TransferDirection, TransferItem } from 'antd/lib/transfer';
5
+ import difference from 'lodash/difference';
6
+ import React, { CSSProperties, useMemo, useRef, useState } from 'react';
7
+ import { useThrottleFn } from 'ahooks';
8
+ import { useFuncExpExecute } from '../utils/hooks/useFuncExpExecute';
9
+ import { LingxiForwardRef } from '@lingxiteam/types';
10
+ import EmptyComp from '../utils/Empty';
11
+ import { useLocale } from '../utils/hooks/useLocale';
12
+ import CustomModule from '../utils/CustomModule';
13
+ import classNames from 'classnames';
14
+
15
+ export interface WrapperTransferProps {
16
+ children: JSX.Element;
17
+ className: string;
18
+ }
19
+ const WrapperTransfer = ({ children, className }: WrapperTransferProps) =>
20
+ React.cloneElement(children, {
21
+ className: `ued-transfer-wrap ${className} ${children.props.className || ''}`,
22
+ });
23
+
24
+ const prefixCls = 'ued-transfer-wrap';
25
+ export interface MyTransferProps extends FormItemProps {
26
+ value?: any;
27
+ visible?: boolean;
28
+ onTransferChange?: (targetKeys: string[], direction: TransferDirection, moveKeys: string[]) => void;
29
+ onValueRelease?: (e: any) => void;
30
+ getCompPropMapState?: (id: string, type: string) => any;
31
+ compId?: string;
32
+ name?: string;
33
+ fieldName: string;
34
+ hidden?: boolean;
35
+ regexp?: any;
36
+ message?: string;
37
+ selfSpan?: number;
38
+ colSpan?: number;
39
+ showWrapperContainer: boolean;
40
+ wrapperContainer: any;
41
+ titleTip?: any;
42
+ tipIcon?: any;
43
+ tipLocation?: any;
44
+ tipContent?: any;
45
+ tipPlacement?: any;
46
+ colon?: boolean;
47
+ displayStyle: 'base' | 'tree' | 'table';
48
+ labelCode: string;
49
+ uid: string;
50
+ dataSource: any[];
51
+ columns?: any[];
52
+ childrenColumnName?: string;
53
+ onSearch?: (direction: 'left' | 'right', value: string) => void;
54
+ showSearch: boolean;
55
+ transferLeftTitle: string;
56
+ transferRightTitle: string;
57
+ transferWidth: number;
58
+ transferHeight: number;
59
+ size: 'small' | 'large';
60
+ page: boolean;
61
+ showQuickJumper?: boolean;
62
+ showSizeChanger?: boolean;
63
+ showTotal?: boolean;
64
+ total: number;
65
+ pageSize: number;
66
+ current: number;
67
+ pageSizeOptions: string;
68
+ onPageChange: (pageNo: number, pageSize: number) => void;
69
+ min: number;
70
+ max: number;
71
+ isFormChild?: boolean | undefined;
72
+ $$componentItem: any;
73
+ tipSize?: string; // 文字提示
74
+ tipWidth?: string; // 提示自定义的宽度
75
+ tipHeight?: string; // 提示自定义的高度
76
+ disabled: boolean;
77
+ readOnly: boolean;
78
+ hideLeftSelected?: boolean; // 是否隐藏左侧已选数据
79
+ // ref
80
+ formFieldsRef: any;
81
+
82
+ required: boolean;
83
+ }
84
+
85
+ const MyTransfer = LingxiForwardRef<any, MyTransferProps>((props, ref) => {
86
+ const {
87
+ value,
88
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
89
+ visible = true,
90
+ onTransferChange,
91
+ onValueRelease,
92
+ getCompPropMapState,
93
+ compId,
94
+ name,
95
+ fieldName: rawFieldName,
96
+ hidden,
97
+ regexp,
98
+ message,
99
+ label,
100
+ labelCol,
101
+ wrapperCol,
102
+ selfSpan,
103
+ colSpan,
104
+ showWrapperContainer,
105
+ wrapperContainer: WrapperContainer,
106
+ titleTip,
107
+ tipIcon,
108
+ tipLocation,
109
+ tipContent,
110
+ tipPlacement,
111
+ displayStyle,
112
+ labelCode,
113
+ uid,
114
+ columns,
115
+ childrenColumnName,
116
+ transferHeight,
117
+ transferWidth,
118
+ size,
119
+ pageSizeOptions,
120
+ min,
121
+ max,
122
+ isFormChild,
123
+ tipSize,
124
+ tipWidth,
125
+ tipHeight,
126
+ getEngineApis,
127
+ hideLeftSelected = false,
128
+ dataSource = [],
129
+ transferLeftTitle,
130
+ transferRightTitle,
131
+ required,
132
+ disabled,
133
+ readOnly,
134
+ formFieldsRef,
135
+ ...restProps
136
+ } = props;
137
+
138
+ const {
139
+ sandBoxSafeRun,
140
+ sandBoxLoadModule,
141
+ dataState,
142
+ } = getEngineApis() || {};
143
+
144
+ const { getLocale } = useLocale(getEngineApis());
145
+
146
+ const funcExpExecute = useFuncExpExecute(sandBoxSafeRun, getLocale);
147
+
148
+ const [currentPage, setCurrentPage] = useState(props.current || 1); // 当前页码
149
+ const [currentPageSize, setCurrentPageSize] = useState(props.pageSize); // 当前每页数量
150
+ // const [rightData, setRigthData] = useState<any>([]);
151
+
152
+
153
+ const currentSearchDirection = useRef<'left' | 'right'>('left');
154
+ const searchVal = useRef<string>('');
155
+
156
+ const titles = useMemo(() => {
157
+ return [transferLeftTitle, transferRightTitle];
158
+ }, [transferLeftTitle, transferRightTitle]);
159
+
160
+ const listStyle = useMemo(() => {
161
+ const tmpStyle: CSSProperties = {
162
+ height: transferHeight,
163
+ };
164
+ if (transferWidth) {
165
+ tmpStyle.maxWidth = transferWidth;
166
+ } else {
167
+ tmpStyle.flex = 1;
168
+ }
169
+ return tmpStyle;
170
+ }, [transferWidth, transferHeight]);
171
+
172
+ // 解析分页选择器配置
173
+ const parsedPageSizeOptions = useMemo(() => {
174
+ if (pageSizeOptions) {
175
+ try {
176
+ const arr = JSON.parse(pageSizeOptions);
177
+ if (Array.isArray(arr)) {
178
+ return arr.map((s) => String(s));
179
+ }
180
+ return [];
181
+ } catch (e) {
182
+ console.error('条数可选值 pageSizeOptions 必须配置为数字数组字符串'); // eslint-disable-line no-console
183
+ }
184
+ }
185
+ return [];
186
+ }, [pageSizeOptions]);
187
+
188
+ // 分页
189
+ const pagination = useMemo((): any => {
190
+ if (props.page) {
191
+ const res: any = {
192
+ showQuickJumper: props.showQuickJumper,
193
+ pageSize: currentPageSize,
194
+ current: currentPage,
195
+ onChange: (pageNo: number, pageSize: number) => {
196
+ setCurrentPage(pageNo);
197
+ setCurrentPageSize(pageSize);
198
+ },
199
+ };
200
+ if (props.showSizeChanger) {
201
+ res.showSizeChanger = props.showSizeChanger;
202
+ res.pageSizeOptions = parsedPageSizeOptions;
203
+ }
204
+ if (props?.showTotal) {
205
+ res.showTotal = (total: any) => getLocale?.('Pagination.showTotal', { tol: total });
206
+ }
207
+ // if(props.onPageChange) {
208
+ // res.onChange = (pageNo: number, pageSize: number) => {
209
+ // setCurrentPage(pageNo);
210
+ // setCurrentPageSize(pageSize);
211
+ // props.onPageChange(pageNo, pageSize);
212
+ // };
213
+ // }
214
+ return res;
215
+ }
216
+ return false;
217
+ }, [props, currentPage, currentPageSize]);
218
+
219
+ /**
220
+ * 向右添加数据
221
+ * @param targetKeys
222
+ */
223
+ // const getRigthData = (targetKeys: any) => { // 每次选中的右侧数据进行保存,左侧搜索框配置请求数据,数据重新渲染会导致右侧数据一起被过滤
224
+ // const selectedData = [...rightData];
225
+ // const newData: any = [];
226
+ // if (targetKeys && targetKeys.length) { // 当前有选中的情况
227
+ // targetKeys.forEach((item: any) => {
228
+ // const selectedObj = selectedData.find(child => child[uid] === item);
229
+ // const targetObj = tmpDataSource.find(i => i[uid] === item);
230
+ // if (!selectedObj && targetObj) {
231
+ // newData.push({ ...targetObj, key: item });
232
+ // }
233
+ // });
234
+ // setRigthData([...newData, ...rightData]);
235
+ // } else {
236
+ // setRigthData([]);
237
+ // }
238
+ // }
239
+ /**
240
+ * 向左移除
241
+ * @param moveKeys
242
+ */
243
+ // const removeRigthDataSource = (moveKeys: any) => {
244
+ // if (moveKeys && Array.isArray(moveKeys) && moveKeys.length) {
245
+ // // const uids = moveKeys.map(it => it[uid]); // 要移除的所有id
246
+ // const targetData: any = [];
247
+ // if (rightData && rightData.length > 0) {
248
+ // rightData.forEach((item: { [x: string]: any; }) => {
249
+ // if (!moveKeys.includes(item[uid])) {
250
+ // targetData.push({ ...item });
251
+ // }
252
+ // })
253
+ // }
254
+ // setRigthData([...targetData]);
255
+ // }
256
+ // }
257
+ const { run } = useThrottleFn((d, v) => {
258
+ if (props?.onSearch) {
259
+ props.onSearch(d, v);
260
+ }
261
+ });
262
+ const commonProps: any = {
263
+ ...restProps,
264
+ titles,
265
+ listStyle,
266
+ style: props.style,
267
+ onSearch: (direction: 'left' | 'right', value: string) => {
268
+ searchVal.current = value;
269
+ currentSearchDirection.current = direction;
270
+ // 增加节流,防止在搜索框输入的过程中,一直请求
271
+ run && run(direction, value);
272
+ // if (props?.onSearch) {
273
+ // props.onSearch(direction, value);
274
+ // }
275
+ },
276
+ targetKeys: value || [],
277
+ render: (item: any) => item[labelCode],
278
+ filterOption: (val: any, item: any) => {
279
+ // 开启了搜索并且配置了搜索事件,左侧不触发本地过滤
280
+ if (props.showSearch && currentSearchDirection.current === 'left' && props.onSearch) {
281
+ return true;
282
+ }
283
+ const isTable = displayStyle === 'table';
284
+ if (isTable) {
285
+ let flag = false;
286
+ try {
287
+ columns?.forEach(col => {
288
+ // 原先写法indexof item[col.dataIndex]? 如果字段为null或者undefined,则返回void 0 === undefined,导致还是会进入该判断
289
+ if (item[col.dataIndex] && item[col.dataIndex]?.indexOf(val) > -1) {
290
+ flag = true;
291
+ throw Error();// 异常跳出循环
292
+ }
293
+ });
294
+ } catch (error) {
295
+ //
296
+ }
297
+ return flag;
298
+ }
299
+ return item?.[labelCode] && `${item?.[labelCode]}`.indexOf(val) > -1; // 同上的原因
300
+ },
301
+ rowKey: (record: any) => record[uid],
302
+ onChange: (targetKeys: string[], direction: TransferDirection, moveKeys: string[]) => {
303
+ // if (direction === 'left') {
304
+ // removeRigthDataSource(moveKeys);
305
+ // } else {
306
+ // getRigthData(targetKeys);
307
+ // }
308
+ // console.log('值变化了');
309
+ if (onTransferChange) {
310
+ onTransferChange(targetKeys, direction, moveKeys);
311
+ }
312
+ },
313
+ selectAllLabels: [null, () => { // 自定义右侧
314
+ return getLocale?.('Transfer.unit', { num: value.length });
315
+ }],
316
+ };
317
+ const finalColumns = useMemo(() => {
318
+ if (displayStyle === 'table') {
319
+ return columns?.map(col => {
320
+ // 自定义渲染函数-
321
+ if (col.jsx) {
322
+ col.render = (text: any, row: any, index: any) => {
323
+ return (
324
+ <span>
325
+ <CustomModule
326
+ sandBoxLoadModule={sandBoxLoadModule}
327
+ errorInfo={{ id: props.$$componentItem.id }}
328
+ code={col.customRendering}
329
+ compProps={{
330
+ text,
331
+ item: row,
332
+ index,
333
+ }}
334
+ />
335
+ </span>
336
+ );
337
+ };
338
+ } else if (col.customRendering) {
339
+ col.render = (text: any, row: any, index: any) => {
340
+ return {
341
+ children: (
342
+ <span
343
+ // eslint-disable-next-line react/no-danger
344
+ dangerouslySetInnerHTML={{
345
+ __html: `${funcExpExecute(col.customRendering, [
346
+ {
347
+ key: 'text',
348
+ value: text,
349
+ },
350
+ {
351
+ key: 'row',
352
+ value: row,
353
+ },
354
+ {
355
+ key: 'index',
356
+ value: index,
357
+ },
358
+ ])}`,
359
+ }}
360
+ />
361
+ ),
362
+ props: {},
363
+ };
364
+ };
365
+ } else if (col.lineNum && typeof col.lineNum === 'number' && col.lineNum > 0) { // 自定义可以单行或者多行溢出
366
+ const controllLineStyle = {
367
+ WebkitLineClamp: col.lineNum,
368
+ };
369
+ return {
370
+ ...col,
371
+ render: (text: any) => (
372
+ <span className="ued-control-line-number" style={controllLineStyle}>
373
+ {text}
374
+ </span>),
375
+ };
376
+ }
377
+ return col;
378
+ });
379
+ }
380
+ return [
381
+ { title: getLocale?.('title'), dataIndex: labelCode },
382
+ ];
383
+ }, [displayStyle]);
384
+
385
+ const renderTransferTable = (isTable: boolean = false) => {
386
+ // 格式化数据
387
+ const generateData = (list: any[]): any[] => {
388
+ return list?.map((item: any) => {
389
+ return {
390
+ ...item,
391
+ key: item[uid],
392
+ children: generateData(childrenColumnName ? item[childrenColumnName] : item.children),
393
+ };
394
+ });
395
+ };
396
+
397
+ // 穿梭框数据
398
+ const transferDataSource: any[] = [];
399
+ function flatten(list: any[] = []) {
400
+ list.forEach(item => {
401
+ transferDataSource.push(item);
402
+ flatten(item?.children);
403
+ });
404
+ }
405
+ flatten(dataSource);
406
+ return (
407
+ <Transfer
408
+ {...commonProps}
409
+ disabled={disabled}
410
+ dataSource={transferDataSource}
411
+ >
412
+ {
413
+ ({
414
+ direction,
415
+ filteredItems,
416
+ disabled: listDisabled,
417
+ selectedKeys: listSelectedKeys,
418
+ onItemSelectAll,
419
+ onItemSelect,
420
+ }) => {
421
+ const rowSelection: TableRowSelection<TransferItem> = {
422
+ getCheckboxProps: (item: any) => {
423
+ return {
424
+ disabled:
425
+ listDisabled ||
426
+ item.disabled ||
427
+ (direction === 'left' && value.includes?.(item.key)),
428
+ };
429
+ },
430
+ onSelectAll(selected, selectedRows) {
431
+ const treeSelectedKeys = selectedRows
432
+ .filter(item => !item?.disabled)
433
+ .map(({ key }) => key);
434
+ // 由于左侧列表保留了右侧选中数据value,点击全选时,需要过滤掉value内的值,否则会重复
435
+ const diffKeys = selected
436
+ ? difference((direction === 'left' && isTable) ? treeSelectedKeys.filter(c => !value.includes?.(c)) : treeSelectedKeys, listSelectedKeys)
437
+ : difference(listSelectedKeys, treeSelectedKeys);
438
+ onItemSelectAll(diffKeys as string[], selected);
439
+ },
440
+ onSelect({ key }, selected) {
441
+ onItemSelect(key as string, selected);
442
+ },
443
+ selectedRowKeys: direction === 'left' ? [...listSelectedKeys, ...value] : listSelectedKeys,
444
+ };
445
+ const tSize = (size === 'large' ? 40 : 32) + 12; // 表格有上内边距
446
+ const searchHeight = isTable ? 44 : 56; // 有搜索框时高度
447
+ // 穿梭框高度 - 传说框头部高度 表头高度 分页高度 搜索框高度
448
+ const scrollY = transferHeight - 40 - 44 - (isTable ? tSize : 0) - (props.showSearch ? searchHeight : 0) - 2;
449
+ const scroll: any = { y: scrollY };
450
+ if (!props.page) {
451
+ scroll.y += 40 + 4;
452
+ }
453
+ let currentDataSource: any[] = [];
454
+ if (direction === 'left') {
455
+ const filterKeys: string[] = [];
456
+ // 过滤表格数据
457
+ const filterTableData = (obj: any) => {
458
+ if (obj) {
459
+ if (Array.isArray(obj)) {
460
+ obj.forEach(item => {
461
+ filterKeys.push(item.key);
462
+ filterTableData(item.children);
463
+ });
464
+ } else {
465
+ filterKeys.push(obj?.key);
466
+ filterTableData(obj?.children);
467
+ }
468
+ }
469
+ };
470
+ if (searchVal.current) {
471
+ const targetFilterData = generateData(filteredItems);
472
+ if (targetFilterData && Array.isArray(targetFilterData) && targetFilterData.length) { // 如果搜索父级里面和子级含有相同的文字,会导致数据有问题,所以条件搜索的情况直接将数据按照一级展示
473
+ targetFilterData.forEach((item) => {
474
+ if (!filterKeys.includes(item.key)) { // 过滤会将子级也过滤进来 eg [{key:1,label:1,children:[{key:2,label:2},{key:3,label:3}]},{key:2,label:2}],需要将子级{key:2,label:2}过滤
475
+ currentDataSource.push(item);
476
+ }
477
+ filterTableData(item);
478
+ });
479
+ }
480
+ } else if (!isTable) {
481
+ // 增加基础样式下左侧选中数据不显示的逻辑
482
+ currentDataSource = generateData(transferDataSource.filter(item => !(hideLeftSelected && value.includes?.(item?.[uid]))));
483
+ } else {
484
+ currentDataSource = generateData([...dataSource]);
485
+ }
486
+ }
487
+ // 有选中数据的时候,左侧数据发生改变,则会导致右侧是数据被重新渲染。
488
+ // 这里如果是渲染右侧数据,则取之前保存的数据进行渲染
489
+ if (direction === 'right') {
490
+ currentDataSource = [...filteredItems];
491
+ // 删除children字段, 由于原先字段默认值配置的是false,这里就保持一致
492
+ currentDataSource.forEach((row) => {
493
+ if (row[childrenColumnName || 'false']) {
494
+ delete row[childrenColumnName || 'false'];
495
+ }
496
+ });
497
+ }
498
+ return (
499
+ <Table
500
+ locale={{
501
+ emptyText: <EmptyComp dataState={dataState} getLocale={getLocale} />,
502
+ }}
503
+ columns={finalColumns}
504
+ dataSource={currentDataSource}
505
+ rowKey={`${uid}`}
506
+ showHeader={isTable}
507
+ rowSelection={rowSelection}
508
+ className={classNames(
509
+ !isTable ? `${prefixCls}-table-hideBorder` : `${prefixCls}-table-border`,
510
+ `${prefixCls}-table`,
511
+ isTable && props.showSearch ? `${prefixCls}-search-table` : '',
512
+ )}
513
+ childrenColumnName={isTable ? childrenColumnName || 'false' : 'false'}
514
+ scroll={scroll}
515
+ onRow={({ key, disabled: itemDisabled }: any) => ({
516
+ onClick: () => {
517
+ if (itemDisabled || listDisabled || (direction === 'left' && value.includes(key))) return;
518
+ onItemSelect(key as string, !listSelectedKeys.includes(key as string));
519
+ },
520
+ })}
521
+ size={size === 'large' ? 'middle' : 'small'}
522
+ pagination={direction === 'left' ? pagination : !!props.page}
523
+ />
524
+ );
525
+ }
526
+ }
527
+ </Transfer>
528
+ );
529
+ };
530
+ // 展开 dataSource
531
+ const renderTransferTree = () => {
532
+ // 是否选中
533
+ const isChecked = (selectedKeys: (string | number)[], eventKey: string | number) => selectedKeys.includes(eventKey);
534
+ // 格式化数据
535
+ const generateData = (list: any[]): any[] => {
536
+ return list?.map((item: any) => {
537
+ return {
538
+ ...item,
539
+ key: item[uid],
540
+ title: item[labelCode],
541
+ disabled: value?.includes(item[uid]),
542
+ children: generateData(childrenColumnName ? item[childrenColumnName] : item.children),
543
+ };
544
+ });
545
+ };
546
+ const transferDataSource: any[] = [];
547
+ function flatten(list: any[] = []) {
548
+ list.forEach(item => {
549
+ transferDataSource.push(item);
550
+ flatten(item.children);
551
+ });
552
+ }
553
+ flatten(dataSource);
554
+ return (
555
+ <Transfer
556
+ {...commonProps}
557
+ disabled={disabled}
558
+ dataSource={transferDataSource}
559
+ >
560
+ {({ direction, onItemSelect, selectedKeys, filteredItems }) => {
561
+ if (direction === 'left') {
562
+ const targetKeysData: any = [];
563
+ // eslint-disable-next-line no-inner-declarations
564
+ function flattenTreeData(obj: any) { // 将过滤的所有数据id存储,用于后面对比
565
+ if (obj) {
566
+ if (Array.isArray(obj)) {
567
+ obj.forEach(item => {
568
+ targetKeysData.push(item.key);
569
+ flattenTreeData(item.children);
570
+ });
571
+ } else {
572
+ targetKeysData.push(obj?.key);
573
+ flattenTreeData(obj?.children);
574
+ }
575
+ }
576
+ }
577
+ const checkedKeys = [...selectedKeys, ...(value || [])];
578
+ let curTreeData: any[] = [];
579
+ if (searchVal.current) {
580
+ const targetFilterData = generateData(filteredItems);
581
+ if (targetFilterData && Array.isArray(targetFilterData) && targetFilterData.length) { // 如果搜索父级里面和子级含有相同的文字,会导致数据有问题,所以条件搜索的情况直接将数据按照一级展示
582
+ targetFilterData.forEach((item) => {
583
+ if (!targetKeysData.includes(item.key)) { // 过滤会将子级也过滤进来 eg [{key:1,label:1,children:[{key:2,label:2},{key:3,label:3}]},{key:2,label:2}],需要将子级{key:2,label:2}过滤
584
+ curTreeData.push(item);
585
+ }
586
+ flattenTreeData(item);
587
+ });
588
+ }
589
+ } else {
590
+ curTreeData = generateData(dataSource);
591
+ }
592
+ return (
593
+ <Tree
594
+ treeData={[...curTreeData]}
595
+ checkable
596
+ checkStrictly
597
+ blockNode
598
+ defaultExpandAll
599
+ fieldNames={{
600
+ title: labelCode,
601
+ key: uid,
602
+ children: childrenColumnName,
603
+ }}
604
+ checkedKeys={checkedKeys}
605
+ onCheck={(_, { node: { key } }) => {
606
+ onItemSelect(key as string, !isChecked(checkedKeys, key));
607
+ }}
608
+ onSelect={(_, { node: { key } }) => {
609
+ onItemSelect(key as string, !isChecked(checkedKeys, key));
610
+ }}
611
+ disabled={disabled}
612
+ />
613
+ );
614
+ }
615
+ return null;
616
+ }}
617
+ </Transfer>
618
+ );
619
+ };
620
+
621
+ const renderTransferContent = useMemo(() => {
622
+ let resComp: any = null;
623
+ switch (displayStyle) {
624
+ case 'tree':
625
+ resComp = renderTransferTree();
626
+ break;
627
+ case 'table':
628
+ resComp = renderTransferTable(true);
629
+ break;
630
+ default:
631
+ resComp = renderTransferTable(false);
632
+ break;
633
+ }
634
+ return resComp;
635
+ }, [props, value, pagination, dataSource, transferLeftTitle, transferRightTitle]);
636
+
637
+
638
+ // console.log(value, 'value===');
639
+
640
+ return <>{renderTransferContent}</>;
641
+ });
642
+
643
+ export default MyTransfer;
644
+ export { WrapperTransfer };