@lingxiteam/ebe-utils 0.1.16 → 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/lib/public/src/utils/polyfills.ts +5 -0
- package/package.json +2 -2
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
|
-
import {
|
|
3
|
-
import { Icon as LegacyIcon } from '@lingxiteam/icons';
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
Divider,
|
|
7
|
-
Popconfirm,
|
|
8
|
-
Popover,
|
|
9
|
-
Skeleton,
|
|
10
|
-
Table,
|
|
11
|
-
Tooltip,
|
|
12
|
-
} from 'antd';
|
|
2
|
+
import { Popover, Skeleton, Table, Tooltip } from 'antd';
|
|
13
3
|
import type { ColumnProps } from 'antd/lib/table';
|
|
14
4
|
import { FilterDropdownProps } from 'antd/lib/table/interface';
|
|
15
5
|
import classnames from 'classnames';
|
|
16
|
-
import { cloneDeep } from 'lodash';
|
|
6
|
+
import { cloneDeep, get } from 'lodash';
|
|
17
7
|
import React, {
|
|
18
|
-
Fragment,
|
|
19
8
|
useCallback,
|
|
20
9
|
useEffect,
|
|
21
10
|
useMemo,
|
|
22
11
|
useRef,
|
|
23
12
|
useState,
|
|
24
13
|
} from 'react';
|
|
25
|
-
import
|
|
14
|
+
import { isDynamicProperty } from '../../utils/common';
|
|
26
15
|
import CustomModule from '../../utils/CustomModule';
|
|
27
16
|
import EditComponent from '../EditComponent';
|
|
28
17
|
import HeaderCellTitle from '../HeaderCell/HeaderCellTitle';
|
|
18
|
+
import OperationCell from '../OperationCell';
|
|
29
19
|
import {
|
|
30
20
|
compareFn,
|
|
31
21
|
handleExpandColumn,
|
|
@@ -100,8 +90,8 @@ const useColumns = (props: any) => {
|
|
|
100
90
|
onTableCellClick,
|
|
101
91
|
getRealIndexById,
|
|
102
92
|
showCustom,
|
|
93
|
+
scroll,
|
|
103
94
|
} = props;
|
|
104
|
-
|
|
105
95
|
const actionsMap: any = actionsMapFn(getLocale);
|
|
106
96
|
|
|
107
97
|
const { customEngineApi, getUserInfo } = engineApis || {};
|
|
@@ -115,10 +105,10 @@ const useColumns = (props: any) => {
|
|
|
115
105
|
const [pageData, setPageData] = useState<any>({});
|
|
116
106
|
const [colCustomOrder, setColCustomOrder] = useState<any>([]); // 自定义列顺序记录
|
|
117
107
|
const [customSelectedCols, setCustomSelectedCols] = useState<any>(); // 自定义列显隐记录
|
|
118
|
-
const [popVisible, setPopVisible] = useState({});
|
|
119
108
|
const [columnWidth, setColumnWidth] = useState<any[]>([]);
|
|
120
109
|
// 初始加载列宽
|
|
121
110
|
const [initLoadColWidth, setInitLoadColWidth] = useState(false);
|
|
111
|
+
const { hasCustom, defaultColumn } = showCustom || {};
|
|
122
112
|
|
|
123
113
|
const getInnerRowAction = (
|
|
124
114
|
rowAction: any,
|
|
@@ -386,341 +376,20 @@ const useColumns = (props: any) => {
|
|
|
386
376
|
setColumnWidth(newColumns);
|
|
387
377
|
};
|
|
388
378
|
|
|
389
|
-
// 操作栏扩展按钮
|
|
390
|
-
const renderExtendBtns = (
|
|
391
|
-
btnList: any,
|
|
392
|
-
isPopover = false,
|
|
393
|
-
row: any,
|
|
394
|
-
index: number,
|
|
395
|
-
) => {
|
|
396
|
-
return btnList.map((c: any, i: number) => {
|
|
397
|
-
if (c.type) {
|
|
398
|
-
return renderBuiltInSingleBtn(
|
|
399
|
-
c,
|
|
400
|
-
row,
|
|
401
|
-
index,
|
|
402
|
-
i,
|
|
403
|
-
btnList,
|
|
404
|
-
isPopover,
|
|
405
|
-
btnList?.slice(i),
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
const {
|
|
409
|
-
icon,
|
|
410
|
-
iconPos,
|
|
411
|
-
id,
|
|
412
|
-
isIcon,
|
|
413
|
-
onClick,
|
|
414
|
-
visible: buttonVisible = true,
|
|
415
|
-
} = c;
|
|
416
|
-
const iconClassName = iconPos
|
|
417
|
-
? iconPos === 'left'
|
|
418
|
-
? 'actIcon-left'
|
|
419
|
-
: 'actIcon-right'
|
|
420
|
-
: '';
|
|
421
|
-
const BtnIcon = icon ? (
|
|
422
|
-
<CommIcon
|
|
423
|
-
getEngineApis={props?.getEngineApis}
|
|
424
|
-
$$componentItem={props?.$$componentItem}
|
|
425
|
-
className={iconClassName}
|
|
426
|
-
icon={icon}
|
|
427
|
-
engineApis={engineApis}
|
|
428
|
-
/>
|
|
429
|
-
) : undefined;
|
|
430
|
-
return buttonVisible ? (
|
|
431
|
-
isPopover ? (
|
|
432
|
-
<div>
|
|
433
|
-
<Tooltip title={c.title} visible={!!isIcon && undefined}>
|
|
434
|
-
<Button
|
|
435
|
-
type="link"
|
|
436
|
-
className="ued-table-actions-antBtn"
|
|
437
|
-
disabled={c.disabled}
|
|
438
|
-
key={id}
|
|
439
|
-
onClick={(e) => {
|
|
440
|
-
e.stopPropagation();
|
|
441
|
-
if (typeof onClick === 'function') {
|
|
442
|
-
onClick(
|
|
443
|
-
currentRowKey ? row[currentRowKey] : row,
|
|
444
|
-
row,
|
|
445
|
-
index,
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
}}
|
|
449
|
-
>
|
|
450
|
-
<div className="ued-table-actions-extendBtn">
|
|
451
|
-
{iconPos && iconPos === 'left' && BtnIcon}
|
|
452
|
-
{!isIcon && c.title}
|
|
453
|
-
{iconPos && iconPos === 'right' && BtnIcon}
|
|
454
|
-
</div>
|
|
455
|
-
</Button>
|
|
456
|
-
</Tooltip>
|
|
457
|
-
</div>
|
|
458
|
-
) : (
|
|
459
|
-
<Fragment key={id}>
|
|
460
|
-
<Tooltip title={c.title} visible={!!isIcon && undefined}>
|
|
461
|
-
<Button
|
|
462
|
-
type="link"
|
|
463
|
-
className="ued-table-actions-antBtn"
|
|
464
|
-
disabled={c.disabled}
|
|
465
|
-
key={id}
|
|
466
|
-
onClick={(e) => {
|
|
467
|
-
e.stopPropagation();
|
|
468
|
-
if (typeof onClick === 'function') {
|
|
469
|
-
onClick(
|
|
470
|
-
currentRowKey ? row[currentRowKey] : row,
|
|
471
|
-
row,
|
|
472
|
-
index,
|
|
473
|
-
);
|
|
474
|
-
}
|
|
475
|
-
}}
|
|
476
|
-
>
|
|
477
|
-
<div className="ued-table-actions-extendBtn">
|
|
478
|
-
{iconPos && iconPos === 'left' && BtnIcon}
|
|
479
|
-
{!isIcon && c.title}
|
|
480
|
-
{iconPos && iconPos === 'right' && BtnIcon}
|
|
481
|
-
</div>
|
|
482
|
-
</Button>
|
|
483
|
-
</Tooltip>
|
|
484
|
-
{i !== btnList.length - 1 && <Divider type="vertical" />}
|
|
485
|
-
</Fragment>
|
|
486
|
-
)
|
|
487
|
-
) : null;
|
|
488
|
-
});
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
// 操作栏更多按钮
|
|
492
|
-
const renderExtendMoreBtns = (
|
|
493
|
-
showBuiltInBtns: any[],
|
|
494
|
-
showExtendBtns: any[],
|
|
495
|
-
moreBuiltInBtns: any[],
|
|
496
|
-
moreExtendBtns: any[],
|
|
497
|
-
row: any,
|
|
498
|
-
index: any,
|
|
499
|
-
) => {
|
|
500
|
-
return (
|
|
501
|
-
<>
|
|
502
|
-
{
|
|
503
|
-
// 扩展
|
|
504
|
-
showExtendBtns?.length > 0 ? (
|
|
505
|
-
<>
|
|
506
|
-
{!!showBuiltInBtns?.length && <Divider type="vertical" />}
|
|
507
|
-
{renderExtendBtns(showExtendBtns, false, row, index)}
|
|
508
|
-
</>
|
|
509
|
-
) : null
|
|
510
|
-
}
|
|
511
|
-
{
|
|
512
|
-
// 更多
|
|
513
|
-
moreBuiltInBtns?.length + moreExtendBtns?.length > 0 && (
|
|
514
|
-
<>
|
|
515
|
-
{/* TODO: 是什么? showBuiltInBtns[showBuiltInBtns.length - 1]?.visible !== false */}
|
|
516
|
-
{(!!showBuiltInBtns?.length || !!showExtendBtns?.length) && (
|
|
517
|
-
<Divider type="vertical" />
|
|
518
|
-
)}
|
|
519
|
-
<Popover
|
|
520
|
-
overlayClassName="ued-table-more-pop"
|
|
521
|
-
content={
|
|
522
|
-
<div
|
|
523
|
-
style={{
|
|
524
|
-
maxHeight: '300px',
|
|
525
|
-
overflow: 'auto',
|
|
526
|
-
padding: '12px 16px',
|
|
527
|
-
}}
|
|
528
|
-
onClick={(e) => e.stopPropagation()}
|
|
529
|
-
>
|
|
530
|
-
{moreBuiltInBtns?.length
|
|
531
|
-
? moreBuiltInBtns.map((child: any, idx: number) => {
|
|
532
|
-
return renderBuiltInSingleBtn(
|
|
533
|
-
child,
|
|
534
|
-
row,
|
|
535
|
-
index,
|
|
536
|
-
idx,
|
|
537
|
-
showBuiltInBtns,
|
|
538
|
-
true,
|
|
539
|
-
);
|
|
540
|
-
})
|
|
541
|
-
: null}
|
|
542
|
-
{renderExtendBtns(moreExtendBtns, true, row, index)}
|
|
543
|
-
</div>
|
|
544
|
-
}
|
|
545
|
-
trigger="click"
|
|
546
|
-
placement="topRight"
|
|
547
|
-
getPopupContainer={(triggerNode: HTMLElement) =>
|
|
548
|
-
triggerNode?.parentNode as HTMLElement
|
|
549
|
-
}
|
|
550
|
-
onVisibleChange={(vis: boolean) => {
|
|
551
|
-
if (fixedAction && tableRef?.current) {
|
|
552
|
-
const fixedActionEle =
|
|
553
|
-
tableRef.current?.querySelectorAll(
|
|
554
|
-
'.ued-table-actions',
|
|
555
|
-
)?.[index]?.parentNode;
|
|
556
|
-
// 操作列固定时 此时fixedActionEle默认antd样式为 position: sticky;z-index: 2
|
|
557
|
-
// 由于气泡卡片挂在fixedActionEle里面导致被后面的列遮盖
|
|
558
|
-
if (fixedActionEle) {
|
|
559
|
-
fixedActionEle.style.zIndex = vis ? 3 : 2;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}}
|
|
563
|
-
>
|
|
564
|
-
<Button
|
|
565
|
-
type="link"
|
|
566
|
-
className="ued-table-actions-antBtn"
|
|
567
|
-
key="more"
|
|
568
|
-
onClick={(e) => e.stopPropagation()}
|
|
569
|
-
>
|
|
570
|
-
<div className="ued-table-actions-extendBtn">
|
|
571
|
-
{getLocale?.('more')}
|
|
572
|
-
<LegacyIcon className="actIcon-left" type="down" />
|
|
573
|
-
</div>
|
|
574
|
-
</Button>
|
|
575
|
-
</Popover>
|
|
576
|
-
</>
|
|
577
|
-
)
|
|
578
|
-
}
|
|
579
|
-
</>
|
|
580
|
-
);
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
// 操作栏单个内置按钮
|
|
584
|
-
const renderBuiltInSingleBtn = (
|
|
585
|
-
c: any,
|
|
586
|
-
row: any,
|
|
587
|
-
rowIndex: number | null,
|
|
588
|
-
idx: number,
|
|
589
|
-
defaultBtnList: any,
|
|
590
|
-
isPopover = false,
|
|
591
|
-
showExtendBtns?: any[],
|
|
592
|
-
moreBuiltInBtns?: any[],
|
|
593
|
-
moreExtendBtns?: any[],
|
|
594
|
-
) => {
|
|
595
|
-
// eslint-disable-next-line no-nested-ternary
|
|
596
|
-
const iconClassName = c?.iconPos
|
|
597
|
-
? c.iconPos === 'left'
|
|
598
|
-
? 'actIcon-left'
|
|
599
|
-
: 'actIcon-right'
|
|
600
|
-
: '';
|
|
601
|
-
const { visible: buttonVisible = true } = c;
|
|
602
|
-
const BtnIcon = c.icon ? (
|
|
603
|
-
<CommIcon
|
|
604
|
-
className={iconClassName}
|
|
605
|
-
icon={c.icon}
|
|
606
|
-
getEngineApis={props?.getEngineApis}
|
|
607
|
-
$$componentItem={props?.$$componentItem}
|
|
608
|
-
/>
|
|
609
|
-
) : undefined;
|
|
610
|
-
|
|
611
|
-
const type = typeof c === 'string' ? c : c?.type;
|
|
612
|
-
|
|
613
|
-
let buildInBtn = (
|
|
614
|
-
<Button
|
|
615
|
-
type="link"
|
|
616
|
-
disabled={c.disabled}
|
|
617
|
-
className={classnames(
|
|
618
|
-
'ued-table-actions-antBtn',
|
|
619
|
-
type ? `ued-table-actions-${type}` : undefined,
|
|
620
|
-
)}
|
|
621
|
-
key={typeof c === 'string' ? c : c.type}
|
|
622
|
-
onClick={(e) => {
|
|
623
|
-
e.stopPropagation();
|
|
624
|
-
if (
|
|
625
|
-
(typeof c === 'string' ? c === 'detail' : c.type === 'detail') &&
|
|
626
|
-
typeof onRowDetailClick === 'function'
|
|
627
|
-
) {
|
|
628
|
-
onRowDetailClick(row, rowIndex);
|
|
629
|
-
} else if (
|
|
630
|
-
(typeof c === 'string' ? c === 'edit' : c.type === 'edit') &&
|
|
631
|
-
typeof onRowEditClick === 'function'
|
|
632
|
-
) {
|
|
633
|
-
onRowEditClick(row, rowIndex);
|
|
634
|
-
}
|
|
635
|
-
setPopVisible({ ...popVisible, [popKey]: false });
|
|
636
|
-
}}
|
|
637
|
-
onDoubleClick={(e) => {
|
|
638
|
-
e.stopPropagation();
|
|
639
|
-
}}
|
|
640
|
-
>
|
|
641
|
-
{typeof c === 'string' ? (
|
|
642
|
-
<div className="ued-table-actions-extendBtn">
|
|
643
|
-
<LegacyIcon className="actIcon-left" type={actionsMap[c][1]} />
|
|
644
|
-
{actionsMap[c][0]}
|
|
645
|
-
</div>
|
|
646
|
-
) : (
|
|
647
|
-
<div className="ued-table-actions-extendBtn">
|
|
648
|
-
{c.iconPos && c.iconPos === 'left' && BtnIcon}
|
|
649
|
-
{!c.isIcon && c.title}
|
|
650
|
-
{c.iconPos && c.iconPos === 'right' && BtnIcon}
|
|
651
|
-
</div>
|
|
652
|
-
)}
|
|
653
|
-
</Button>
|
|
654
|
-
);
|
|
655
|
-
const popKey = `${rowIndex}-${idx}`;
|
|
656
|
-
buildInBtn = c.isIcon ? (
|
|
657
|
-
<Tooltip
|
|
658
|
-
title={c.title}
|
|
659
|
-
// @ts-ignore
|
|
660
|
-
visible={popVisible?.[popKey]}
|
|
661
|
-
onVisibleChange={(v) => setPopVisible({ ...popVisible, [popKey]: v })}
|
|
662
|
-
>
|
|
663
|
-
{buildInBtn}
|
|
664
|
-
</Tooltip>
|
|
665
|
-
) : (
|
|
666
|
-
buildInBtn
|
|
667
|
-
);
|
|
668
|
-
|
|
669
|
-
const btn = buttonVisible ? (
|
|
670
|
-
<Fragment key={idx}>
|
|
671
|
-
{(typeof c === 'string' ? c === 'delete' : c.type === 'delete') &&
|
|
672
|
-
!c.disabled ? (
|
|
673
|
-
<span
|
|
674
|
-
style={{ lineHeight: '0px' }}
|
|
675
|
-
onClick={(e) => {
|
|
676
|
-
e.stopPropagation();
|
|
677
|
-
}}
|
|
678
|
-
onDoubleClick={(e) => {
|
|
679
|
-
e.stopPropagation();
|
|
680
|
-
}}
|
|
681
|
-
>
|
|
682
|
-
<Popconfirm
|
|
683
|
-
onVisibleChange={(v) =>
|
|
684
|
-
v && setPopVisible({ ...popVisible, [popKey]: false })
|
|
685
|
-
}
|
|
686
|
-
placement={
|
|
687
|
-
moreBuiltInBtns?.length ||
|
|
688
|
-
moreExtendBtns?.length ||
|
|
689
|
-
showExtendBtns?.length
|
|
690
|
-
? 'top'
|
|
691
|
-
: 'topRight'
|
|
692
|
-
}
|
|
693
|
-
title={getLocale('deleteConfirm')}
|
|
694
|
-
onConfirm={(e: any) => {
|
|
695
|
-
e.stopPropagation();
|
|
696
|
-
if (typeof onRowDeleteClick === 'function') {
|
|
697
|
-
onRowDeleteClick(row, rowIndex);
|
|
698
|
-
}
|
|
699
|
-
}}
|
|
700
|
-
>
|
|
701
|
-
{buildInBtn}
|
|
702
|
-
</Popconfirm>
|
|
703
|
-
</span>
|
|
704
|
-
) : (
|
|
705
|
-
buildInBtn
|
|
706
|
-
)}
|
|
707
|
-
{!isPopover && idx !== defaultBtnList.length - 1 && (
|
|
708
|
-
<Divider type="vertical" />
|
|
709
|
-
)}
|
|
710
|
-
</Fragment>
|
|
711
|
-
) : null;
|
|
712
|
-
return isPopover ? <div>{btn}</div> : btn;
|
|
713
|
-
};
|
|
714
|
-
|
|
715
379
|
// 处理cell props
|
|
716
|
-
const createCellProps = (
|
|
380
|
+
const createCellProps = (
|
|
381
|
+
record: any,
|
|
382
|
+
col: { dataIndex: string | string[]; [key: string]: any },
|
|
383
|
+
rowIndex: number,
|
|
384
|
+
) => {
|
|
717
385
|
const __rowSpan = rowSpanMap?.get(record) || {};
|
|
718
386
|
const __rowClass = rowClassMap?.get(record) || {};
|
|
387
|
+
const dataIndex = `${col.dataIndex}`;
|
|
719
388
|
const rowSpan =
|
|
720
|
-
__rowSpan && __rowSpan[
|
|
389
|
+
__rowSpan && __rowSpan[dataIndex] === undefined
|
|
721
390
|
? 1
|
|
722
|
-
: __rowSpan[
|
|
723
|
-
const rowClass = __rowClass && __rowClass[
|
|
391
|
+
: __rowSpan[dataIndex];
|
|
392
|
+
const rowClass = __rowClass && __rowClass[dataIndex];
|
|
724
393
|
|
|
725
394
|
// 表格单元格内-行数控制控制
|
|
726
395
|
let controllLineStyle = null;
|
|
@@ -753,11 +422,14 @@ const useColumns = (props: any) => {
|
|
|
753
422
|
...(colorFormatInfo || []),
|
|
754
423
|
...(col.colorFormatInfo || []),
|
|
755
424
|
],
|
|
425
|
+
width: col.width,
|
|
756
426
|
isCustomRendering: !!col.customRendering,
|
|
757
427
|
rowSpan,
|
|
758
428
|
className: rowClass,
|
|
759
429
|
onTableCellClick,
|
|
760
430
|
controllLineStyle,
|
|
431
|
+
$$componentItemId: props.$$componentItem.id,
|
|
432
|
+
index: getRealIndexById(record[currentRowKey]),
|
|
761
433
|
};
|
|
762
434
|
|
|
763
435
|
if (col.filter) {
|
|
@@ -766,7 +438,7 @@ const useColumns = (props: any) => {
|
|
|
766
438
|
}
|
|
767
439
|
|
|
768
440
|
const { translateContent } = parseTranslateContent(col, {
|
|
769
|
-
text: record
|
|
441
|
+
text: get(record, col.dataIndex),
|
|
770
442
|
row: record,
|
|
771
443
|
index: rowIndex,
|
|
772
444
|
});
|
|
@@ -832,7 +504,7 @@ const useColumns = (props: any) => {
|
|
|
832
504
|
if (col?.dataSource?.length) {
|
|
833
505
|
const dynamicColumns = col.dataSource.map(
|
|
834
506
|
(c: any, index: number) => {
|
|
835
|
-
const dataIndex = c
|
|
507
|
+
const dataIndex = get(c, col.dataIndex);
|
|
836
508
|
const realCol = {
|
|
837
509
|
...col, // 动态列所有配置行为(排序、固定等)相同
|
|
838
510
|
dataIndex,
|
|
@@ -1016,16 +688,31 @@ const useColumns = (props: any) => {
|
|
|
1016
688
|
}
|
|
1017
689
|
});
|
|
1018
690
|
const customizableCols = newColumns.concat(extendCols);
|
|
691
|
+
const defaultColumnSet = new Set<string>();
|
|
692
|
+
if (hasCustom && defaultColumn?.length) {
|
|
693
|
+
defaultColumn.forEach((c: any) => {
|
|
694
|
+
defaultColumnSet.add(c.key);
|
|
695
|
+
});
|
|
696
|
+
}
|
|
1019
697
|
// 只展示选中列
|
|
1020
|
-
let customCols = customizableCols.filter(
|
|
1021
|
-
(
|
|
1022
|
-
customSelectedCols === undefined
|
|
1023
|
-
|
|
1024
|
-
|
|
698
|
+
let customCols = customizableCols.filter((c) => {
|
|
699
|
+
if (hasCustom) {
|
|
700
|
+
if (customSelectedCols === undefined) {
|
|
701
|
+
if (defaultColumn) {
|
|
702
|
+
// 没有缓存列,使用默认列
|
|
703
|
+
return defaultColumnSet.has(c.key);
|
|
704
|
+
}
|
|
705
|
+
} else {
|
|
706
|
+
// 有缓存列,使用缓存列
|
|
707
|
+
return customSelectedCols?.includes(`${c.dataIndex}`);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return true;
|
|
711
|
+
});
|
|
1025
712
|
// 固定列与自定义列拼接在一起组成最终展示列
|
|
1026
713
|
customCols = fixedLeft.concat(customCols).concat(fixedRight);
|
|
1027
714
|
return [customCols, customizableCols, group];
|
|
1028
|
-
}, [columns, colCustomOrder, customSelectedCols]);
|
|
715
|
+
}, [columns, colCustomOrder, customSelectedCols, hasCustom, defaultColumn]);
|
|
1029
716
|
|
|
1030
717
|
const actionRowFlag = useRef<boolean>(false);
|
|
1031
718
|
|
|
@@ -1079,7 +766,10 @@ const useColumns = (props: any) => {
|
|
|
1079
766
|
// 绑定了服务
|
|
1080
767
|
const { labelKey, valueKey } = rowEditoption.selectoption.staticService;
|
|
1081
768
|
const optionskey = Object.keys(colServiceDataForEdit).find((k) => {
|
|
1082
|
-
if (
|
|
769
|
+
if (
|
|
770
|
+
`${k}` === `${c.dataIndex}` &&
|
|
771
|
+
Array.isArray(colServiceDataForEdit[k])
|
|
772
|
+
) {
|
|
1083
773
|
return true;
|
|
1084
774
|
}
|
|
1085
775
|
return false;
|
|
@@ -1117,7 +807,13 @@ const useColumns = (props: any) => {
|
|
|
1117
807
|
editoption.edittype === 'SuperSelect'
|
|
1118
808
|
) {
|
|
1119
809
|
// 高级选择框选用后端翻译好的字段值
|
|
1120
|
-
const
|
|
810
|
+
const realDataIndex = Array.isArray(dataIndex)
|
|
811
|
+
? [
|
|
812
|
+
...dataIndex.slice(0, dataIndex.length - 1),
|
|
813
|
+
`${dataIndex[dataIndex.length - 1]}_introduce`,
|
|
814
|
+
]
|
|
815
|
+
: `${dataIndex}_introduce`;
|
|
816
|
+
const _introduce = get(row, realDataIndex);
|
|
1121
817
|
translateContent = _introduce
|
|
1122
818
|
? (Array.isArray(_introduce) ? _introduce : [_introduce]).join(',')
|
|
1123
819
|
: text;
|
|
@@ -1126,7 +822,8 @@ const useColumns = (props: any) => {
|
|
|
1126
822
|
if (staticService && colServiceData) {
|
|
1127
823
|
const { labelKey, valueKey } = staticService;
|
|
1128
824
|
const needtranskey = Object.keys(colServiceData).find(
|
|
1129
|
-
(k) =>
|
|
825
|
+
(k) =>
|
|
826
|
+
`${k}` === `${c.dataIndex}` && Array.isArray(colServiceData[k]),
|
|
1130
827
|
);
|
|
1131
828
|
if (needtranskey) {
|
|
1132
829
|
// 支持数组或逗号分支字符翻译
|
|
@@ -1144,7 +841,13 @@ const useColumns = (props: any) => {
|
|
|
1144
841
|
}
|
|
1145
842
|
}
|
|
1146
843
|
if (editoption?.edittype === 'ModalSelect') {
|
|
1147
|
-
const
|
|
844
|
+
const realDataIndex = Array.isArray(dataIndex)
|
|
845
|
+
? [
|
|
846
|
+
...dataIndex.slice(0, dataIndex.length - 1),
|
|
847
|
+
`${dataIndex[dataIndex.length - 1]}_introduce`,
|
|
848
|
+
]
|
|
849
|
+
: `${dataIndex}_introduce`;
|
|
850
|
+
const _introduce = get(row, realDataIndex);
|
|
1148
851
|
translateContent = _introduce
|
|
1149
852
|
? (Array.isArray(_introduce) ? _introduce : [_introduce]).join(',')
|
|
1150
853
|
: text;
|
|
@@ -1211,12 +914,14 @@ const useColumns = (props: any) => {
|
|
|
1211
914
|
editoption?.edittype === 'ModalSelect' &&
|
|
1212
915
|
responseObj?.length
|
|
1213
916
|
) {
|
|
1214
|
-
|
|
917
|
+
// 保留原有配置 不然会导致首次解析结果会被再次解析
|
|
918
|
+
editoption.modalInfo.responseObjRun = (
|
|
1215
919
|
row: any,
|
|
1216
920
|
rowId: string | number,
|
|
1217
921
|
index: number,
|
|
1218
922
|
) =>
|
|
1219
|
-
responseObj?.map((
|
|
923
|
+
responseObj?.map((_d: any) => {
|
|
924
|
+
const d = { ..._d };
|
|
1220
925
|
if (typeof d?.value === 'string') {
|
|
1221
926
|
const rule = d.value;
|
|
1222
927
|
d.value = sandBoxSafeRun(rule, {
|
|
@@ -1234,8 +939,8 @@ const useColumns = (props: any) => {
|
|
|
1234
939
|
}
|
|
1235
940
|
|
|
1236
941
|
let modalSelectParams = [];
|
|
1237
|
-
if (typeof editoption?.modalInfo?.
|
|
1238
|
-
modalSelectParams = editoption?.modalInfo?.
|
|
942
|
+
if (typeof editoption?.modalInfo?.responseObjRun === 'function') {
|
|
943
|
+
modalSelectParams = editoption?.modalInfo?.responseObjRun(
|
|
1239
944
|
row,
|
|
1240
945
|
rowId,
|
|
1241
946
|
index,
|
|
@@ -1338,18 +1043,20 @@ const useColumns = (props: any) => {
|
|
|
1338
1043
|
// 自定义渲染函数
|
|
1339
1044
|
if (c.jsx) {
|
|
1340
1045
|
content = (
|
|
1341
|
-
<
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1046
|
+
<span>
|
|
1047
|
+
<CustomModule
|
|
1048
|
+
code={c.customRendering}
|
|
1049
|
+
sandBoxLoadModule={engineApis.sandBoxLoadModule}
|
|
1050
|
+
errorInfo={{
|
|
1051
|
+
id: props.$$componentItem.id,
|
|
1052
|
+
}}
|
|
1053
|
+
compProps={{
|
|
1054
|
+
text: translateContent,
|
|
1055
|
+
item: row,
|
|
1056
|
+
index,
|
|
1057
|
+
}}
|
|
1058
|
+
/>
|
|
1059
|
+
</span>
|
|
1353
1060
|
);
|
|
1354
1061
|
} else if (c.customRendering && funcExpExecute) {
|
|
1355
1062
|
content = (
|
|
@@ -1487,8 +1194,9 @@ const useColumns = (props: any) => {
|
|
|
1487
1194
|
let newPopContent = popContent;
|
|
1488
1195
|
try {
|
|
1489
1196
|
if (popContent) {
|
|
1197
|
+
let popoverContent = popContent;
|
|
1490
1198
|
if (typeof popContent === 'string') {
|
|
1491
|
-
|
|
1199
|
+
popoverContent = (row: any, rowId: string, index: number) =>
|
|
1492
1200
|
sandBoxSafeRun(popContent, {
|
|
1493
1201
|
row,
|
|
1494
1202
|
rowId,
|
|
@@ -1496,13 +1204,21 @@ const useColumns = (props: any) => {
|
|
|
1496
1204
|
});
|
|
1497
1205
|
}
|
|
1498
1206
|
|
|
1499
|
-
if (typeof
|
|
1500
|
-
newPopContent =
|
|
1207
|
+
if (typeof popoverContent === 'function') {
|
|
1208
|
+
newPopContent = popoverContent(row, rowId, index);
|
|
1501
1209
|
}
|
|
1502
1210
|
}
|
|
1503
1211
|
} catch (e) {
|
|
1504
1212
|
console.error(e);
|
|
1505
1213
|
}
|
|
1214
|
+
if (
|
|
1215
|
+
newPopContent === undefined &&
|
|
1216
|
+
typeof popContent === 'string' &&
|
|
1217
|
+
!isDynamicProperty(popContent)
|
|
1218
|
+
) {
|
|
1219
|
+
// 当表达式返回空,且不被$$包裹时,内容当成普通文本处理
|
|
1220
|
+
newPopContent = popContent;
|
|
1221
|
+
}
|
|
1506
1222
|
|
|
1507
1223
|
content = (
|
|
1508
1224
|
<Popover
|
|
@@ -1529,7 +1245,10 @@ const useColumns = (props: any) => {
|
|
|
1529
1245
|
c.sorter = true;
|
|
1530
1246
|
} else {
|
|
1531
1247
|
c.sorter = (a: any, b: any) => {
|
|
1532
|
-
return compareFn(
|
|
1248
|
+
return compareFn(
|
|
1249
|
+
get(a, c.dataIndex || c.key),
|
|
1250
|
+
get(b, c.dataIndex || c.key),
|
|
1251
|
+
);
|
|
1533
1252
|
};
|
|
1534
1253
|
}
|
|
1535
1254
|
}
|
|
@@ -1598,6 +1317,7 @@ const useColumns = (props: any) => {
|
|
|
1598
1317
|
((rowActions && rowActions.length) || (extend && extend.length))
|
|
1599
1318
|
) {
|
|
1600
1319
|
actionRowFlag.current = true;
|
|
1320
|
+
const isSmallPopover = innerDataSource?.length < 4;
|
|
1601
1321
|
const actionColumn: any = {
|
|
1602
1322
|
title: getLocale('ctrl'),
|
|
1603
1323
|
key: ACTION_COL_KEY,
|
|
@@ -1612,114 +1332,28 @@ const useColumns = (props: any) => {
|
|
|
1612
1332
|
nowInlineEditKey &&
|
|
1613
1333
|
row[currentRowKey] === nowInlineEditKey;
|
|
1614
1334
|
|
|
1615
|
-
// 过滤掉隐藏的按钮,得到真正的内置的默认按钮数据(详情、编辑、删除)
|
|
1616
|
-
const builtInBtns = getRealRowActions(
|
|
1617
|
-
row,
|
|
1618
|
-
getRealIndexById(row[currentRowKey]),
|
|
1619
|
-
);
|
|
1620
|
-
// 过滤掉隐藏的扩展按钮,得到真正的扩展按钮数据
|
|
1621
|
-
const extendBtns = getRealExtendRowActions(
|
|
1622
|
-
row,
|
|
1623
|
-
getRealIndexById(row[currentRowKey]),
|
|
1624
|
-
);
|
|
1625
|
-
|
|
1626
|
-
const allBtns = [...builtInBtns, ...extendBtns]?.filter(
|
|
1627
|
-
(btn) => btn?.checked !== false,
|
|
1628
|
-
); // 只展示选中的按钮;
|
|
1629
|
-
|
|
1630
|
-
let showBtns: any[] = [];
|
|
1631
|
-
let moreBtns: any[] = [];
|
|
1632
|
-
|
|
1633
|
-
// 当按钮数量超过 设置最大展示的数量两个时,超过的两个及以上部分放到更多中
|
|
1634
|
-
const allBtnsLen = allBtns?.length;
|
|
1635
|
-
if (allBtnsLen > extendNum) {
|
|
1636
|
-
showBtns = allBtns.slice(0, extendNum - 1);
|
|
1637
|
-
moreBtns = allBtns.slice(extendNum - 1, allBtnsLen);
|
|
1638
|
-
} else {
|
|
1639
|
-
showBtns = allBtns;
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
const showBuiltInBtns = showBtns.filter(
|
|
1643
|
-
(b) => b.btnType === 'builtIn',
|
|
1644
|
-
);
|
|
1645
|
-
const showExtendBtns = showBtns.filter((b) => b.btnType === 'extend');
|
|
1646
|
-
const moreBuiltInBtns = moreBtns.filter(
|
|
1647
|
-
(b) => b.btnType === 'builtIn',
|
|
1648
|
-
);
|
|
1649
|
-
const moreExtendBtns = moreBtns.filter((b) => b.btnType === 'extend');
|
|
1650
|
-
|
|
1651
1335
|
return (
|
|
1652
|
-
<
|
|
1653
|
-
{
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
<Divider type="vertical" />
|
|
1674
|
-
<Popconfirm
|
|
1675
|
-
title={getLocale('cancelConfirm')}
|
|
1676
|
-
placement="topRight"
|
|
1677
|
-
overlayClassName="ued-table-actions-overlay"
|
|
1678
|
-
onConfirm={(e: any) => {
|
|
1679
|
-
e.stopPropagation();
|
|
1680
|
-
if (typeof onRowCancelClick === 'function') {
|
|
1681
|
-
onRowCancelClick(row);
|
|
1682
|
-
}
|
|
1683
|
-
}}
|
|
1684
|
-
>
|
|
1685
|
-
<div
|
|
1686
|
-
className="ued-table-actions-extendBtn"
|
|
1687
|
-
onClick={(e) => {
|
|
1688
|
-
e.stopPropagation();
|
|
1689
|
-
}}
|
|
1690
|
-
>
|
|
1691
|
-
<CloseOutlined rev="" className="actIcon-left" />
|
|
1692
|
-
{getLocale('cancel')}
|
|
1693
|
-
</div>
|
|
1694
|
-
</Popconfirm>
|
|
1695
|
-
</>
|
|
1696
|
-
) : (
|
|
1697
|
-
<>
|
|
1698
|
-
{showBuiltInBtns.map((c: any, idx: number) => {
|
|
1699
|
-
return renderBuiltInSingleBtn(
|
|
1700
|
-
c,
|
|
1701
|
-
row,
|
|
1702
|
-
getRealIndexById(row[currentRowKey]),
|
|
1703
|
-
idx,
|
|
1704
|
-
showBuiltInBtns,
|
|
1705
|
-
false,
|
|
1706
|
-
showExtendBtns,
|
|
1707
|
-
moreBuiltInBtns,
|
|
1708
|
-
moreExtendBtns,
|
|
1709
|
-
);
|
|
1710
|
-
})}
|
|
1711
|
-
{renderExtendMoreBtns(
|
|
1712
|
-
showBuiltInBtns,
|
|
1713
|
-
showExtendBtns,
|
|
1714
|
-
moreBuiltInBtns,
|
|
1715
|
-
moreExtendBtns,
|
|
1716
|
-
row,
|
|
1717
|
-
getRealIndexById(row[currentRowKey]),
|
|
1718
|
-
)}
|
|
1719
|
-
</>
|
|
1720
|
-
)
|
|
1721
|
-
}
|
|
1722
|
-
</div>
|
|
1336
|
+
<OperationCell
|
|
1337
|
+
row={row}
|
|
1338
|
+
currentRowKey={currentRowKey}
|
|
1339
|
+
isNowEditRow={isNowEditRow}
|
|
1340
|
+
extendNum={extendNum}
|
|
1341
|
+
engineApis={engineApis}
|
|
1342
|
+
getRealIndexById={getRealIndexById}
|
|
1343
|
+
getRealRowActions={getRealRowActions}
|
|
1344
|
+
getRealExtendRowActions={getRealExtendRowActions}
|
|
1345
|
+
onRowDeleteClick={onRowDeleteClick}
|
|
1346
|
+
onRowSaveClick={onRowSaveClick}
|
|
1347
|
+
onRowDetailClick={onRowDetailClick}
|
|
1348
|
+
onRowEditClick={onRowEditClick}
|
|
1349
|
+
onRowCancelClick={onRowCancelClick}
|
|
1350
|
+
getLocale={getLocale}
|
|
1351
|
+
actionsMap={actionsMap}
|
|
1352
|
+
isSmallPopover={isSmallPopover}
|
|
1353
|
+
fixedAction={fixedAction}
|
|
1354
|
+
tableRef={tableRef}
|
|
1355
|
+
$$componentItem={props.$$componentItem}
|
|
1356
|
+
/>
|
|
1723
1357
|
);
|
|
1724
1358
|
},
|
|
1725
1359
|
};
|
|
@@ -1795,7 +1429,6 @@ const useColumns = (props: any) => {
|
|
|
1795
1429
|
nowEditingData,
|
|
1796
1430
|
nowInlineEditKey,
|
|
1797
1431
|
pageData,
|
|
1798
|
-
renderExtendMoreBtns,
|
|
1799
1432
|
rowActions,
|
|
1800
1433
|
onRowDetailClick,
|
|
1801
1434
|
onRowDeleteClick,
|
|
@@ -1820,21 +1453,28 @@ const useColumns = (props: any) => {
|
|
|
1820
1453
|
|
|
1821
1454
|
useEffect(() => {
|
|
1822
1455
|
if (tableRef.current && isFlexColumn) {
|
|
1823
|
-
//
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
tableRef?.current?.querySelectorAll('colgroup')?.[1]?.children || [];
|
|
1827
|
-
for (let i = 0; i < thList.length; i += 1) {
|
|
1828
|
-
const rowWidth = thList[i].offsetWidth;
|
|
1829
|
-
columnWidth[i] = rowWidth;
|
|
1830
|
-
}
|
|
1831
|
-
// TODO: 这里是啥意思??
|
|
1832
|
-
if (rowSelection) {
|
|
1833
|
-
columnWidth.shift();
|
|
1834
|
-
}
|
|
1835
|
-
setColumnWidth([...columnWidth]);
|
|
1456
|
+
// 如果开启了内容滚动, 但是没有配置内容宽度,则取表格项配置里的宽度,否则通过计算表格最终th渲染的宽度
|
|
1457
|
+
if (scroll && !scroll.x) {
|
|
1458
|
+
setColumnWidth(finalcolumns.map((item) => item.width || 100));
|
|
1836
1459
|
setInitLoadColWidth(true);
|
|
1837
|
-
}
|
|
1460
|
+
} else {
|
|
1461
|
+
// 当前执行时,antd表格列虽展示,但列宽按指定宽度渲染,需等下一次render,目前解决办法先延迟执行
|
|
1462
|
+
setTimeout(() => {
|
|
1463
|
+
const thList =
|
|
1464
|
+
tableRef?.current?.querySelectorAll('.pcfactory-table-thead th') ||
|
|
1465
|
+
[];
|
|
1466
|
+
for (let i = 0; i < thList.length; i += 1) {
|
|
1467
|
+
const rowWidth = thList[i].offsetWidth;
|
|
1468
|
+
columnWidth[i] = rowWidth;
|
|
1469
|
+
}
|
|
1470
|
+
// TODO: 这里是啥意思??
|
|
1471
|
+
if (rowSelection) {
|
|
1472
|
+
columnWidth.shift();
|
|
1473
|
+
}
|
|
1474
|
+
setColumnWidth([...columnWidth]);
|
|
1475
|
+
setInitLoadColWidth(true);
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1838
1478
|
}
|
|
1839
1479
|
}, [tableRef.current, isFlexColumn]);
|
|
1840
1480
|
|
|
@@ -1846,23 +1486,6 @@ const useColumns = (props: any) => {
|
|
|
1846
1486
|
(colCustomOrder?.length > 0 || customSelectedCols !== undefined) &&
|
|
1847
1487
|
showCustom?.hasCustom
|
|
1848
1488
|
) {
|
|
1849
|
-
// const tableStr: string = window.sessionStorage.getItem('TABLE_CUSTOM') || '{}';
|
|
1850
|
-
// try {
|
|
1851
|
-
// const tableInfo = JSON.parse(tableStr);
|
|
1852
|
-
// if (!tableInfo[compId]) {
|
|
1853
|
-
// tableInfo[compId] = {};
|
|
1854
|
-
// }
|
|
1855
|
-
// const target = tableInfo[compId];
|
|
1856
|
-
// target.ORDER = colCustomOrder;
|
|
1857
|
-
// target.SELECTED = customSelectedCols;
|
|
1858
|
-
// const newRes = JSON.stringify(tableInfo);
|
|
1859
|
-
// if (tableStr !== newRes) {
|
|
1860
|
-
// window.sessionStorage.setItem('TABLE_CUSTOM', newRes);
|
|
1861
|
-
// }
|
|
1862
|
-
// } catch (e) {
|
|
1863
|
-
// //
|
|
1864
|
-
// }
|
|
1865
|
-
|
|
1866
1489
|
// 修改数据的存储方法
|
|
1867
1490
|
getOrSaveData({
|
|
1868
1491
|
appId: props?.appId || props?.$$componentItem?.appId || '',
|
|
@@ -1877,13 +1500,9 @@ const useColumns = (props: any) => {
|
|
|
1877
1500
|
}
|
|
1878
1501
|
}, [colCustomOrder, customSelectedCols, compId, showCustom]);
|
|
1879
1502
|
|
|
1503
|
+
// 从缓存中取自定义列
|
|
1880
1504
|
useEffect(() => {
|
|
1881
1505
|
if (compId && showCustom?.hasCustom) {
|
|
1882
|
-
// const tableStr: string = window.sessionStorage.getItem('TABLE_CUSTOM') || '{}';
|
|
1883
|
-
// const tableInfo = JSON.parse(tableStr);
|
|
1884
|
-
// const { ORDER = [], SELECTED } = tableInfo[compId] || {};
|
|
1885
|
-
// setColCustomOrder(ORDER);
|
|
1886
|
-
// setCustomSelectedCols(SELECTED);
|
|
1887
1506
|
getOrSaveData({
|
|
1888
1507
|
appId: props?.appId || props?.$$componentItem?.appId || '',
|
|
1889
1508
|
userId,
|