@lingxiteam/ebe-utils 0.0.10 → 0.0.12
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/README.md +6 -0
- package/es/index.d.ts +11 -6
- package/es/index.js +63 -52
- package/es/node/babel/getAllImportFiles.d.ts +1 -1
- package/es/node/babel/getAllImportFiles.js +4 -4
- package/es/node/move.d.ts +1 -0
- package/es/node/move.js +21 -13
- package/lib/h5public/src/components/factory/package.json +4 -0
- package/lib/h5public/src/components/factory/src/BlockSelect/index.tsx +9 -1
- package/lib/h5public/src/components/factory/src/DynamicDataContainer/index.tsx +24 -5
- package/lib/h5public/src/components/factory/src/DynamicList/MySwipe/index.tsx +1 -1
- package/lib/h5public/src/hooks/usePageForm.ts +108 -4
- package/lib/h5public/src/utils/LcdpSpin/index.tsx +15 -3
- package/lib/h5public/src/utils/formUtils.ts +336 -0
- package/lib/node/babel/getAllImportFiles.d.ts +1 -1
- package/lib/node/babel/getAllImportFiles.js +3 -3
- package/lib/node/move.d.ts +1 -0
- package/lib/node/move.js +19 -8
- package/lib/pcpublic/src/components/common/PreviewFile/index.less +200 -0
- package/lib/pcpublic/src/components/common/PreviewFile/index.tsx +787 -0
- package/lib/pcpublic/src/components/common/PreviewFile/utils.ts +90 -0
- package/lib/pcpublic/src/components/pcfactory/package.json +4 -0
- package/lib/pcpublic/src/components/pcfactory/src/Audio/index.tsx +6 -6
- package/lib/pcpublic/src/components/pcfactory/src/Cascader/index.tsx +15 -0
- package/lib/pcpublic/src/components/pcfactory/src/Checkbox/index.tsx +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/index.tsx +301 -0
- package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/useDynamicDataContainer.ts +27 -0
- package/lib/pcpublic/src/components/pcfactory/src/Form/Form.tsx +1 -0
- package/lib/pcpublic/src/components/pcfactory/src/GridView/GridView.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/Img/assets/placeholder.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/Input/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/LoopList/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/PictureVerifyCode/assets/placeholder.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/PictureVerifyCode/index.tsx +6 -6
- package/lib/pcpublic/src/components/pcfactory/src/QuillEditor/index.tsx +11 -0
- package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/components/ReactRender.tsx +5 -1
- package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/constant.ts +36 -0
- package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/index.tsx +28 -16
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditor.tsx +12 -5
- package/lib/pcpublic/src/components/pcfactory/src/Select/index.tsx +65 -39
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/default.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/js.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/pdf.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/ppt.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/txt.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/word.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/xls.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/zip.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/index.tsx +11 -1
- package/lib/pcpublic/src/components/pcfactory/src/SuperSelect/ComSelect.tsx +1 -2
- package/lib/pcpublic/src/components/pcfactory/src/Table/TableSummaryRow/index.tsx +8 -1
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +4 -4
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +91 -34
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSelection.ts +22 -11
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +51 -8
- package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +28 -6
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/bodyCell.d.ts +22 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/contentStyle.d.ts +41 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/event.d.ts +129 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/headerCell.d.ts +37 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/prop.d.ts +301 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +83 -31
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/indexedDBHelper.ts +119 -0
- package/lib/pcpublic/src/components/pcfactory/src/Transfer/index.tsx +8 -3
- package/lib/pcpublic/src/components/pcfactory/src/Tree/index.tsx +4 -1
- package/lib/pcpublic/src/components/pcfactory/src/TreeSelect/index.tsx +12 -1
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +28 -3
- package/lib/pcpublic/src/components/pcfactory/src/VerificationCode/assets/placeholder.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/VerificationCode/index.tsx +6 -6
- package/lib/pcpublic/src/components/pcfactory/src/VideoPlayer/index.tsx +12 -12
- package/lib/pcpublic/src/components/pcfactory/src/View/index.tsx +18 -4
- package/lib/pcpublic/src/components/pcfactory/src/index.component.ts +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/common.less +6 -1
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Form.less +4 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Input.less +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/InputNumber.less +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/ModalSelect.less +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Table.less +5 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/DummyFormContext.ts +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/empty.tsx +29 -28
- package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/index.tsx +36 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/Spin/index.tsx +29 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +18 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormContext.tsx +10 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormFields.tsx +10 -5
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/common.ts +46 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCompState.tsx +44 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useLocale.ts +1 -0
- package/lib/pcpublic/src/utils/formUtils.ts +458 -0
- package/lib/public/src/components/WaterMark/index.tsx +1 -1
- package/lib/public/src/services/api/index.ts +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EngineApisType } from '@lingxiteam/types';
|
|
2
|
+
import type { ResizeCallbackData } from 'react-resizable';
|
|
3
|
+
|
|
4
|
+
export type HeaderCellProps = React.HTMLAttributes<any> & {
|
|
5
|
+
onResize: (
|
|
6
|
+
e: React.SyntheticEvent<Element>,
|
|
7
|
+
data: ResizeCallbackData,
|
|
8
|
+
) => void;
|
|
9
|
+
width: number;
|
|
10
|
+
isFlexColumn?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface Code {
|
|
14
|
+
code: any;
|
|
15
|
+
originCode: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Tip {
|
|
19
|
+
type: string;
|
|
20
|
+
icon: any;
|
|
21
|
+
iconPlacement?: string;
|
|
22
|
+
content: string | Code;
|
|
23
|
+
placement?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface HeaderCellTitleProps {
|
|
27
|
+
size?: string;
|
|
28
|
+
column: {
|
|
29
|
+
title?: string;
|
|
30
|
+
titleLineNum?: number;
|
|
31
|
+
titleTip?: Tip;
|
|
32
|
+
};
|
|
33
|
+
mode?: 'editor' | 'engine';
|
|
34
|
+
funcExpExecute?: FuncExpExeCuteType;
|
|
35
|
+
sandBoxSafeRun?: any;
|
|
36
|
+
engineApis?: EngineApisType;
|
|
37
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import type { TableProps } from 'antd/lib/table';
|
|
2
|
+
import type { MyTableEventTypes } from './event';
|
|
3
|
+
|
|
4
|
+
export type SummaryConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* 不合计|单列|多列
|
|
7
|
+
*/
|
|
8
|
+
type: 'none' | 'single' | 'multi';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 总结行名称
|
|
12
|
+
*/
|
|
13
|
+
name?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 单列合并值
|
|
17
|
+
*/
|
|
18
|
+
col?: Array<ColItem>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 多列合并
|
|
22
|
+
*/
|
|
23
|
+
group?: Array<ColItem>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 保留几位小数
|
|
27
|
+
*/
|
|
28
|
+
decimal?: number;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 背景色
|
|
32
|
+
*/
|
|
33
|
+
background?: string;
|
|
34
|
+
};
|
|
35
|
+
export interface TableBasePropTypes extends TableProps<any> {
|
|
36
|
+
className?: string;
|
|
37
|
+
style?: React.CSSProperties;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 数据源
|
|
41
|
+
*/
|
|
42
|
+
dataSource: [];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 标识是否绑定了数据源
|
|
46
|
+
*/
|
|
47
|
+
dataSourceFromDataSourceConfig?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 刷新数据源时,是否开启加载中效果
|
|
51
|
+
*/
|
|
52
|
+
dataSourceLoading?: boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 行主键来源类型
|
|
56
|
+
*/
|
|
57
|
+
rowKeyType?: 'rowKeyType' | 'auto';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 行主键来源类型为指定字段时,字段名
|
|
61
|
+
*/
|
|
62
|
+
rowKey?: string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 尺寸
|
|
66
|
+
*/
|
|
67
|
+
size?: 'default' | 'middle' | 'small';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 边框类型
|
|
71
|
+
*/
|
|
72
|
+
borded?: 'segmentation' | 'zebra' | 'border';
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 是否显示
|
|
76
|
+
*/
|
|
77
|
+
visible?: boolean;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 是否开启可拖拽列宽
|
|
81
|
+
*/
|
|
82
|
+
isFlexColumn?: boolean;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
scroll?: false | { x: number; y: number };
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 适应方式
|
|
91
|
+
*/
|
|
92
|
+
adjustModel?: 'auto' | 'fill';
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 内容列配置
|
|
96
|
+
*/
|
|
97
|
+
columns: any[];
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 单元格样式配置
|
|
101
|
+
*/
|
|
102
|
+
colorFormatInfo?: any[];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 这是啥呢?
|
|
106
|
+
* @deprecated 是否废弃?
|
|
107
|
+
*/
|
|
108
|
+
pageState?: any;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 运行时所属应用id
|
|
112
|
+
* @deprecated 将要废弃或已废弃,统一从 $$componentItem 获取
|
|
113
|
+
*/
|
|
114
|
+
appId?: string;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 运行时所属页面id
|
|
118
|
+
* @deprecated 将要废弃或已废弃,统一从 $$componentItem 获取
|
|
119
|
+
*/
|
|
120
|
+
pageId?: string;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 引擎能力
|
|
124
|
+
*/
|
|
125
|
+
getEngineApis?: () => EngineApisType;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 组件运行时引擎透露信息
|
|
129
|
+
*/
|
|
130
|
+
$$componentItem: ComponentItemType;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 总结合计行
|
|
134
|
+
*/
|
|
135
|
+
summaryTotal?: SummaryConfig;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface TablePaginationPropTypes {
|
|
139
|
+
/**
|
|
140
|
+
* 是否开启分页
|
|
141
|
+
*/
|
|
142
|
+
page?: boolean;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 分页开启后,当前页
|
|
146
|
+
*/
|
|
147
|
+
current?: number;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 分页开启后,每页条数
|
|
151
|
+
*/
|
|
152
|
+
pageSize?: number;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 分页开启后,是否显示总条数
|
|
156
|
+
*/
|
|
157
|
+
showTotal?: boolean;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 分页开启后,总条数值
|
|
161
|
+
*/
|
|
162
|
+
total?: number;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 分页开启后,是否显示每页条数选择
|
|
166
|
+
*/
|
|
167
|
+
showSizeChanger?: boolean;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 分页开启后,每页条数可选值配置
|
|
171
|
+
*/
|
|
172
|
+
pageSizeOptions?: string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 分页开启后,是否显示快速跳转分页
|
|
176
|
+
*/
|
|
177
|
+
showQuickJumper?: boolean;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface TableEditPropTypes {
|
|
181
|
+
/**
|
|
182
|
+
* 编辑模式
|
|
183
|
+
*/
|
|
184
|
+
editMode?: 'single' | 'multiple';
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 行编辑是否禁用判断
|
|
188
|
+
*/
|
|
189
|
+
rowEditableRule?: any;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 操作列内置按钮的配置
|
|
193
|
+
*/
|
|
194
|
+
rowActions?: any[];
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 操作列扩展按钮的配置
|
|
198
|
+
*/
|
|
199
|
+
extend?: any[];
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 操作列展示按钮的最大数量
|
|
203
|
+
*/
|
|
204
|
+
extendNum?: number;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 是否固定操作列
|
|
208
|
+
*/
|
|
209
|
+
fixedAction?: boolean;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 是否隐藏操作列
|
|
213
|
+
*/
|
|
214
|
+
hiddenAction?: boolean;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 操作列固定宽度
|
|
218
|
+
*/
|
|
219
|
+
actionWidth?: number;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface TableRowExpandPropTypes {
|
|
223
|
+
/**
|
|
224
|
+
* 是否可以行展开规则
|
|
225
|
+
*/
|
|
226
|
+
rowExpandable?: any;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 是否全部展开所有行
|
|
230
|
+
*/
|
|
231
|
+
defaultExpandAllRows?: boolean;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 是否点击行展开
|
|
235
|
+
*/
|
|
236
|
+
expandRowByClick?: boolean;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 默认展开行,例如:"[\"1\"]"
|
|
240
|
+
*/
|
|
241
|
+
defaultExpandedRowKeys?: string;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 展开图标的位置的基准列
|
|
245
|
+
*/
|
|
246
|
+
expandIconPositionRef?: { title: string; dataIndex?: string };
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 展开图标位于基准列的方向位置
|
|
250
|
+
*/
|
|
251
|
+
expandIconPosition?: 'left' | 'right';
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* 处于展开时,显示的图标配置
|
|
255
|
+
*/
|
|
256
|
+
expandCloseIcon?: any;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* 处于收缩时,显示的图标配置
|
|
260
|
+
*/
|
|
261
|
+
expandOpenIcon?: any;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 行展开的扩展内容(业务组件)配置
|
|
265
|
+
*/
|
|
266
|
+
expandComponents?: any[];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface TableRowSelectPropType {
|
|
270
|
+
/**
|
|
271
|
+
* 选择模式
|
|
272
|
+
*/
|
|
273
|
+
rowSelection?:
|
|
274
|
+
| false
|
|
275
|
+
| {
|
|
276
|
+
type: 'radio' | 'checkbox';
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 可选表格行选择是否禁用判断
|
|
281
|
+
*/
|
|
282
|
+
rowSelectionDisabled?: any;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* 父子联动选择
|
|
286
|
+
*/
|
|
287
|
+
checkLoosed?: boolean;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export type MyTableProps = TableBasePropTypes &
|
|
291
|
+
TablePaginationPropTypes &
|
|
292
|
+
TableEditPropTypes &
|
|
293
|
+
TableRowExpandPropTypes &
|
|
294
|
+
TableRowSelectPropType &
|
|
295
|
+
MyTableEventTypes;
|
|
296
|
+
|
|
297
|
+
export type LevelItem<T> = {
|
|
298
|
+
__parent__?: LevelItem<T>;
|
|
299
|
+
__key__: string | number;
|
|
300
|
+
__children__?: LevelItem<T>[];
|
|
301
|
+
} & T;
|
|
@@ -2,12 +2,18 @@ import { Table } from 'antd';
|
|
|
2
2
|
import { LevelItem } from '../types/prop';
|
|
3
3
|
// 以下逻辑调整时需同步到packages/editor/src/Input/TableColorGroup/utils.ts
|
|
4
4
|
export const treeRootName = 'tree-root';
|
|
5
|
+
export const hiddenHeaderCellClass = 'ued-table-hidden-head-cell';
|
|
5
6
|
export type SingleRowInfo = {
|
|
6
7
|
[rowIndex: number]: {
|
|
7
8
|
rowIdAndTitleColMap: any;
|
|
8
9
|
nextRowsChildren: any;
|
|
9
10
|
};
|
|
10
11
|
};
|
|
12
|
+
// 获取分组名称,为空的向下补全
|
|
13
|
+
const findGroupName = (groupList: string[], startIndex: number) => {
|
|
14
|
+
const list = groupList.slice(startIndex);
|
|
15
|
+
return list.find((g) => !!g) || '';
|
|
16
|
+
};
|
|
11
17
|
export const handleMultiLevelHeader = (leftTree: any, column: any) => {
|
|
12
18
|
const { fixed = '' } = column;
|
|
13
19
|
let { group } = column;
|
|
@@ -23,8 +29,8 @@ export const handleMultiLevelHeader = (leftTree: any, column: any) => {
|
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
// 过滤掉空的配置
|
|
26
|
-
group = group.filter((g: any) => g);
|
|
27
|
-
// 保留一个空配置,以进入构造
|
|
32
|
+
// group = group.filter((g: any) => g);
|
|
33
|
+
// // 保留一个空配置,以进入构造
|
|
28
34
|
group = group.length === 0 ? [''] : group;
|
|
29
35
|
|
|
30
36
|
const groupLen = group.length;
|
|
@@ -67,7 +73,7 @@ export const handleMultiLevelHeader = (leftTree: any, column: any) => {
|
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
const rightTreeCurrLevelLast: any = {
|
|
70
|
-
title: group
|
|
76
|
+
title: findGroupName(group, rightLevel - 1), // 为空的话,强制设置为 ''
|
|
71
77
|
// 当前层为第一层时,将parent指向左树的根节点,为后续合并做准备
|
|
72
78
|
parent: tempRightTree.title === treeRootName ? leftTree : tempRightTree,
|
|
73
79
|
//
|
|
@@ -106,47 +112,91 @@ export const handleMultiLevelHeader = (leftTree: any, column: any) => {
|
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
// 遍历右树(i 表示右树的层级):
|
|
109
|
-
for (let i = 0; i <= groupLen
|
|
115
|
+
for (let i = 0; i <= groupLen; i += 1) {
|
|
110
116
|
const leftTreeLast = leftTreeLevelMap[i]; // 左树第i层的最后一个
|
|
111
117
|
const current = rightTreeLevelMap[i]; // 右树第 i 层的最后一个(唯一一个)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
if (i === 0) {
|
|
119
|
+
if (!leftTreeLast.children) {
|
|
120
|
+
leftTreeLast.children = [];
|
|
121
|
+
}
|
|
122
|
+
leftTreeLast.children.push(...(current?.children || []));
|
|
123
|
+
} else if (
|
|
124
|
+
current &&
|
|
115
125
|
current?.title === leftTreeLast?.title &&
|
|
116
|
-
|
|
117
|
-
i === 1
|
|
118
|
-
? current?.fixed === leftTreeLast?.fixed
|
|
119
|
-
: true
|
|
126
|
+
current?.fixed === leftTreeLast?.fixed
|
|
120
127
|
) {
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
128
|
+
current.colSpanStart = leftTreeLast?.colSpanStart || leftTreeLast;
|
|
129
|
+
const colSpan = current?.colSpanStart?.colSpan || 1;
|
|
130
|
+
current.colSpanStart.colSpan = colSpan + 1;
|
|
131
|
+
// 被合并的单元格隐藏
|
|
132
|
+
current.className = hiddenHeaderCellClass;
|
|
133
|
+
}
|
|
134
|
+
if (current) {
|
|
135
|
+
current.colSpan = 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
124
140
|
|
|
125
|
-
|
|
141
|
+
// 合并上下相同的分组
|
|
142
|
+
export const handleMergeHeader = <
|
|
143
|
+
T extends {
|
|
144
|
+
title?: string;
|
|
145
|
+
className?: string;
|
|
146
|
+
children?: T[];
|
|
147
|
+
colSpan?: number;
|
|
148
|
+
},
|
|
149
|
+
>(
|
|
150
|
+
columns?: Array<T>,
|
|
151
|
+
) => {
|
|
152
|
+
const getRowSpan = (col: T) => {
|
|
153
|
+
let span = 1;
|
|
154
|
+
const newCol = { ...col };
|
|
155
|
+
let current: T | null = newCol;
|
|
156
|
+
while (current !== null) {
|
|
157
|
+
if (current?.children?.length === 1) {
|
|
158
|
+
const next: T = current.children?.[0];
|
|
126
159
|
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
160
|
+
next.title === col?.title &&
|
|
161
|
+
col?.title &&
|
|
162
|
+
next.className !== hiddenHeaderCellClass &&
|
|
163
|
+
col?.colSpan === next?.colSpan
|
|
130
164
|
) {
|
|
131
|
-
//
|
|
132
|
-
|
|
165
|
+
// 分组名一致,上下合并
|
|
166
|
+
span += 1;
|
|
167
|
+
next.className = hiddenHeaderCellClass;
|
|
168
|
+
current = next;
|
|
133
169
|
} else {
|
|
134
|
-
// 如果不相同,则直接将右树的下一层接入左树的下一层
|
|
135
|
-
if (leftTreeLast?.children) {
|
|
136
|
-
leftTreeLast.children.push(...current.children);
|
|
137
|
-
} else {
|
|
138
|
-
leftTreeLast.children = [...current.children];
|
|
139
|
-
}
|
|
140
|
-
// 退出循环,等待合并下一列右树
|
|
141
170
|
break;
|
|
142
171
|
}
|
|
143
172
|
} else {
|
|
144
|
-
// 当前层组名不同,则直接将右树,并入左树
|
|
145
|
-
leftTreeLast.parent.children.push(current);
|
|
146
173
|
break;
|
|
147
174
|
}
|
|
148
175
|
}
|
|
149
|
-
|
|
176
|
+
return {
|
|
177
|
+
...newCol,
|
|
178
|
+
rowSpan: span,
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
const recursive = (cols: T[]) => {
|
|
182
|
+
return cols.map((col) => {
|
|
183
|
+
if (col?.title) {
|
|
184
|
+
const { rowSpan } = getRowSpan(col);
|
|
185
|
+
if (rowSpan > 1) {
|
|
186
|
+
return {
|
|
187
|
+
...col,
|
|
188
|
+
rowSpan,
|
|
189
|
+
// 重置一下子级,将相同的分组上下合并
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (col.children) {
|
|
194
|
+
col.children = recursive(col.children);
|
|
195
|
+
}
|
|
196
|
+
return col;
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
return recursive(columns || []);
|
|
150
200
|
};
|
|
151
201
|
|
|
152
202
|
export const handleExpandColumn = ({
|
|
@@ -198,7 +248,9 @@ export const EMPTY_ROW_TEMP_KEY_ATTR = '_lxTempKey';
|
|
|
198
248
|
export const LATEST_EMPTY_ROW_FLAG_ATTR = '_latestCreation';
|
|
199
249
|
|
|
200
250
|
export const deleteTempRowProperties = (row: any) => {
|
|
201
|
-
|
|
251
|
+
if (row) {
|
|
252
|
+
delete row[LATEST_EMPTY_ROW_FLAG_ATTR];
|
|
253
|
+
}
|
|
202
254
|
};
|
|
203
255
|
|
|
204
256
|
export const createEmptyRow = () => ({
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export interface DataProps {
|
|
2
|
+
userId: string;
|
|
3
|
+
appId: string;
|
|
4
|
+
compId: string;
|
|
5
|
+
order?: any[];
|
|
6
|
+
selected?: any[];
|
|
7
|
+
save: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// 定义正则表达式
|
|
11
|
+
const PATTERN = /[^?]+/;
|
|
12
|
+
const DBNAME = 'TABLE_CUSTOM';
|
|
13
|
+
const isIE = !!((window as any).ActiveXObject || 'ActiveXObject' in window);
|
|
14
|
+
|
|
15
|
+
const getOrSaveData = (actionData: DataProps) => {
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const pagePatch =
|
|
18
|
+
window.location.hash?.match(PATTERN)?.[0]?.replace(/^#\//, '') || '';
|
|
19
|
+
const pageKey = `${actionData.appId}_${pagePatch}_${actionData.userId}`;
|
|
20
|
+
// 兼容浏览器
|
|
21
|
+
const indexedDB =
|
|
22
|
+
window.indexedDB ||
|
|
23
|
+
(window as any).mozIndexedDB ||
|
|
24
|
+
(window as any).webkitIndexedDB ||
|
|
25
|
+
(window as any).msIndexedDB;
|
|
26
|
+
|
|
27
|
+
if (indexedDB) {
|
|
28
|
+
let version = new Date().getTime();
|
|
29
|
+
if (isIE) {
|
|
30
|
+
// ie上版本号最多支持9位数,做下兼容,取时间戳中间9位
|
|
31
|
+
version = parseInt(version.toString().substring(2, 11), 10);
|
|
32
|
+
}
|
|
33
|
+
// 打开数据库,若没有则会创建
|
|
34
|
+
const request = indexedDB.open(DBNAME, version);
|
|
35
|
+
// 数据库打开成功回调
|
|
36
|
+
request.onsuccess = (event: any) => {
|
|
37
|
+
// console.log('打开数据库成功');
|
|
38
|
+
const db = event.target.result; // 数据库对象
|
|
39
|
+
const transaction = db.transaction([pageKey], 'readwrite');
|
|
40
|
+
const objectStore = transaction.objectStore(pageKey);
|
|
41
|
+
// 保存数据
|
|
42
|
+
if (actionData.save) {
|
|
43
|
+
const actionPut = objectStore.put({
|
|
44
|
+
ORDER: actionData.order,
|
|
45
|
+
SELECTED: actionData.selected,
|
|
46
|
+
id: actionData.compId,
|
|
47
|
+
});
|
|
48
|
+
actionPut.onsuccess = (e: any) => {
|
|
49
|
+
// console.log('数组插入成功');
|
|
50
|
+
db.close();
|
|
51
|
+
};
|
|
52
|
+
actionPut.onerror = () => {
|
|
53
|
+
db.close();
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
// 读取数据
|
|
57
|
+
const action = objectStore.get(actionData.compId);
|
|
58
|
+
action.onsuccess = (e: any) => {
|
|
59
|
+
// 获取对象成功
|
|
60
|
+
resolve(e.target.result);
|
|
61
|
+
db.close();
|
|
62
|
+
};
|
|
63
|
+
action.onerror = () => {
|
|
64
|
+
resolve({});
|
|
65
|
+
db.close();
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
// 数据库打开失败的回调
|
|
70
|
+
request.onerror = (event) => {
|
|
71
|
+
console.log('indexedDB数据库打开报错:', event);
|
|
72
|
+
resolve({});
|
|
73
|
+
};
|
|
74
|
+
request.onupgradeneeded = (event: any) => {
|
|
75
|
+
const db = event.target.result; // 数据库对象
|
|
76
|
+
if (db.objectStoreNames?.length > 100) {
|
|
77
|
+
db.deleteObjectStore(db.objectStoreNames[0]);
|
|
78
|
+
}
|
|
79
|
+
if (!db.objectStoreNames.contains(pageKey)) {
|
|
80
|
+
db.createObjectStore(pageKey, { keyPath: 'id' });
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
} else {
|
|
84
|
+
// 不支持indexDB,就用localStorage存储
|
|
85
|
+
const allData: any = JSON.parse(
|
|
86
|
+
window.localStorage.getItem(DBNAME) || '{}',
|
|
87
|
+
);
|
|
88
|
+
if (actionData.save) {
|
|
89
|
+
// 超过100个就删掉一些
|
|
90
|
+
let allKeys = Object.keys(allData);
|
|
91
|
+
if (allKeys.length > 100) {
|
|
92
|
+
delete allData[allKeys[0]];
|
|
93
|
+
}
|
|
94
|
+
allKeys = Object.keys(allData);
|
|
95
|
+
if (allKeys.includes(pageKey)) {
|
|
96
|
+
const data: any = allData[pageKey];
|
|
97
|
+
data[actionData.compId] = {
|
|
98
|
+
ORDER: actionData.order,
|
|
99
|
+
SELECTED: actionData.selected,
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
allData[pageKey] = {
|
|
103
|
+
[actionData.compId]: {
|
|
104
|
+
ORDER: actionData.order,
|
|
105
|
+
SELECTED: actionData.selected,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
window.localStorage.setItem(DBNAME, JSON.stringify(allData));
|
|
110
|
+
} else if (allData?.[pageKey]?.[actionData.compId]) {
|
|
111
|
+
resolve(allData[pageKey][actionData.compId]);
|
|
112
|
+
} else {
|
|
113
|
+
resolve({});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { getOrSaveData };
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
useListenProps,
|
|
14
14
|
} from '../utils';
|
|
15
15
|
import CustomModule from '../utils/CustomModule';
|
|
16
|
-
import
|
|
16
|
+
import EmptyComp from '../utils/Empty';
|
|
17
17
|
import { useFuncExpExecute } from '../utils/hooks/useFuncExpExecute';
|
|
18
18
|
import { useLocale } from '../utils/hooks/useLocale';
|
|
19
19
|
|
|
@@ -131,7 +131,8 @@ const MyTransfer = LingxiForwardRef<any, MyTransferProps>((props, ref) => {
|
|
|
131
131
|
...restProps
|
|
132
132
|
} = props;
|
|
133
133
|
|
|
134
|
-
const { sandBoxSafeRun, sandBoxLoadModule } =
|
|
134
|
+
const { sandBoxSafeRun, sandBoxLoadModule, dataState } =
|
|
135
|
+
getEngineApis() || {};
|
|
135
136
|
|
|
136
137
|
const { getLocale, lang } = useLocale(getEngineApis());
|
|
137
138
|
|
|
@@ -548,7 +549,11 @@ const MyTransfer = LingxiForwardRef<any, MyTransferProps>((props, ref) => {
|
|
|
548
549
|
}
|
|
549
550
|
return (
|
|
550
551
|
<Table
|
|
551
|
-
locale={
|
|
552
|
+
locale={{
|
|
553
|
+
emptyText: (
|
|
554
|
+
<EmptyComp dataState={dataState} getLocale={getLocale} />
|
|
555
|
+
),
|
|
556
|
+
}}
|
|
552
557
|
columns={finalColumns}
|
|
553
558
|
dataSource={currentDataSource}
|
|
554
559
|
rowKey={`${uid}`}
|
|
@@ -224,9 +224,12 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
|
|
|
224
224
|
setSelectAll(_flag: boolean) {
|
|
225
225
|
setIsSelectAll(_flag);
|
|
226
226
|
},
|
|
227
|
-
setSelectedKeys(keys: any[]) {
|
|
227
|
+
setSelectedKeys(keys: any[] | string) {
|
|
228
228
|
if (Array.isArray(keys)) {
|
|
229
229
|
setSelectedKeys(keys);
|
|
230
|
+
} else {
|
|
231
|
+
// 兼容浩鲸E之前版本设置选中数据
|
|
232
|
+
setSelectedKeys([keys]);
|
|
230
233
|
}
|
|
231
234
|
},
|
|
232
235
|
setRightMenuData(rightInfo: any) {
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
useCommonImperativeHandle,
|
|
10
10
|
useListenProps,
|
|
11
11
|
} from '../utils';
|
|
12
|
+
import EmptyComp from '../utils/Empty';
|
|
13
|
+
import { useLocale } from '../utils/hooks/useLocale';
|
|
12
14
|
import { flattenTreeData, renderCommonList } from '../utils/renderReadOnly';
|
|
13
15
|
|
|
14
16
|
const { TreeNode } = TreeSelect;
|
|
@@ -136,7 +138,7 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
136
138
|
|
|
137
139
|
const engineApis = getEngineApis?.() || {};
|
|
138
140
|
|
|
139
|
-
const { onlySyncValue } = engineApis;
|
|
141
|
+
const { onlySyncValue, dataState } = engineApis;
|
|
140
142
|
|
|
141
143
|
// 加载数据字段映射
|
|
142
144
|
const [treeService, setTreeService] = useListenProps(props.treeService);
|
|
@@ -153,6 +155,8 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
153
155
|
// 用来记录当前展开的key,节点展开事件中以获取展开的节点
|
|
154
156
|
const [expandedKeys, setExpandedKeys] = useState<any[]>([]);
|
|
155
157
|
|
|
158
|
+
const { getLocale } = useLocale(engineApis);
|
|
159
|
+
|
|
156
160
|
const { formFieldsRef, required, readOnly, disabled, finalRules } =
|
|
157
161
|
useCommonImperativeHandle(ref, props, {
|
|
158
162
|
get dataSource() {
|
|
@@ -610,6 +614,13 @@ const MyTreeSelect = LingxiForwardRef<any, MyTreeSelectProps>((props, ref) => {
|
|
|
610
614
|
}
|
|
611
615
|
resetSelectAll();
|
|
612
616
|
}}
|
|
617
|
+
notFoundContent={
|
|
618
|
+
<EmptyComp
|
|
619
|
+
getLocale={getLocale}
|
|
620
|
+
dataState={dataState}
|
|
621
|
+
clsName="pcfactory-empty-small"
|
|
622
|
+
/>
|
|
623
|
+
}
|
|
613
624
|
onTreeExpand={(keys) => {
|
|
614
625
|
setExpandedKeys(keys);
|
|
615
626
|
// 展开的时候触发
|