@lingxiteam/ebe-utils 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/pcpublic/src/components/pcfactory/src/Table/BodyCell/index.tsx +17 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/EditComponent/index.tsx +12 -7
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Thumbnail/index.tsx +284 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/index.tsx +37 -1
- package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/SingleBtn.tsx +120 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/index.tsx +436 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/TableHead/index.tsx +64 -47
- package/lib/pcpublic/src/components/pcfactory/src/Table/assets/placeholder.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/constant.ts +1 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +17 -3
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +141 -522
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useExpandable.tsx +42 -3
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFilter.tsx +3 -2
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFormatCell.tsx +326 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowEdit.ts +13 -7
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowMerge.ts +9 -4
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSort.ts +5 -2
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +21 -8
- package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +3 -2
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/OperationCell.d.ts +38 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/bodyCell.d.ts +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/contentStyle.d.ts +4 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +14 -9
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Table.less +138 -14
- package/package.json +2 -2
|
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import CommIconEG from '../../Icon';
|
|
3
3
|
import { handleIsValidIconCfg } from '../../Icon/hooks';
|
|
4
4
|
import CommIconED from '../../Icon/IconED';
|
|
5
|
+
import { useUpdateEffect } from '../../utils/ahooks';
|
|
5
6
|
import { useLocale } from '../../utils/hooks/useLocale';
|
|
6
7
|
|
|
7
8
|
const useExpandable = (expandCfg: any, isED?: boolean) => {
|
|
@@ -34,6 +35,7 @@ const useExpandable = (expandCfg: any, isED?: boolean) => {
|
|
|
34
35
|
|
|
35
36
|
const hasExpandContent =
|
|
36
37
|
Array.isArray(expandComponents) && expandComponents.length;
|
|
38
|
+
const [isExpandAllRows, setIsExpandAllRows] = useState<boolean>();
|
|
37
39
|
const [expandedRowKeys, setExpandedRowKeys] = useState(() => {
|
|
38
40
|
if (!defaultExpandAllRows && defaultExpandedRowKeys) {
|
|
39
41
|
try {
|
|
@@ -306,18 +308,55 @@ const useExpandable = (expandCfg: any, isED?: boolean) => {
|
|
|
306
308
|
return currPageRowKeys || [];
|
|
307
309
|
};
|
|
308
310
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (innerDataSource.length && defaultExpandAllRows) {
|
|
311
|
+
const expandAllDataSource = () => {
|
|
312
|
+
if (innerDataSource.length) {
|
|
312
313
|
const currPageRowKeys = handleAllExpandRowKeys(innerDataSource);
|
|
313
314
|
setExpandedRowKeys(currPageRowKeys);
|
|
314
315
|
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
useEffect(() => {
|
|
319
|
+
// 设置了全部展开,则展开当前页所有行
|
|
320
|
+
if (isExpandAllRows) {
|
|
321
|
+
expandAllDataSource();
|
|
322
|
+
}
|
|
315
323
|
}, [innerDataSource]);
|
|
316
324
|
|
|
325
|
+
// 全部展开属性可绑定数据源变动
|
|
326
|
+
useEffect(() => {
|
|
327
|
+
setIsExpandAllRows(defaultExpandAllRows);
|
|
328
|
+
}, [defaultExpandAllRows]);
|
|
329
|
+
|
|
330
|
+
// 展开/收起方法
|
|
331
|
+
const setExpanded = () => {
|
|
332
|
+
if (!isExpandAllRows) {
|
|
333
|
+
setExpandedRowKeys([]);
|
|
334
|
+
} else if (isExpandAllRows) {
|
|
335
|
+
expandAllDataSource();
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// 表格全部展开/收起动作调用该方法
|
|
340
|
+
const expandTableData = (isExpanded: boolean | 'toggle') => {
|
|
341
|
+
const isExpand =
|
|
342
|
+
isExpanded === 'toggle' ? !isExpandAllRows : Boolean(isExpanded);
|
|
343
|
+
setIsExpandAllRows(isExpand);
|
|
344
|
+
|
|
345
|
+
// 当传入的状态与以前一致时,不触发下面的useEffect,手动调一下方法
|
|
346
|
+
if (isExpand === isExpandAllRows) {
|
|
347
|
+
setExpanded();
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
useUpdateEffect(() => {
|
|
352
|
+
setExpanded();
|
|
353
|
+
}, [isExpandAllRows]);
|
|
354
|
+
|
|
317
355
|
return {
|
|
318
356
|
expandable,
|
|
319
357
|
childrenColumnName: realChildrenColumnName,
|
|
320
358
|
setChildrenColumnName,
|
|
359
|
+
expandTableData,
|
|
321
360
|
};
|
|
322
361
|
};
|
|
323
362
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/no-danger-with-children */
|
|
2
2
|
import { Button, Checkbox } from 'antd';
|
|
3
3
|
import { FilterDropdownProps } from 'antd/lib/table/interface';
|
|
4
|
+
import _ from 'lodash';
|
|
4
5
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
6
|
|
|
6
7
|
const useFilter = (props: any) => {
|
|
@@ -79,7 +80,7 @@ const useFilter = (props: any) => {
|
|
|
79
80
|
const originDataMap: any = {};
|
|
80
81
|
let prevTdInfo: any = null;
|
|
81
82
|
innerDataSource.forEach((d: any) => {
|
|
82
|
-
originDataMap[d[rowKey]] = d
|
|
83
|
+
originDataMap[d[rowKey]] = _.get(d, dataIndex);
|
|
83
84
|
// 由于表格存在单元格渲染和自定义渲染的情况,所以筛选列表从td元素获取innerText作为最终展示
|
|
84
85
|
let td: any = tableDom?.querySelector(
|
|
85
86
|
`tr[data-row-key='${d[rowKey]}'] > td[td-dataIndex='${dataIndex}']`,
|
|
@@ -148,7 +149,7 @@ const useFilter = (props: any) => {
|
|
|
148
149
|
const rowKeys = currentFilter[k]?.rowKeyList.filter(
|
|
149
150
|
(rowKey: string) => {
|
|
150
151
|
return Object.keys(filters || {}).every((dataKey: string) => {
|
|
151
|
-
if (dataKey !== dataIndex) {
|
|
152
|
+
if (dataKey !== `${dataIndex}`) {
|
|
152
153
|
const v = filters[dataKey];
|
|
153
154
|
if (v?.length) {
|
|
154
155
|
const rowVal =
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { message } from 'antd';
|
|
2
|
+
import CustomModule from '../../utils/CustomModule';
|
|
3
|
+
import type { FuncExpExeCuteType } from '../../utils/hooks/useFuncExpExecute';
|
|
4
|
+
import {
|
|
5
|
+
CUSTOM,
|
|
6
|
+
DOWNLOAD_FILE,
|
|
7
|
+
OPEN_MODAL,
|
|
8
|
+
PAGE_JUMP,
|
|
9
|
+
PREVIEW_FILE,
|
|
10
|
+
ROUTE_PUSH,
|
|
11
|
+
ROUTE_REPLACE,
|
|
12
|
+
} from '../constant';
|
|
13
|
+
import type { ContentClick, FuncCode } from '../types/contentStyle';
|
|
14
|
+
|
|
15
|
+
interface useFormatCellProps extends ContentClick {
|
|
16
|
+
appId: string;
|
|
17
|
+
pageId: string;
|
|
18
|
+
modalHeight?: number;
|
|
19
|
+
modalWidth?: number;
|
|
20
|
+
funcExpExecute?: FuncExpExeCuteType;
|
|
21
|
+
engineApis: any;
|
|
22
|
+
$$componentItemId: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const useFormatCell = (props: useFormatCellProps) => {
|
|
26
|
+
const {
|
|
27
|
+
funcExpExecute,
|
|
28
|
+
engineApis,
|
|
29
|
+
appId,
|
|
30
|
+
pageId,
|
|
31
|
+
content,
|
|
32
|
+
clickType,
|
|
33
|
+
page,
|
|
34
|
+
modal,
|
|
35
|
+
openType,
|
|
36
|
+
fileIds,
|
|
37
|
+
filename,
|
|
38
|
+
previewType,
|
|
39
|
+
downloadUrl,
|
|
40
|
+
modalHeight,
|
|
41
|
+
modalWidth,
|
|
42
|
+
$$componentItemId,
|
|
43
|
+
} = props;
|
|
44
|
+
|
|
45
|
+
const realAppId = appId;
|
|
46
|
+
const realPageId = pageId;
|
|
47
|
+
|
|
48
|
+
const handleCellContent = (row: any, rowIndex: number, rowText?: any) => {
|
|
49
|
+
if ((content as FuncCode)?.jsx) {
|
|
50
|
+
return (
|
|
51
|
+
<div>
|
|
52
|
+
<CustomModule
|
|
53
|
+
code={(content as FuncCode)?.code}
|
|
54
|
+
sandBoxLoadModule={engineApis.sandBoxLoadModule}
|
|
55
|
+
compProps={{ text: rowText, item: row, index: rowIndex }}
|
|
56
|
+
errorInfo={{
|
|
57
|
+
id: $$componentItemId,
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if ((content as FuncCode)?.code && funcExpExecute) {
|
|
64
|
+
return funcExpExecute((content as FuncCode).code, [
|
|
65
|
+
{
|
|
66
|
+
key: 'row',
|
|
67
|
+
value: row,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: 'index',
|
|
71
|
+
value: rowIndex,
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return content;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const handlePageJump = async (
|
|
80
|
+
row: any,
|
|
81
|
+
rowId: string | number,
|
|
82
|
+
rowIndex: number,
|
|
83
|
+
) => {
|
|
84
|
+
if (page) {
|
|
85
|
+
const { pagePath, searchParams = {} } = page;
|
|
86
|
+
const newSearchParams: any = {};
|
|
87
|
+
|
|
88
|
+
Object.keys(searchParams).forEach((key) => {
|
|
89
|
+
if (typeof searchParams[key] === 'string') {
|
|
90
|
+
const exp = searchParams[key];
|
|
91
|
+
searchParams[key] = (
|
|
92
|
+
row: any,
|
|
93
|
+
rowId: string | number,
|
|
94
|
+
index: number,
|
|
95
|
+
) =>
|
|
96
|
+
engineApis?.sandBoxSafeRun(exp, {
|
|
97
|
+
row,
|
|
98
|
+
rowId,
|
|
99
|
+
index,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (typeof searchParams[key] === 'function') {
|
|
104
|
+
try {
|
|
105
|
+
newSearchParams[key] = searchParams[key](row, rowId, rowIndex);
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.error(e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
let newPath = pagePath || '';
|
|
113
|
+
Object.keys(newSearchParams).forEach((key) => {
|
|
114
|
+
if (!newPath.includes(`${key}=`)) {
|
|
115
|
+
newPath += `${newPath.includes('?') ? '&' : '?'}${key}=${
|
|
116
|
+
newSearchParams[key]
|
|
117
|
+
}`;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
switch (openType) {
|
|
122
|
+
case ROUTE_PUSH:
|
|
123
|
+
if (typeof engineApis?.historyPush === 'function') {
|
|
124
|
+
engineApis.historyPush(newPath);
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case ROUTE_REPLACE:
|
|
128
|
+
if (typeof engineApis?.historyReplace === 'function') {
|
|
129
|
+
engineApis.historyReplace(newPath);
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const handleOpenModal = async (
|
|
139
|
+
row: any,
|
|
140
|
+
rowId: string | number,
|
|
141
|
+
rowIndex: number,
|
|
142
|
+
) => {
|
|
143
|
+
if (modal) {
|
|
144
|
+
const { pageId, compStates = {} } = modal;
|
|
145
|
+
|
|
146
|
+
const newCompStates: any = {};
|
|
147
|
+
Object.keys(compStates).forEach((key) => {
|
|
148
|
+
if (typeof compStates[key] === 'string') {
|
|
149
|
+
const exp = compStates[key];
|
|
150
|
+
compStates[key] = (row: any, rowId: string | number, index: number) =>
|
|
151
|
+
engineApis?.sandBoxSafeRun(exp, {
|
|
152
|
+
row,
|
|
153
|
+
rowId,
|
|
154
|
+
index,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (typeof compStates[key] === 'function') {
|
|
159
|
+
try {
|
|
160
|
+
newCompStates[key] = compStates[key](row, rowId, rowIndex);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
console.error(e);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
if (engineApis?.openModal) {
|
|
168
|
+
engineApis.openModal({
|
|
169
|
+
pageId,
|
|
170
|
+
params: newCompStates,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const handleDownloadFile = async (row: any, rowIndex: number) => {
|
|
177
|
+
if (typeof engineApis?.batchDownloadFileByIds === 'function') {
|
|
178
|
+
try {
|
|
179
|
+
let realFilename = filename;
|
|
180
|
+
let realFileIds = fileIds;
|
|
181
|
+
|
|
182
|
+
if ((filename as FuncCode)?.code && funcExpExecute) {
|
|
183
|
+
realFilename = funcExpExecute((filename as FuncCode).code, [
|
|
184
|
+
{
|
|
185
|
+
key: 'row',
|
|
186
|
+
value: row,
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
key: 'index',
|
|
190
|
+
value: rowIndex,
|
|
191
|
+
},
|
|
192
|
+
]);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if ((fileIds as FuncCode)?.code && funcExpExecute) {
|
|
196
|
+
realFileIds = funcExpExecute((fileIds as FuncCode).code, [
|
|
197
|
+
{
|
|
198
|
+
key: 'row',
|
|
199
|
+
value: row,
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
key: 'index',
|
|
203
|
+
value: rowIndex,
|
|
204
|
+
},
|
|
205
|
+
]);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
realFileIds = Array.isArray(realFileIds) ? realFileIds[0] : realFileIds;
|
|
209
|
+
|
|
210
|
+
engineApis.batchDownloadFileByIds({
|
|
211
|
+
fileIds: realFileIds,
|
|
212
|
+
newFileName: realFilename,
|
|
213
|
+
onError: (errorMessage: string) => {
|
|
214
|
+
message.error(errorMessage);
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
} catch (e) {
|
|
218
|
+
console.error(e);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const handlePreviewFile = async (row: any, rowIndex: number) => {
|
|
224
|
+
let realFileIds: any = fileIds;
|
|
225
|
+
|
|
226
|
+
if ((fileIds as FuncCode)?.code && funcExpExecute) {
|
|
227
|
+
realFileIds = funcExpExecute((fileIds as FuncCode).code, [
|
|
228
|
+
{
|
|
229
|
+
key: 'row',
|
|
230
|
+
value: row,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
key: 'index',
|
|
234
|
+
value: rowIndex,
|
|
235
|
+
},
|
|
236
|
+
]);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (typeof engineApis?.BannerModal?.open === 'function') {
|
|
240
|
+
// 弹窗预览
|
|
241
|
+
realFileIds =
|
|
242
|
+
typeof realFileIds === 'string' ? [realFileIds] : realFileIds;
|
|
243
|
+
const fileList = realFileIds.map((fileId: string | number) => {
|
|
244
|
+
return {
|
|
245
|
+
fileId,
|
|
246
|
+
file: {
|
|
247
|
+
fileId,
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
engineApis.BannerModal.open({
|
|
252
|
+
fileIndex: 0,
|
|
253
|
+
fileList,
|
|
254
|
+
viewMode: previewType,
|
|
255
|
+
modalHeight,
|
|
256
|
+
pageId: realPageId,
|
|
257
|
+
appId: realAppId,
|
|
258
|
+
modalWidth,
|
|
259
|
+
});
|
|
260
|
+
} else if (
|
|
261
|
+
previewType !== undefined &&
|
|
262
|
+
typeof engineApis?.previewFile === 'function'
|
|
263
|
+
) {
|
|
264
|
+
// 新窗口预览
|
|
265
|
+
realFileIds = Array.isArray(realFileIds) ? realFileIds[0] : realFileIds;
|
|
266
|
+
try {
|
|
267
|
+
engineApis.previewFile({
|
|
268
|
+
fileId: realFileIds,
|
|
269
|
+
appId: realAppId,
|
|
270
|
+
pageId: realPageId,
|
|
271
|
+
});
|
|
272
|
+
} catch (e) {
|
|
273
|
+
console.error(e);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
const onCellClick = async (
|
|
279
|
+
row: any,
|
|
280
|
+
rowId: string | number,
|
|
281
|
+
rowIndex: number,
|
|
282
|
+
) => {
|
|
283
|
+
switch (clickType) {
|
|
284
|
+
case PAGE_JUMP:
|
|
285
|
+
handlePageJump(row, rowId, rowIndex);
|
|
286
|
+
break;
|
|
287
|
+
case OPEN_MODAL:
|
|
288
|
+
handleOpenModal(row, rowId, rowIndex);
|
|
289
|
+
break;
|
|
290
|
+
case DOWNLOAD_FILE:
|
|
291
|
+
handleDownloadFile(row, rowIndex);
|
|
292
|
+
break;
|
|
293
|
+
case PREVIEW_FILE:
|
|
294
|
+
handlePreviewFile(row, rowIndex);
|
|
295
|
+
break;
|
|
296
|
+
case CUSTOM: {
|
|
297
|
+
let realDownloadUrl: any = downloadUrl;
|
|
298
|
+
|
|
299
|
+
if ((downloadUrl as FuncCode)?.code && funcExpExecute) {
|
|
300
|
+
realDownloadUrl = funcExpExecute((downloadUrl as FuncCode).code, [
|
|
301
|
+
{
|
|
302
|
+
key: 'row',
|
|
303
|
+
value: row,
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
key: 'index',
|
|
307
|
+
value: rowIndex,
|
|
308
|
+
},
|
|
309
|
+
]);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
window.open(realDownloadUrl, openType);
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
default:
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
return {
|
|
321
|
+
onCellClick,
|
|
322
|
+
handleCellContent,
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export default useFormatCell;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
import { useState } from 'react';
|
|
2
3
|
import { EDIT_COMPONENT_STOP_PROPAGATION_CLS } from '../constant';
|
|
3
4
|
import {
|
|
@@ -61,16 +62,20 @@ const useRowEdit = (props: any) => {
|
|
|
61
62
|
const trow: any = innerDataSource.find(
|
|
62
63
|
(i: any) => i[currentRowKey] === nowInlineEditKey,
|
|
63
64
|
);
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
if (trow) {
|
|
66
|
+
Object.assign(trow, nowEditingData);
|
|
67
|
+
deleteTempRowProperties(trow);
|
|
68
|
+
}
|
|
66
69
|
|
|
67
70
|
if (!tableUpdateInnerDataSource) {
|
|
68
71
|
// 单行保存编辑时,需要将修改后的值同步到绑定的数据源
|
|
69
72
|
const syncPropsDataSourceRow = props.dataSource?.find(
|
|
70
73
|
(r: any) => r[currentRowKey] === nowInlineEditKey,
|
|
71
74
|
);
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
if (syncPropsDataSourceRow) {
|
|
76
|
+
Object.assign(syncPropsDataSourceRow, nowEditingData);
|
|
77
|
+
deleteTempRowProperties(syncPropsDataSourceRow);
|
|
78
|
+
}
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
setInnerDataSource([...innerDataSource]);
|
|
@@ -204,8 +209,9 @@ const useRowEdit = (props: any) => {
|
|
|
204
209
|
);
|
|
205
210
|
}
|
|
206
211
|
|
|
207
|
-
|
|
208
|
-
|
|
212
|
+
// 兼容attr(表格的dataIndex)为层级的情况
|
|
213
|
+
_.set(editRow, attr, newAttrVal);
|
|
214
|
+
_.set(syncPropsDataSourceRow, attr, newAttrVal);
|
|
209
215
|
|
|
210
216
|
Object.keys(otherAttrVals).forEach((op) => {
|
|
211
217
|
editRow[op] = otherAttrVals[op];
|
|
@@ -215,7 +221,7 @@ const useRowEdit = (props: any) => {
|
|
|
215
221
|
return;
|
|
216
222
|
}
|
|
217
223
|
|
|
218
|
-
nowEditingData
|
|
224
|
+
_.set(nowEditingData, attr, newAttrVal);
|
|
219
225
|
Object.keys(otherAttrVals).forEach((op) => {
|
|
220
226
|
nowEditingData[op] = otherAttrVals[op];
|
|
221
227
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
import { useMemo } from 'react';
|
|
2
3
|
|
|
3
4
|
const useRowMerge = (props: any) => {
|
|
4
|
-
const {
|
|
5
|
+
const { currentPageDataSource, columns, nowInlineEditKey, currentRowKey } =
|
|
6
|
+
props;
|
|
5
7
|
|
|
6
8
|
// 记录所有设置了行合并的列
|
|
7
9
|
const rowSpanColMap = useMemo(() => {
|
|
@@ -51,8 +53,10 @@ const useRowMerge = (props: any) => {
|
|
|
51
53
|
};
|
|
52
54
|
} else {
|
|
53
55
|
const { preIndex, row } = parentSpanRowsMap[rowIndex];
|
|
56
|
+
// 兼容层级表格场景
|
|
57
|
+
const path = rowIndex.split(',');
|
|
54
58
|
// 当且仅当相邻行内容相同时才进行合并,否则把之前的主行换成当前行
|
|
55
|
-
if (preIndex === i - 1 && row
|
|
59
|
+
if (preIndex === i - 1 && _.get(row, path) === _.get(newD, path)) {
|
|
56
60
|
const curRowSpan = tableRowSpan.get(row);
|
|
57
61
|
curRowSpan[rowIndex] += 1;
|
|
58
62
|
// 合并当前行
|
|
@@ -75,13 +79,14 @@ const useRowMerge = (props: any) => {
|
|
|
75
79
|
});
|
|
76
80
|
return newData;
|
|
77
81
|
};
|
|
78
|
-
|
|
82
|
+
// 仅合并当前页的数据
|
|
83
|
+
recursiveSet(currentPageDataSource);
|
|
79
84
|
// // loading没有数据的时候模拟3个数据
|
|
80
85
|
// if(loading && d?.length === 0) {
|
|
81
86
|
// d = [{}, {}, {}];
|
|
82
87
|
// }
|
|
83
88
|
return [tableRowSpan, tableRowClass];
|
|
84
|
-
}, [
|
|
89
|
+
}, [currentPageDataSource, rowSpanColMap, nowInlineEditKey, currentRowKey]);
|
|
85
90
|
|
|
86
91
|
return {
|
|
87
92
|
rowSpanColMap,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
import { useMemo, useState } from 'react';
|
|
2
3
|
import { compareFn } from '../utils';
|
|
3
4
|
|
|
@@ -21,10 +22,12 @@ const useSort = (props: any) => {
|
|
|
21
22
|
return innerDataSource;
|
|
22
23
|
}
|
|
23
24
|
return [...innerDataSource].sort((a, b) => {
|
|
25
|
+
const prev = _.get(a, sortOrder?.field);
|
|
26
|
+
const next = _.get(b, sortOrder?.field);
|
|
24
27
|
if (sortOrder?.order === 'ascend') {
|
|
25
|
-
return compareFn(
|
|
28
|
+
return compareFn(prev, next);
|
|
26
29
|
}
|
|
27
|
-
return compareFn(
|
|
30
|
+
return compareFn(next, prev);
|
|
28
31
|
});
|
|
29
32
|
}, [innerDataSource, sortOrder]);
|
|
30
33
|
|
|
@@ -16,7 +16,7 @@ export type ColItem = {
|
|
|
16
16
|
|
|
17
17
|
export type Column = {
|
|
18
18
|
key?: string;
|
|
19
|
-
dataIndex: string;
|
|
19
|
+
dataIndex: string | string[];
|
|
20
20
|
type?: 'orderCol' | 'dynamicCol';
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -52,7 +52,7 @@ const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
|
52
52
|
};
|
|
53
53
|
}, [summaryConfig]);
|
|
54
54
|
|
|
55
|
-
//
|
|
55
|
+
// 拉平后真实的字段columns
|
|
56
56
|
const fieldColumns = useMemo(() => {
|
|
57
57
|
const colList: typeof columns = [];
|
|
58
58
|
const recursive = (arr: typeof columns) => {
|
|
@@ -165,7 +165,7 @@ const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
|
165
165
|
// 合并分组
|
|
166
166
|
col.push(item);
|
|
167
167
|
}
|
|
168
|
-
item?.dataIndexList?.push?.(dataIndex);
|
|
168
|
+
item?.dataIndexList?.push?.(`${dataIndex}`);
|
|
169
169
|
item.colSpan = (item.colSpan || 0) + 1;
|
|
170
170
|
if (item.colSpan > 1) {
|
|
171
171
|
item.align = 'center';
|
|
@@ -182,13 +182,26 @@ const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
const dataMap: Record<string, any[]> = {};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
const recursiveCollectValueByDataIndex = (
|
|
186
|
+
row: Record<string, any>,
|
|
187
|
+
keyPath: string[] = [],
|
|
188
|
+
) => {
|
|
189
|
+
Object.keys(row || {}).forEach((key: string) => {
|
|
190
|
+
const dataIndex = [...keyPath, key];
|
|
191
|
+
if (!dataMap[`${dataIndex}`]) {
|
|
192
|
+
dataMap[`${dataIndex}`] = [];
|
|
193
|
+
}
|
|
194
|
+
const val = row[key];
|
|
195
|
+
if (typeof val === 'object' && !Array.isArray(val)) {
|
|
196
|
+
// 存在层级对象,继续收集下层的值列表
|
|
197
|
+
recursiveCollectValueByDataIndex(val, dataIndex);
|
|
189
198
|
}
|
|
190
|
-
dataMap[
|
|
199
|
+
dataMap[`${dataIndex}`].push(val);
|
|
191
200
|
});
|
|
201
|
+
};
|
|
202
|
+
// 收集每个dataIndex
|
|
203
|
+
dataSource?.forEach((v) => {
|
|
204
|
+
recursiveCollectValueByDataIndex(v as Record<string, any>);
|
|
192
205
|
});
|
|
193
206
|
return col.map((c) => {
|
|
194
207
|
const { operateType, dataIndexList = [] } = c;
|
|
@@ -150,7 +150,7 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
|
|
|
150
150
|
innerDataSource: filterDataSource,
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
-
const { expandable: realExpandable } = useExpandable({
|
|
153
|
+
const { expandable: realExpandable, expandTableData } = useExpandable({
|
|
154
154
|
...props,
|
|
155
155
|
dataSource: sortDataSource,
|
|
156
156
|
currentRowKey,
|
|
@@ -216,7 +216,7 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
|
|
|
216
216
|
|
|
217
217
|
const { rowSpanColMap, rowSpanMap, rowClassMap } = useRowMerge({
|
|
218
218
|
...props,
|
|
219
|
-
|
|
219
|
+
currentPageDataSource,
|
|
220
220
|
nowInlineEditKey,
|
|
221
221
|
currentRowKey,
|
|
222
222
|
});
|
|
@@ -254,6 +254,7 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
|
|
|
254
254
|
onRowSaveClick,
|
|
255
255
|
loadPrint,
|
|
256
256
|
engineApis,
|
|
257
|
+
expandTableData,
|
|
257
258
|
});
|
|
258
259
|
|
|
259
260
|
// 根据id获取真实的下标,避免过滤和排序后影响下标
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LocaleFunction } from '@lingxiteam/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
export interface OperationCellProps {
|
|
5
|
+
row: any;
|
|
6
|
+
currentRowKey: string;
|
|
7
|
+
isNowEditRow: boolean;
|
|
8
|
+
extendNum: number;
|
|
9
|
+
engineApis: any;
|
|
10
|
+
getRealIndexById: (id: string | number) => number;
|
|
11
|
+
getRealRowActions: (row: any, index: number | null) => any[];
|
|
12
|
+
getRealExtendRowActions: (row: any, index: number | null) => any[];
|
|
13
|
+
onRowDeleteClick: (row: any, index: number | null) => void;
|
|
14
|
+
onRowSaveClick: (row: any, index: number | null, isForce: any) => void;
|
|
15
|
+
onRowDetailClick: (row: any, index: number | null) => void;
|
|
16
|
+
onRowEditClick: (row: any, index: number | null) => void;
|
|
17
|
+
onRowCancelClick: (row: any) => void;
|
|
18
|
+
getLocale: LocaleFunction;
|
|
19
|
+
actionsMap: any;
|
|
20
|
+
fixedAction?: boolean;
|
|
21
|
+
isSmallPopover: boolean;
|
|
22
|
+
tableRef: any;
|
|
23
|
+
$$componentItem: any;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SingleBtnProps {
|
|
27
|
+
onDeleteClick: (e: any) => void;
|
|
28
|
+
onBtnClick: (e: any) => void;
|
|
29
|
+
getLocale: LocaleFunction;
|
|
30
|
+
actionsMap: any;
|
|
31
|
+
setMorePopVisible: (vis: boolean) => void;
|
|
32
|
+
BtnIcon?: React.ReactElement;
|
|
33
|
+
c: any;
|
|
34
|
+
idx: number;
|
|
35
|
+
defaultBtnList: any[];
|
|
36
|
+
isPopover?: boolean;
|
|
37
|
+
popconfirmPlacement: 'top' | 'topRight';
|
|
38
|
+
}
|
|
@@ -14,6 +14,7 @@ interface Modal {
|
|
|
14
14
|
export interface FuncCode {
|
|
15
15
|
code: string;
|
|
16
16
|
originCode: string;
|
|
17
|
+
jsx?: any;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
type DataBindType = FuncCode | string | undefined;
|
|
@@ -38,4 +39,7 @@ export interface ContentStyle extends ContentClick {
|
|
|
38
39
|
backgroundColor: string;
|
|
39
40
|
modalWidth?: number;
|
|
40
41
|
modalHeight?: number;
|
|
42
|
+
imgMaxNum?: number;
|
|
43
|
+
imgSize?: number;
|
|
44
|
+
field?: string;
|
|
41
45
|
}
|