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