@lingxiteam/ebe-utils 0.1.17 → 0.1.18
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
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { CloseOutlined, SaveOutlined } from '@ant-design/icons';
|
|
2
|
+
import { Icon as LegacyIcon } from '@lingxiteam/icons';
|
|
3
|
+
import { Button, Divider, Popconfirm, Popover, Tooltip } from 'antd';
|
|
4
|
+
import React, { Fragment, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import CommIcon from '../../Icon';
|
|
6
|
+
import type { OperationCellProps } from '../types/OperationCell';
|
|
7
|
+
import SingleBtn from './SingleBtn';
|
|
8
|
+
|
|
9
|
+
// 操作列
|
|
10
|
+
const OperationCell = (props: OperationCellProps) => {
|
|
11
|
+
const {
|
|
12
|
+
row,
|
|
13
|
+
currentRowKey,
|
|
14
|
+
isNowEditRow,
|
|
15
|
+
extendNum,
|
|
16
|
+
engineApis,
|
|
17
|
+
getRealIndexById,
|
|
18
|
+
getRealRowActions,
|
|
19
|
+
getRealExtendRowActions,
|
|
20
|
+
onRowDeleteClick,
|
|
21
|
+
onRowSaveClick,
|
|
22
|
+
onRowDetailClick,
|
|
23
|
+
onRowEditClick,
|
|
24
|
+
getLocale,
|
|
25
|
+
onRowCancelClick,
|
|
26
|
+
actionsMap,
|
|
27
|
+
fixedAction,
|
|
28
|
+
isSmallPopover,
|
|
29
|
+
tableRef,
|
|
30
|
+
} = props;
|
|
31
|
+
const [morePopVisible, setMorePopVisible] = useState<boolean>(false); // 更多操作按钮气泡卡片显隐
|
|
32
|
+
const timerRef = useRef<any>();
|
|
33
|
+
|
|
34
|
+
const { showBuiltInBtns, showExtendBtns, moreBuiltInBtns, moreExtendBtns } =
|
|
35
|
+
useMemo(() => {
|
|
36
|
+
// 过滤掉隐藏的按钮,得到真正的内置的默认按钮数据(详情、编辑、删除)
|
|
37
|
+
const builtInBtns = getRealRowActions(
|
|
38
|
+
row,
|
|
39
|
+
getRealIndexById(row[currentRowKey]),
|
|
40
|
+
);
|
|
41
|
+
// 过滤掉隐藏的扩展按钮,得到真正的扩展按钮数据
|
|
42
|
+
const extendBtns = getRealExtendRowActions(
|
|
43
|
+
row,
|
|
44
|
+
getRealIndexById(row[currentRowKey]),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const allBtns = [...builtInBtns, ...extendBtns]?.filter(
|
|
48
|
+
(btn) => btn?.checked !== false,
|
|
49
|
+
); // 只展示选中的按钮;
|
|
50
|
+
|
|
51
|
+
let showBtns: any[] = [];
|
|
52
|
+
let moreBtns: any[] = [];
|
|
53
|
+
|
|
54
|
+
// 当按钮数量超过 设置最大展示的数量两个时,超过的两个及以上部分放到更多中
|
|
55
|
+
const allBtnsLen = allBtns?.length;
|
|
56
|
+
if (allBtnsLen > extendNum) {
|
|
57
|
+
showBtns = allBtns.slice(0, extendNum - 1);
|
|
58
|
+
moreBtns = allBtns.slice(extendNum - 1, allBtnsLen);
|
|
59
|
+
} else {
|
|
60
|
+
showBtns = allBtns;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const showBuiltInBtns = showBtns.filter((b) => b.btnType === 'builtIn');
|
|
64
|
+
const showExtendBtns = showBtns.filter((b) => b.btnType === 'extend');
|
|
65
|
+
const moreBuiltInBtns = moreBtns.filter((b) => b.btnType === 'builtIn');
|
|
66
|
+
const moreExtendBtns = moreBtns.filter((b) => b.btnType === 'extend');
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
showBuiltInBtns,
|
|
70
|
+
showExtendBtns,
|
|
71
|
+
moreBuiltInBtns,
|
|
72
|
+
moreExtendBtns,
|
|
73
|
+
};
|
|
74
|
+
}, [
|
|
75
|
+
row,
|
|
76
|
+
currentRowKey,
|
|
77
|
+
extendNum,
|
|
78
|
+
getRealRowActions,
|
|
79
|
+
getRealExtendRowActions,
|
|
80
|
+
getRealIndexById,
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
const renderBtnIcon = (c: any) => {
|
|
84
|
+
const { icon, iconPos } = c;
|
|
85
|
+
let iconClassName = '';
|
|
86
|
+
if (iconPos) {
|
|
87
|
+
iconClassName = iconPos === 'left' ? 'actIcon-left' : 'actIcon-right';
|
|
88
|
+
}
|
|
89
|
+
const BtnIcon = icon ? (
|
|
90
|
+
<CommIcon
|
|
91
|
+
getEngineApis={() => (engineApis || {}) as any}
|
|
92
|
+
$$componentItem={props?.$$componentItem}
|
|
93
|
+
className={iconClassName}
|
|
94
|
+
icon={icon}
|
|
95
|
+
engineApis={engineApis}
|
|
96
|
+
/>
|
|
97
|
+
) : undefined;
|
|
98
|
+
return BtnIcon;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// 操作栏单个内置按钮
|
|
102
|
+
const renderBuiltInSingleBtn = (
|
|
103
|
+
c: any,
|
|
104
|
+
row: any,
|
|
105
|
+
rowIndex: number | null,
|
|
106
|
+
idx: number,
|
|
107
|
+
defaultBtnList: any,
|
|
108
|
+
isPopover = false,
|
|
109
|
+
showExtendBtns?: any[],
|
|
110
|
+
moreBuiltInBtns?: any[],
|
|
111
|
+
moreExtendBtns?: any[],
|
|
112
|
+
) => {
|
|
113
|
+
const BtnIcon = renderBtnIcon(c);
|
|
114
|
+
|
|
115
|
+
const popconfirmPlacement =
|
|
116
|
+
moreBuiltInBtns?.length ||
|
|
117
|
+
moreExtendBtns?.length ||
|
|
118
|
+
showExtendBtns?.length
|
|
119
|
+
? 'top'
|
|
120
|
+
: 'topRight';
|
|
121
|
+
|
|
122
|
+
const onBtnClick = (e: any) => {
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
if (
|
|
125
|
+
(typeof c === 'string' ? c === 'detail' : c.type === 'detail') &&
|
|
126
|
+
typeof onRowDetailClick === 'function'
|
|
127
|
+
) {
|
|
128
|
+
onRowDetailClick(row, rowIndex);
|
|
129
|
+
} else if (
|
|
130
|
+
(typeof c === 'string' ? c === 'edit' : c.type === 'edit') &&
|
|
131
|
+
typeof onRowEditClick === 'function'
|
|
132
|
+
) {
|
|
133
|
+
onRowEditClick(row, rowIndex);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const onDeleteClick = (e: any) => {
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
if (typeof onRowDeleteClick === 'function') {
|
|
140
|
+
onRowDeleteClick(row, rowIndex);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<SingleBtn
|
|
146
|
+
getLocale={getLocale}
|
|
147
|
+
actionsMap={actionsMap}
|
|
148
|
+
setMorePopVisible={setMorePopVisible}
|
|
149
|
+
BtnIcon={BtnIcon}
|
|
150
|
+
c={c}
|
|
151
|
+
idx={idx}
|
|
152
|
+
defaultBtnList={defaultBtnList}
|
|
153
|
+
isPopover={isPopover}
|
|
154
|
+
popconfirmPlacement={popconfirmPlacement}
|
|
155
|
+
onBtnClick={onBtnClick}
|
|
156
|
+
onDeleteClick={onDeleteClick}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// 操作栏扩展按钮
|
|
162
|
+
const renderExtendBtns = (
|
|
163
|
+
btnList: any,
|
|
164
|
+
isPopover = false,
|
|
165
|
+
row: any,
|
|
166
|
+
index: number,
|
|
167
|
+
buttonStyle?: React.CSSProperties,
|
|
168
|
+
) => {
|
|
169
|
+
return btnList.map((c: any, i: number) => {
|
|
170
|
+
if (c.type) {
|
|
171
|
+
return renderBuiltInSingleBtn(
|
|
172
|
+
c,
|
|
173
|
+
row,
|
|
174
|
+
index,
|
|
175
|
+
i,
|
|
176
|
+
btnList,
|
|
177
|
+
isPopover,
|
|
178
|
+
btnList?.slice(i),
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
const { iconPos, id, isIcon, onClick, visible: buttonVisible = true } = c;
|
|
182
|
+
|
|
183
|
+
const BtnIcon = renderBtnIcon(c);
|
|
184
|
+
|
|
185
|
+
if (!buttonVisible) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return isPopover ? (
|
|
190
|
+
<div>
|
|
191
|
+
<Tooltip title={c.title} visible={!!isIcon && undefined}>
|
|
192
|
+
<Button
|
|
193
|
+
type="link"
|
|
194
|
+
className="ued-table-actions-antBtn"
|
|
195
|
+
disabled={c.disabled}
|
|
196
|
+
key={id}
|
|
197
|
+
onClick={(e) => {
|
|
198
|
+
e.stopPropagation();
|
|
199
|
+
if (typeof onClick === 'function') {
|
|
200
|
+
onClick(currentRowKey ? row[currentRowKey] : row, row, index);
|
|
201
|
+
}
|
|
202
|
+
setMorePopVisible(false);
|
|
203
|
+
}}
|
|
204
|
+
>
|
|
205
|
+
<div className="ued-table-actions-extendBtn" style={buttonStyle}>
|
|
206
|
+
{iconPos && iconPos === 'left' && BtnIcon}
|
|
207
|
+
{!isIcon && c.title}
|
|
208
|
+
{iconPos && iconPos === 'right' && BtnIcon}
|
|
209
|
+
</div>
|
|
210
|
+
</Button>
|
|
211
|
+
</Tooltip>
|
|
212
|
+
</div>
|
|
213
|
+
) : (
|
|
214
|
+
<Fragment key={id}>
|
|
215
|
+
<Tooltip title={c.title} visible={!!isIcon && undefined}>
|
|
216
|
+
<Button
|
|
217
|
+
type="link"
|
|
218
|
+
className="ued-table-actions-antBtn"
|
|
219
|
+
disabled={c.disabled}
|
|
220
|
+
key={id}
|
|
221
|
+
onClick={(e) => {
|
|
222
|
+
e.stopPropagation();
|
|
223
|
+
if (typeof onClick === 'function') {
|
|
224
|
+
onClick(currentRowKey ? row[currentRowKey] : row, row, index);
|
|
225
|
+
}
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
228
|
+
<div className="ued-table-actions-extendBtn">
|
|
229
|
+
{iconPos && iconPos === 'left' && BtnIcon}
|
|
230
|
+
{!isIcon && c.title}
|
|
231
|
+
{iconPos && iconPos === 'right' && BtnIcon}
|
|
232
|
+
</div>
|
|
233
|
+
</Button>
|
|
234
|
+
</Tooltip>
|
|
235
|
+
{i !== btnList.length - 1 && <Divider type="vertical" />}
|
|
236
|
+
</Fragment>
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// 操作栏更多按钮
|
|
242
|
+
const renderExtendMoreBtns = (
|
|
243
|
+
showBuiltInBtns: any[],
|
|
244
|
+
showExtendBtns: any[],
|
|
245
|
+
moreBuiltInBtns: any[],
|
|
246
|
+
moreExtendBtns: any[],
|
|
247
|
+
row: any,
|
|
248
|
+
index: number,
|
|
249
|
+
) => {
|
|
250
|
+
return (
|
|
251
|
+
<>
|
|
252
|
+
{
|
|
253
|
+
// 扩展
|
|
254
|
+
showExtendBtns?.length > 0 ? (
|
|
255
|
+
<>
|
|
256
|
+
{!!showBuiltInBtns?.length && <Divider type="vertical" />}
|
|
257
|
+
{renderExtendBtns(showExtendBtns, false, row, index)}
|
|
258
|
+
</>
|
|
259
|
+
) : null
|
|
260
|
+
}
|
|
261
|
+
{
|
|
262
|
+
// 更多
|
|
263
|
+
moreBuiltInBtns?.length + moreExtendBtns?.length > 0 && (
|
|
264
|
+
<>
|
|
265
|
+
{/* TODO: 是什么? showBuiltInBtns[showBuiltInBtns.length - 1]?.visible !== false */}
|
|
266
|
+
{(!!showBuiltInBtns?.length || !!showExtendBtns?.length) && (
|
|
267
|
+
<Divider type="vertical" />
|
|
268
|
+
)}
|
|
269
|
+
<Popover
|
|
270
|
+
overlayClassName="ued-table-more-pop"
|
|
271
|
+
content={
|
|
272
|
+
<div
|
|
273
|
+
style={{
|
|
274
|
+
maxHeight: '300px',
|
|
275
|
+
overflow: 'auto',
|
|
276
|
+
padding: isSmallPopover ? '5px 5px' : '12px 16px',
|
|
277
|
+
}}
|
|
278
|
+
onClick={(e) => e.stopPropagation()}
|
|
279
|
+
>
|
|
280
|
+
{moreBuiltInBtns?.length
|
|
281
|
+
? moreBuiltInBtns.map((child: any, idx: number) => {
|
|
282
|
+
return renderBuiltInSingleBtn(
|
|
283
|
+
child,
|
|
284
|
+
row,
|
|
285
|
+
index,
|
|
286
|
+
idx,
|
|
287
|
+
showBuiltInBtns,
|
|
288
|
+
true,
|
|
289
|
+
);
|
|
290
|
+
})
|
|
291
|
+
: null}
|
|
292
|
+
{renderExtendBtns(
|
|
293
|
+
moreExtendBtns,
|
|
294
|
+
true,
|
|
295
|
+
row,
|
|
296
|
+
index,
|
|
297
|
+
isSmallPopover ? { fontSize: '12px' } : {},
|
|
298
|
+
)}
|
|
299
|
+
</div>
|
|
300
|
+
}
|
|
301
|
+
trigger="click"
|
|
302
|
+
placement="topRight"
|
|
303
|
+
open={morePopVisible}
|
|
304
|
+
// eslint-disable-next-line max-len
|
|
305
|
+
getPopupContainer={
|
|
306
|
+
isSmallPopover
|
|
307
|
+
? () =>
|
|
308
|
+
document.getElementById('lcdpApp-root') || document.body
|
|
309
|
+
: (triggerNode: HTMLElement) =>
|
|
310
|
+
triggerNode?.parentNode as HTMLElement
|
|
311
|
+
}
|
|
312
|
+
onOpenChange={(vis: boolean) => {
|
|
313
|
+
setMorePopVisible(vis);
|
|
314
|
+
if (fixedAction && tableRef?.current) {
|
|
315
|
+
const fixedActionEle =
|
|
316
|
+
tableRef.current?.querySelectorAll(
|
|
317
|
+
'.ued-table-actions',
|
|
318
|
+
)?.[index]?.parentNode;
|
|
319
|
+
// 操作列固定时 此时fixedActionEle默认antd样式为 position: sticky;z-index: 2
|
|
320
|
+
// 由于气泡卡片挂在fixedActionEle里面导致被后面的列遮盖
|
|
321
|
+
if (fixedActionEle) {
|
|
322
|
+
if (timerRef.current) {
|
|
323
|
+
clearTimeout(timerRef.current);
|
|
324
|
+
}
|
|
325
|
+
if (!vis) {
|
|
326
|
+
// 防止卡片部分被遮盖再隐藏
|
|
327
|
+
timerRef.current = setTimeout(() => {
|
|
328
|
+
fixedActionEle.style.zIndex = 2;
|
|
329
|
+
timerRef.current = null;
|
|
330
|
+
}, 200);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
fixedActionEle.style.zIndex = 3;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}}
|
|
337
|
+
>
|
|
338
|
+
<Button
|
|
339
|
+
type="link"
|
|
340
|
+
className="ued-table-actions-antBtn"
|
|
341
|
+
key="more"
|
|
342
|
+
onClick={(e) => e.stopPropagation()}
|
|
343
|
+
>
|
|
344
|
+
<div className="ued-table-actions-extendBtn">
|
|
345
|
+
{getLocale?.('more')}
|
|
346
|
+
<LegacyIcon className="actIcon-left" type="down" />
|
|
347
|
+
</div>
|
|
348
|
+
</Button>
|
|
349
|
+
</Popover>
|
|
350
|
+
</>
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
</>
|
|
354
|
+
);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
return (
|
|
358
|
+
<div className="ued-table-actions">
|
|
359
|
+
{
|
|
360
|
+
// 行内编辑部分
|
|
361
|
+
isNowEditRow ? (
|
|
362
|
+
<>
|
|
363
|
+
<div
|
|
364
|
+
className="ued-table-actions-extendBtn"
|
|
365
|
+
onClick={(e) => {
|
|
366
|
+
e.stopPropagation();
|
|
367
|
+
if (typeof onRowSaveClick === 'function') {
|
|
368
|
+
onRowSaveClick(
|
|
369
|
+
row,
|
|
370
|
+
getRealIndexById(row[currentRowKey]),
|
|
371
|
+
false,
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}}
|
|
375
|
+
>
|
|
376
|
+
<SaveOutlined rev="" className="actIcon-left" />
|
|
377
|
+
{getLocale('save')}
|
|
378
|
+
</div>
|
|
379
|
+
<Divider type="vertical" />
|
|
380
|
+
<Popconfirm
|
|
381
|
+
title={getLocale('cancelConfirm')}
|
|
382
|
+
placement="topRight"
|
|
383
|
+
overlayClassName="ued-table-actions-overlay"
|
|
384
|
+
onConfirm={(e: any) => {
|
|
385
|
+
e.stopPropagation();
|
|
386
|
+
if (typeof onRowCancelClick === 'function') {
|
|
387
|
+
onRowCancelClick(row);
|
|
388
|
+
}
|
|
389
|
+
}}
|
|
390
|
+
onCancel={(e) => {
|
|
391
|
+
e?.preventDefault();
|
|
392
|
+
e?.stopPropagation();
|
|
393
|
+
}}
|
|
394
|
+
>
|
|
395
|
+
<div
|
|
396
|
+
className="ued-table-actions-extendBtn"
|
|
397
|
+
onClick={(e) => {
|
|
398
|
+
e.stopPropagation();
|
|
399
|
+
}}
|
|
400
|
+
>
|
|
401
|
+
<CloseOutlined rev="" className="actIcon-left" />
|
|
402
|
+
{getLocale('cancel')}
|
|
403
|
+
</div>
|
|
404
|
+
</Popconfirm>
|
|
405
|
+
</>
|
|
406
|
+
) : (
|
|
407
|
+
<>
|
|
408
|
+
{showBuiltInBtns.map((c: any, idx: number) => {
|
|
409
|
+
return renderBuiltInSingleBtn(
|
|
410
|
+
c,
|
|
411
|
+
row,
|
|
412
|
+
getRealIndexById(row[currentRowKey]),
|
|
413
|
+
idx,
|
|
414
|
+
showBuiltInBtns,
|
|
415
|
+
false,
|
|
416
|
+
showExtendBtns,
|
|
417
|
+
moreBuiltInBtns,
|
|
418
|
+
moreExtendBtns,
|
|
419
|
+
);
|
|
420
|
+
})}
|
|
421
|
+
{renderExtendMoreBtns(
|
|
422
|
+
showBuiltInBtns,
|
|
423
|
+
showExtendBtns,
|
|
424
|
+
moreBuiltInBtns,
|
|
425
|
+
moreExtendBtns,
|
|
426
|
+
row,
|
|
427
|
+
getRealIndexById(row[currentRowKey]),
|
|
428
|
+
)}
|
|
429
|
+
</>
|
|
430
|
+
)
|
|
431
|
+
}
|
|
432
|
+
</div>
|
|
433
|
+
);
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
export default OperationCell;
|
|
@@ -84,18 +84,30 @@ const TableHead: React.FC<MyTableHeadProps> = (props: any) => {
|
|
|
84
84
|
customTitle,
|
|
85
85
|
customStyle,
|
|
86
86
|
iconFile: newIconFile,
|
|
87
|
+
// 默认列
|
|
88
|
+
defaultColumn,
|
|
87
89
|
} = !showCustom || typeof showCustom === 'boolean' ? ({} as any) : showCustom; // 兼容旧数据,旧数据是true、false、undefined
|
|
88
90
|
|
|
89
91
|
const [checkedKeys, checkedMap] = useMemo(() => {
|
|
90
92
|
const map: any = {};
|
|
93
|
+
// 缓存没有自定义列时
|
|
91
94
|
if (selectedCols === undefined) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
];
|
|
95
|
+
const defaultColumnSet = new Set<string>();
|
|
96
|
+
if (defaultColumn?.length) {
|
|
97
|
+
defaultColumn.forEach((c: any) => {
|
|
98
|
+
defaultColumnSet.add(c.key);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const keys: string[] = [];
|
|
102
|
+
columns?.forEach((c: any) => {
|
|
103
|
+
// 如果有默认列,没有缓存列时,按照默认列初始化自定义列内容
|
|
104
|
+
if (defaultColumn && !defaultColumnSet.has(c.key)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
map[c.dataIndex] = c;
|
|
108
|
+
keys.push(`${c.dataIndex || ''}`);
|
|
109
|
+
});
|
|
110
|
+
return [keys, map];
|
|
99
111
|
}
|
|
100
112
|
return [
|
|
101
113
|
selectedCols.map((c: any) => {
|
|
@@ -340,14 +352,14 @@ const TableHead: React.FC<MyTableHeadProps> = (props: any) => {
|
|
|
340
352
|
let orders: string[] = [...pre];
|
|
341
353
|
// 旧顺序列表为空时,表示是采用原始顺序
|
|
342
354
|
if (pre.length === 0) {
|
|
343
|
-
orders = columns?.map((c: any) => c.dataIndex) || [];
|
|
355
|
+
orders = columns?.map((c: any) => `${c.dataIndex}`) || [];
|
|
344
356
|
}
|
|
345
357
|
if (pre.length !== columns?.length) {
|
|
346
358
|
// 前后顺序列表不一致时,表格列发生变化
|
|
347
359
|
const extendCols: any[] = [];
|
|
348
360
|
columns?.forEach((col: any) => {
|
|
349
361
|
if (!orderMap[col.dataIndex]) {
|
|
350
|
-
extendCols.push(col.dataIndex);
|
|
362
|
+
extendCols.push(`${col.dataIndex}`);
|
|
351
363
|
}
|
|
352
364
|
});
|
|
353
365
|
orders = orders.filter((o) => orderMap[o]).concat(extendCols);
|
|
@@ -369,44 +381,49 @@ const TableHead: React.FC<MyTableHeadProps> = (props: any) => {
|
|
|
369
381
|
}
|
|
370
382
|
}}
|
|
371
383
|
>
|
|
372
|
-
{columns?.map(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
<
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
384
|
+
{columns?.map(
|
|
385
|
+
(col: { dataIndex: string | string[]; [key: string]: any }) => {
|
|
386
|
+
const dataIndex = `${col.dataIndex}`;
|
|
387
|
+
return (
|
|
388
|
+
<TreeNode
|
|
389
|
+
selectable={false}
|
|
390
|
+
title={
|
|
391
|
+
<div className="title">
|
|
392
|
+
<div className="icon">
|
|
393
|
+
<IconFont
|
|
394
|
+
width={16}
|
|
395
|
+
height={16}
|
|
396
|
+
iconClass="lcdp-icon-tuozhuai"
|
|
397
|
+
/>
|
|
398
|
+
</div>
|
|
399
|
+
<Checkbox
|
|
400
|
+
checked={checkedMap[dataIndex] !== undefined}
|
|
401
|
+
className="checkbox"
|
|
402
|
+
onChange={(e) => {
|
|
403
|
+
if (typeof setSelectedCols === 'function') {
|
|
404
|
+
setSelectedCols(() => {
|
|
405
|
+
if (e.target.checked) {
|
|
406
|
+
return [...(checkedKeys || []), dataIndex];
|
|
407
|
+
}
|
|
408
|
+
return (checkedKeys || []).filter(
|
|
409
|
+
(co: any) => co !== dataIndex,
|
|
410
|
+
);
|
|
411
|
+
});
|
|
392
412
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
key={col.dataIndex}
|
|
408
|
-
/>
|
|
409
|
-
))}
|
|
413
|
+
}}
|
|
414
|
+
/>
|
|
415
|
+
{checkedMap[dataIndex] ? (
|
|
416
|
+
<a>{col.originTitle}</a>
|
|
417
|
+
) : (
|
|
418
|
+
col.originTitle
|
|
419
|
+
)}
|
|
420
|
+
</div>
|
|
421
|
+
}
|
|
422
|
+
key={dataIndex}
|
|
423
|
+
/>
|
|
424
|
+
);
|
|
425
|
+
},
|
|
426
|
+
)}
|
|
410
427
|
</Tree>
|
|
411
428
|
);
|
|
412
429
|
};
|
|
@@ -468,7 +485,7 @@ const TableHead: React.FC<MyTableHeadProps> = (props: any) => {
|
|
|
468
485
|
<a
|
|
469
486
|
className="extend"
|
|
470
487
|
onClick={() => {
|
|
471
|
-
setSelectedCols(columns?.map((c: any) => c.dataIndex));
|
|
488
|
+
setSelectedCols(columns?.map((c: any) => `${c.dataIndex}`));
|
|
472
489
|
setColOrder([]);
|
|
473
490
|
}}
|
|
474
491
|
>
|
|
@@ -16,6 +16,7 @@ export const GHOST_TAG = 'ghostTag';
|
|
|
16
16
|
export const FADE_COLOUR_TAG = 'fadeColourTag';
|
|
17
17
|
export const PURE_COLOUR_TAG = 'pureColourTag';
|
|
18
18
|
export const HYPER_LINK = 'hyperlink';
|
|
19
|
+
export const THUMBNAIL = 'thumbnail';
|
|
19
20
|
|
|
20
21
|
export const ROW_CELL_CONTENT_STYLE_MAP = {
|
|
21
22
|
[PURE_COLOUR_FILL]: '纯色填充',
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { EngineApisType } from '@lingxiteam/types';
|
|
2
2
|
import { useImperativeHandle, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createEmptyRow,
|
|
5
|
+
deleteTempRowProperties,
|
|
6
|
+
EMPTY_ROW_TEMP_KEY_ATTR,
|
|
7
|
+
} from '../utils';
|
|
4
8
|
|
|
5
9
|
interface UseCommonCMDAction {
|
|
6
10
|
ref: any;
|
|
@@ -63,6 +67,7 @@ const useCMDAction = (props: UseCMDActionPropsType) => {
|
|
|
63
67
|
onRowSaveClick,
|
|
64
68
|
loadPrint,
|
|
65
69
|
engineApis,
|
|
70
|
+
expandTableData,
|
|
66
71
|
} = props;
|
|
67
72
|
|
|
68
73
|
// 表格编辑格式为下拉框时,绑定的服务对应的数据
|
|
@@ -149,8 +154,16 @@ const useCMDAction = (props: UseCMDActionPropsType) => {
|
|
|
149
154
|
if (tableUpdateInnerDataSource) {
|
|
150
155
|
const newRowKey = newRowData[EMPTY_ROW_TEMP_KEY_ATTR];
|
|
151
156
|
newRowData[currentRowKey] = newRowKey;
|
|
152
|
-
|
|
153
|
-
|
|
157
|
+
const newDataSource = innerDataSource.map((c) => {
|
|
158
|
+
/**
|
|
159
|
+
* 移除空白行的临时属性
|
|
160
|
+
* 最后一条空白行,不允许自动移除临时属性(交由保存/取消逻辑手动移除)
|
|
161
|
+
*/
|
|
162
|
+
delete c[EMPTY_ROW_TEMP_KEY_ATTR];
|
|
163
|
+
deleteTempRowProperties(c);
|
|
164
|
+
return c;
|
|
165
|
+
});
|
|
166
|
+
setInnerDataSource([newRowData, ...newDataSource]);
|
|
154
167
|
// 是否开启行编辑
|
|
155
168
|
if (inlineeditnow) {
|
|
156
169
|
// 设置当前行为编辑状态
|
|
@@ -268,6 +281,7 @@ const useCMDAction = (props: UseCMDActionPropsType) => {
|
|
|
268
281
|
});
|
|
269
282
|
},
|
|
270
283
|
loadPrint,
|
|
284
|
+
expandTableData,
|
|
271
285
|
}));
|
|
272
286
|
|
|
273
287
|
return {
|