@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
|
@@ -29,10 +29,12 @@ import HeaderCellTitle from '../HeaderCell/HeaderCellTitle';
|
|
|
29
29
|
import {
|
|
30
30
|
compareFn,
|
|
31
31
|
handleExpandColumn,
|
|
32
|
+
handleMergeHeader,
|
|
32
33
|
handleMultiLevelHeader,
|
|
33
34
|
handleRecursiveParseColumns,
|
|
34
35
|
treeRootName,
|
|
35
36
|
} from '../utils';
|
|
37
|
+
import { getOrSaveData } from '../utils/indexedDBHelper';
|
|
36
38
|
|
|
37
39
|
const ACTION_COL_KEY = '_actions';
|
|
38
40
|
|
|
@@ -97,10 +99,16 @@ const useColumns = (props: any) => {
|
|
|
97
99
|
getLocale,
|
|
98
100
|
onTableCellClick,
|
|
99
101
|
getRealIndexById,
|
|
102
|
+
showCustom,
|
|
100
103
|
} = props;
|
|
101
104
|
|
|
102
105
|
const actionsMap: any = actionsMapFn(getLocale);
|
|
103
106
|
|
|
107
|
+
const { customEngineApi, getUserInfo } = engineApis || {};
|
|
108
|
+
|
|
109
|
+
const { userId = '' } = getUserInfo?.() || {};
|
|
110
|
+
const fatherBOFramerId = customEngineApi?.getFatherComId?.();
|
|
111
|
+
|
|
104
112
|
// const api = getApis();
|
|
105
113
|
|
|
106
114
|
const tableRef = useRef<any>();
|
|
@@ -393,7 +401,7 @@ const useColumns = (props: any) => {
|
|
|
393
401
|
index,
|
|
394
402
|
i,
|
|
395
403
|
btnList,
|
|
396
|
-
|
|
404
|
+
isPopover,
|
|
397
405
|
btnList?.slice(i),
|
|
398
406
|
);
|
|
399
407
|
}
|
|
@@ -536,6 +544,9 @@ const useColumns = (props: any) => {
|
|
|
536
544
|
}
|
|
537
545
|
trigger="click"
|
|
538
546
|
placement="topRight"
|
|
547
|
+
getPopupContainer={(triggerNode: HTMLElement) =>
|
|
548
|
+
triggerNode?.parentNode as HTMLElement
|
|
549
|
+
}
|
|
539
550
|
>
|
|
540
551
|
<Button
|
|
541
552
|
type="link"
|
|
@@ -737,11 +748,12 @@ const useColumns = (props: any) => {
|
|
|
737
748
|
};
|
|
738
749
|
}
|
|
739
750
|
|
|
751
|
+
// 动态列标记一下,合计行需要根据key处理
|
|
752
|
+
realCol.dynamicOriginKey = realCol.key;
|
|
740
753
|
// key增强,拼接index,防止重复
|
|
741
754
|
realCol.key = `${realCol.key}_${index}`;
|
|
742
|
-
|
|
743
755
|
// 移除动态列标识字段,和动态列数据源字段
|
|
744
|
-
delete realCol.type;
|
|
756
|
+
// delete realCol.type;
|
|
745
757
|
delete realCol.dataSource;
|
|
746
758
|
return realCol;
|
|
747
759
|
});
|
|
@@ -900,7 +912,7 @@ const useColumns = (props: any) => {
|
|
|
900
912
|
* customCols:左右固定列 + 已选的、自定义顺序的列
|
|
901
913
|
* customizableCols:可自定义(显隐、顺序)的列
|
|
902
914
|
*/
|
|
903
|
-
const [customCols, customizableCols] = useMemo(() => {
|
|
915
|
+
const [customCols, customizableCols, groupMark] = useMemo(() => {
|
|
904
916
|
const fixedLeft: any[] = [];
|
|
905
917
|
const fixedRight: any[] = [];
|
|
906
918
|
let newColumns = [...columns];
|
|
@@ -915,6 +927,8 @@ const useColumns = (props: any) => {
|
|
|
915
927
|
const colMap: any = {};
|
|
916
928
|
// 记录重新调整列内容后之前没有的列
|
|
917
929
|
const extendCols: any[] = [];
|
|
930
|
+
// 记录每层分组的数量
|
|
931
|
+
const group = new Map<number, number>();
|
|
918
932
|
columns.forEach((c: any, i: number) => {
|
|
919
933
|
try {
|
|
920
934
|
let isHidden;
|
|
@@ -943,6 +957,17 @@ const useColumns = (props: any) => {
|
|
|
943
957
|
extendCols.push(newCol);
|
|
944
958
|
}
|
|
945
959
|
}
|
|
960
|
+
if (!isHidden && newCol?.group) {
|
|
961
|
+
newCol.group.forEach((c: string, gi: number) => {
|
|
962
|
+
if (!group.has(gi)) {
|
|
963
|
+
group.set(gi, 0);
|
|
964
|
+
}
|
|
965
|
+
const len = group.get(gi) || 0;
|
|
966
|
+
if (c) {
|
|
967
|
+
group.set(gi, len + 1);
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
}
|
|
946
971
|
} catch (e) {
|
|
947
972
|
console.log(e);
|
|
948
973
|
}
|
|
@@ -962,7 +987,7 @@ const useColumns = (props: any) => {
|
|
|
962
987
|
);
|
|
963
988
|
// 固定列与自定义列拼接在一起组成最终展示列
|
|
964
989
|
customCols = fixedLeft.concat(customCols).concat(fixedRight);
|
|
965
|
-
return [customCols, customizableCols];
|
|
990
|
+
return [customCols, customizableCols, group];
|
|
966
991
|
}, [columns, colCustomOrder, customSelectedCols]);
|
|
967
992
|
|
|
968
993
|
const actionRowFlag = useRef<boolean>(false);
|
|
@@ -1112,7 +1137,7 @@ const useColumns = (props: any) => {
|
|
|
1112
1137
|
|
|
1113
1138
|
const finalcolumns: any[] = useMemo(() => {
|
|
1114
1139
|
const newColumns = [...customCols];
|
|
1115
|
-
|
|
1140
|
+
let finalCols: ColumnProps<any>[] = [];
|
|
1116
1141
|
|
|
1117
1142
|
// 用于表格头分组的数据结构:左树根节点,为第0层
|
|
1118
1143
|
const leftTree: any = {
|
|
@@ -1517,6 +1542,13 @@ const useColumns = (props: any) => {
|
|
|
1517
1542
|
);
|
|
1518
1543
|
}
|
|
1519
1544
|
|
|
1545
|
+
if (c?.group) {
|
|
1546
|
+
// 过滤掉整层为空的分组
|
|
1547
|
+
c.group = c.group.filter(
|
|
1548
|
+
(_: string, gi: number) => groupMark.get(gi) !== 0,
|
|
1549
|
+
);
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1520
1552
|
// 处理分组逻辑
|
|
1521
1553
|
handleMultiLevelHeader(leftTree, newColumns[i]);
|
|
1522
1554
|
});
|
|
@@ -1528,6 +1560,8 @@ const useColumns = (props: any) => {
|
|
|
1528
1560
|
finalCols.push(...newColumns);
|
|
1529
1561
|
}
|
|
1530
1562
|
|
|
1563
|
+
finalCols = handleMergeHeader(finalCols as any[]) || finalCols;
|
|
1564
|
+
|
|
1531
1565
|
if (
|
|
1532
1566
|
!hiddenAction &&
|
|
1533
1567
|
((rowActions && rowActions.length) || (extend && extend.length))
|
|
@@ -1759,7 +1793,6 @@ const useColumns = (props: any) => {
|
|
|
1759
1793
|
setTimeout(() => {
|
|
1760
1794
|
const thList =
|
|
1761
1795
|
tableRef?.current?.querySelectorAll('colgroup')?.[1]?.children || [];
|
|
1762
|
-
|
|
1763
1796
|
for (let i = 0; i < thList.length; i += 1) {
|
|
1764
1797
|
const rowWidth = thList[i].offsetWidth;
|
|
1765
1798
|
columnWidth[i] = rowWidth;
|
|
@@ -1776,40 +1809,64 @@ const useColumns = (props: any) => {
|
|
|
1776
1809
|
|
|
1777
1810
|
// 将自定义列地相关操作记录到sessionStorage中,刷新时保留
|
|
1778
1811
|
useEffect(() => {
|
|
1812
|
+
// 需要开启自定义列才进行存储
|
|
1779
1813
|
if (
|
|
1780
1814
|
compId &&
|
|
1781
|
-
(colCustomOrder?.length > 0 || customSelectedCols !== undefined)
|
|
1815
|
+
(colCustomOrder?.length > 0 || customSelectedCols !== undefined) &&
|
|
1816
|
+
showCustom?.hasCustom
|
|
1782
1817
|
) {
|
|
1783
|
-
const tableStr: string =
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1818
|
+
// const tableStr: string = window.sessionStorage.getItem('TABLE_CUSTOM') || '{}';
|
|
1819
|
+
// try {
|
|
1820
|
+
// const tableInfo = JSON.parse(tableStr);
|
|
1821
|
+
// if (!tableInfo[compId]) {
|
|
1822
|
+
// tableInfo[compId] = {};
|
|
1823
|
+
// }
|
|
1824
|
+
// const target = tableInfo[compId];
|
|
1825
|
+
// target.ORDER = colCustomOrder;
|
|
1826
|
+
// target.SELECTED = customSelectedCols;
|
|
1827
|
+
// const newRes = JSON.stringify(tableInfo);
|
|
1828
|
+
// if (tableStr !== newRes) {
|
|
1829
|
+
// window.sessionStorage.setItem('TABLE_CUSTOM', newRes);
|
|
1830
|
+
// }
|
|
1831
|
+
// } catch (e) {
|
|
1832
|
+
// //
|
|
1833
|
+
// }
|
|
1834
|
+
|
|
1835
|
+
// 修改数据的存储方法
|
|
1836
|
+
getOrSaveData({
|
|
1837
|
+
appId: props?.appId || props?.$$componentItem?.appId || '',
|
|
1838
|
+
userId,
|
|
1839
|
+
compId: fatherBOFramerId
|
|
1840
|
+
? `${fatherBOFramerId}-${props.$$componentItem?.uid}`
|
|
1841
|
+
: props.$$componentItem?.uid,
|
|
1842
|
+
save: true,
|
|
1843
|
+
order: colCustomOrder,
|
|
1844
|
+
selected: customSelectedCols,
|
|
1845
|
+
});
|
|
1800
1846
|
}
|
|
1801
|
-
}, [colCustomOrder, customSelectedCols, compId]);
|
|
1847
|
+
}, [colCustomOrder, customSelectedCols, compId, showCustom]);
|
|
1802
1848
|
|
|
1803
1849
|
useEffect(() => {
|
|
1804
|
-
if (compId) {
|
|
1805
|
-
const tableStr: string =
|
|
1806
|
-
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1850
|
+
if (compId && showCustom?.hasCustom) {
|
|
1851
|
+
// const tableStr: string = window.sessionStorage.getItem('TABLE_CUSTOM') || '{}';
|
|
1852
|
+
// const tableInfo = JSON.parse(tableStr);
|
|
1853
|
+
// const { ORDER = [], SELECTED } = tableInfo[compId] || {};
|
|
1854
|
+
// setColCustomOrder(ORDER);
|
|
1855
|
+
// setCustomSelectedCols(SELECTED);
|
|
1856
|
+
getOrSaveData({
|
|
1857
|
+
appId: props?.appId || props?.$$componentItem?.appId || '',
|
|
1858
|
+
userId,
|
|
1859
|
+
compId: fatherBOFramerId
|
|
1860
|
+
? `${fatherBOFramerId}-${props.$$componentItem?.uid}`
|
|
1861
|
+
: props.$$componentItem?.uid,
|
|
1862
|
+
save: false,
|
|
1863
|
+
}).then((result: any) => {
|
|
1864
|
+
const { ORDER = [], SELECTED } = result || {};
|
|
1865
|
+
setColCustomOrder(ORDER);
|
|
1866
|
+
setCustomSelectedCols(SELECTED);
|
|
1867
|
+
});
|
|
1811
1868
|
}
|
|
1812
|
-
}, [compId]);
|
|
1869
|
+
}, [compId, showCustom]);
|
|
1813
1870
|
|
|
1814
1871
|
useEffect(() => {
|
|
1815
1872
|
const newColumns = [...columns];
|
|
@@ -254,17 +254,28 @@ const useSelection = <T extends { [key: string]: unknown }>(
|
|
|
254
254
|
const onRowSelectClick = (record: any, index?: number) => {
|
|
255
255
|
// 行禁用,不允许界面选中
|
|
256
256
|
if (rowSelection && !handleIsRowSelectDisabled(record, index)) {
|
|
257
|
-
if
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
257
|
+
// 下面if else代码一样??
|
|
258
|
+
// if (selectedRowKeys.includes(record[currentRowKey])) {
|
|
259
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
260
|
+
// rowSelection.type === 'radio'
|
|
261
|
+
// ? onRowSelected([record], true)
|
|
262
|
+
// : onRowSelected(
|
|
263
|
+
// triggerSingleSelection(selectedRows, record),
|
|
264
|
+
// true,
|
|
265
|
+
// );
|
|
266
|
+
// } else {
|
|
267
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
268
|
+
// rowSelection.type === 'radio'
|
|
269
|
+
// ? onRowSelected([record], true)
|
|
270
|
+
// : onRowSelected(
|
|
271
|
+
// triggerSingleSelection(selectedRows, record),
|
|
272
|
+
// true,
|
|
273
|
+
// );
|
|
274
|
+
// }
|
|
275
|
+
|
|
276
|
+
rowSelection.type === 'radio'
|
|
277
|
+
? onRowSelected([record], true)
|
|
278
|
+
: onRowSelected(triggerSingleSelection(selectedRows, record), true);
|
|
268
279
|
}
|
|
269
280
|
};
|
|
270
281
|
|
|
@@ -17,7 +17,12 @@ export type ColItem = {
|
|
|
17
17
|
export type Column = {
|
|
18
18
|
key?: string;
|
|
19
19
|
dataIndex: string;
|
|
20
|
-
type?:
|
|
20
|
+
type?: 'orderCol' | 'dynamicCol';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 动态列原始key
|
|
24
|
+
*/
|
|
25
|
+
dynamicOriginKey?: string;
|
|
21
26
|
fixed?: TableColumnProps<any>['fixed'];
|
|
22
27
|
align?: TableColumnProps<any>['align'];
|
|
23
28
|
children?: Array<Column>;
|
|
@@ -29,7 +34,10 @@ export interface SummaryProps<T> {
|
|
|
29
34
|
}
|
|
30
35
|
const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
31
36
|
const { summaryConfig, dataSource, columns } = props;
|
|
32
|
-
const { summaryType, summaryGroup } = useMemo
|
|
37
|
+
const { summaryType, summaryGroup } = useMemo<{
|
|
38
|
+
summaryType: SummaryConfig['type'];
|
|
39
|
+
summaryGroup: SummaryConfig['group'];
|
|
40
|
+
}>(() => {
|
|
33
41
|
if (!summaryConfig) {
|
|
34
42
|
return {
|
|
35
43
|
summaryType: 'none',
|
|
@@ -44,6 +52,24 @@ const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
|
44
52
|
};
|
|
45
53
|
}, [summaryConfig]);
|
|
46
54
|
|
|
55
|
+
// 真实的字段columns
|
|
56
|
+
const fieldColumns = useMemo(() => {
|
|
57
|
+
const colList: typeof columns = [];
|
|
58
|
+
const recursive = (arr: typeof columns) => {
|
|
59
|
+
if (Array.isArray(arr)) {
|
|
60
|
+
arr.forEach((c) => {
|
|
61
|
+
if (c?.children?.length) {
|
|
62
|
+
recursive(c.children);
|
|
63
|
+
} else {
|
|
64
|
+
colList.push(c);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
recursive(columns);
|
|
70
|
+
return colList;
|
|
71
|
+
}, [columns]);
|
|
72
|
+
|
|
47
73
|
const summaryColIndexMap = useMemo(() => {
|
|
48
74
|
const map = new Map<
|
|
49
75
|
string,
|
|
@@ -80,6 +106,7 @@ const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
|
80
106
|
colSpan?: number;
|
|
81
107
|
dataIndexList?: string[];
|
|
82
108
|
operateType?: ColItem['operateType'];
|
|
109
|
+
type?: Column['type'];
|
|
83
110
|
prev?: {
|
|
84
111
|
index: number;
|
|
85
112
|
fixed?: TableColumnProps<T>['fixed'];
|
|
@@ -88,8 +115,19 @@ const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
|
88
115
|
}> = [];
|
|
89
116
|
// 标记当前已经记录的总结列
|
|
90
117
|
const currentSummaryColMap: Record<number, (typeof col)[number]> = {};
|
|
91
|
-
|
|
92
|
-
|
|
118
|
+
fieldColumns?.forEach((c, i) => {
|
|
119
|
+
const { key, dataIndex, dynamicOriginKey, type } = c;
|
|
120
|
+
let matchKey = key;
|
|
121
|
+
if (type === 'dynamicCol' && dynamicOriginKey) {
|
|
122
|
+
matchKey = dynamicOriginKey;
|
|
123
|
+
}
|
|
124
|
+
const summaryCol = summaryColIndexMap.get(matchKey || '');
|
|
125
|
+
// 首列是序号列或者是没有参与合并的,用于展示合并文案
|
|
126
|
+
if (
|
|
127
|
+
i === 0 &&
|
|
128
|
+
(type === 'orderCol' || !summaryCol) &&
|
|
129
|
+
summaryConfig?.name
|
|
130
|
+
) {
|
|
93
131
|
col.push({
|
|
94
132
|
title: summaryConfig?.name,
|
|
95
133
|
align: c.align,
|
|
@@ -99,9 +137,8 @@ const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
|
99
137
|
title: '',
|
|
100
138
|
dataIndexList: [],
|
|
101
139
|
align: c.align,
|
|
140
|
+
type,
|
|
102
141
|
};
|
|
103
|
-
const { key, dataIndex } = c;
|
|
104
|
-
const summaryCol = summaryColIndexMap.get(key || '');
|
|
105
142
|
if (summaryCol) {
|
|
106
143
|
const { index, operateType } = summaryCol;
|
|
107
144
|
if (currentSummaryColMap[index]) {
|
|
@@ -109,9 +146,15 @@ const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
|
109
146
|
if (
|
|
110
147
|
prevItem?.prev &&
|
|
111
148
|
i === prevItem?.prev?.index + 1 &&
|
|
112
|
-
prevItem?.prev?.fixed === c?.fixed
|
|
149
|
+
prevItem?.prev?.fixed === c?.fixed &&
|
|
150
|
+
!(
|
|
151
|
+
summaryType === 'single' &&
|
|
152
|
+
type === 'dynamicCol' &&
|
|
153
|
+
type === prevItem?.type
|
|
154
|
+
)
|
|
113
155
|
) {
|
|
114
156
|
// 勾选列是相邻的,则允许合并
|
|
157
|
+
// 单列合计时,需排除动态列情况
|
|
115
158
|
item = prevItem;
|
|
116
159
|
} else {
|
|
117
160
|
// 单独一列
|
|
@@ -180,7 +223,7 @@ const useSummaryCol = <T>(props: SummaryProps<T>) => {
|
|
|
180
223
|
dataSource,
|
|
181
224
|
summaryConfig?.name,
|
|
182
225
|
summaryConfig?.decimal,
|
|
183
|
-
|
|
226
|
+
fieldColumns,
|
|
184
227
|
summaryColIndexMap,
|
|
185
228
|
]);
|
|
186
229
|
return {
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
/* eslint-disable no-underscore-dangle */
|
|
6
6
|
import { Form, Table } from 'antd';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
-
import React, { useRef } from 'react';
|
|
8
|
+
import React, { useMemo, useRef } from 'react';
|
|
9
9
|
import { PrintContainer, usePrintMode } from '../utils';
|
|
10
10
|
import { useCreation } from '../utils/ahooks';
|
|
11
|
-
import
|
|
11
|
+
import EmptyComp from '../utils/Empty';
|
|
12
12
|
import { useFuncExpExecute } from '../utils/hooks/useFuncExpExecute';
|
|
13
13
|
import { useLocale } from '../utils/hooks/useLocale';
|
|
14
14
|
import BodyCell from './BodyCell';
|
|
@@ -76,7 +76,7 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
|
|
|
76
76
|
const [form] = Form.useForm();
|
|
77
77
|
|
|
78
78
|
const engineApis = getEngineApis?.();
|
|
79
|
-
const { sandBoxSafeRun, renderBusiComponent } = engineApis || {};
|
|
79
|
+
const { sandBoxSafeRun, renderBusiComponent, dataState } = engineApis || {};
|
|
80
80
|
|
|
81
81
|
const { getLocale } = useLocale(engineApis || {});
|
|
82
82
|
|
|
@@ -396,6 +396,11 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
|
|
|
396
396
|
'data-compid': (props as any)?.['data-compid'],
|
|
397
397
|
};
|
|
398
398
|
|
|
399
|
+
const isEmptyLoading = useMemo(
|
|
400
|
+
() => loading && sortDataSource?.length === 0,
|
|
401
|
+
[loading, sortDataSource],
|
|
402
|
+
);
|
|
403
|
+
|
|
399
404
|
return visible ? (
|
|
400
405
|
<Form form={form}>
|
|
401
406
|
<div
|
|
@@ -416,7 +421,11 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
|
|
|
416
421
|
<Table
|
|
417
422
|
// {...restProps} // TODO: 不要这么透传,需要什么传什么,先注释,之后缺什么再补
|
|
418
423
|
{...tableProps}
|
|
419
|
-
locale={
|
|
424
|
+
locale={{
|
|
425
|
+
emptyText: (
|
|
426
|
+
<EmptyComp dataState={dataState} getLocale={getLocale} />
|
|
427
|
+
),
|
|
428
|
+
}}
|
|
420
429
|
ref={tableRef}
|
|
421
430
|
// loading={loading}
|
|
422
431
|
bordered={isBordered}
|
|
@@ -461,9 +470,10 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
|
|
|
461
470
|
};
|
|
462
471
|
}}
|
|
463
472
|
rowSelection={rowSelection}
|
|
464
|
-
|
|
473
|
+
// loading没有数据的时候模拟3个数据,当数据为空时依然展示骨架屏
|
|
474
|
+
dataSource={isEmptyLoading ? [{}, {}, {}] : sortDataSource}
|
|
465
475
|
expandable={realExpandable}
|
|
466
|
-
pagination={page && pagination}
|
|
476
|
+
pagination={isEmptyLoading ? false : page && pagination}
|
|
467
477
|
summary={(pageData: any[]) => (
|
|
468
478
|
<Table.Summary fixed={!!props?.scroll}>
|
|
469
479
|
<TableSummaryRow
|
|
@@ -471,6 +481,7 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
|
|
|
471
481
|
dataSource={pageData as any[]}
|
|
472
482
|
summary={props.summary}
|
|
473
483
|
summaryConfig={props?.summaryTotal}
|
|
484
|
+
selectionType={rowSelection?.type}
|
|
474
485
|
/>
|
|
475
486
|
</Table.Summary>
|
|
476
487
|
)}
|
|
@@ -515,6 +526,17 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
|
|
|
515
526
|
}
|
|
516
527
|
expandable={realExpandable}
|
|
517
528
|
pagination={false}
|
|
529
|
+
summary={(pageData: readonly any[]) => (
|
|
530
|
+
<Table.Summary fixed={!!props?.scroll}>
|
|
531
|
+
<TableSummaryRow
|
|
532
|
+
columns={finalcolumns}
|
|
533
|
+
dataSource={pageData as any[]}
|
|
534
|
+
summary={props.summary}
|
|
535
|
+
summaryConfig={props?.summaryTotal}
|
|
536
|
+
selectionType={rowSelection?.type}
|
|
537
|
+
/>
|
|
538
|
+
</Table.Summary>
|
|
539
|
+
)}
|
|
518
540
|
/>
|
|
519
541
|
</PrintContainer>
|
|
520
542
|
)}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FuncExpExeCuteType } from '../../utils/hooks/useFuncExpExecute';
|
|
2
|
+
|
|
3
|
+
export interface MyBodyCellProps {
|
|
4
|
+
editable: boolean;
|
|
5
|
+
isExtend: boolean;
|
|
6
|
+
dataIndex: string | number;
|
|
7
|
+
row: any;
|
|
8
|
+
rowId: string | number;
|
|
9
|
+
rowIndex: number;
|
|
10
|
+
children: any;
|
|
11
|
+
colorFormatInfo: any[];
|
|
12
|
+
isCustomRendering: boolean;
|
|
13
|
+
style?: any;
|
|
14
|
+
mode?: string;
|
|
15
|
+
funcExpExecute?: FuncExpExeCuteType;
|
|
16
|
+
engineApis?: any;
|
|
17
|
+
onTableCellClick?: (
|
|
18
|
+
row: Record<string, any>,
|
|
19
|
+
cell: any,
|
|
20
|
+
cellId: string | number,
|
|
21
|
+
) => void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
interface Page {
|
|
2
|
+
pageId: string;
|
|
3
|
+
pagePath: string;
|
|
4
|
+
currentPageVersionId: string;
|
|
5
|
+
searchParams?: any;
|
|
6
|
+
}
|
|
7
|
+
interface Modal {
|
|
8
|
+
pageId: string;
|
|
9
|
+
pagePath: string;
|
|
10
|
+
currentPageVersionId: string;
|
|
11
|
+
compStates?: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface FuncCode {
|
|
15
|
+
code: string;
|
|
16
|
+
originCode: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type DataBindType = FuncCode | string | undefined;
|
|
20
|
+
|
|
21
|
+
export interface ContentClick {
|
|
22
|
+
content?: DataBindType;
|
|
23
|
+
clickType?: string;
|
|
24
|
+
page?: Page;
|
|
25
|
+
modal?: Modal;
|
|
26
|
+
openType?: string;
|
|
27
|
+
fileIds?: DataBindType;
|
|
28
|
+
filename?: DataBindType;
|
|
29
|
+
previewType?: string;
|
|
30
|
+
downloadUrl?: DataBindType;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ContentStyle extends ContentClick {
|
|
34
|
+
formatStyle: number;
|
|
35
|
+
contentType: string;
|
|
36
|
+
fontColor: string;
|
|
37
|
+
borderColor: string;
|
|
38
|
+
backgroundColor: string;
|
|
39
|
+
modalWidth?: number;
|
|
40
|
+
modalHeight?: number;
|
|
41
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export interface TableBaseEventTypes {
|
|
2
|
+
/**
|
|
3
|
+
* 点击表格头排序图标时触发
|
|
4
|
+
* @param ascendCol
|
|
5
|
+
* @param descendCol
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
onSortChange?: (ascendCol?: string, descendCol?: string) => void;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 选中行变化时触发
|
|
12
|
+
* @param key
|
|
13
|
+
* @param row
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
onSelectChange?: (key: string, row: any) => void;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 头部按钮点击事件
|
|
20
|
+
*/
|
|
21
|
+
onHeadClickBtn1?: (e: any) => void;
|
|
22
|
+
onHeadClickBtn2?: (e: any) => void;
|
|
23
|
+
onHeadClickBtn3?: (e: any) => void;
|
|
24
|
+
onHeadClickBtn4?: (e: any) => void;
|
|
25
|
+
onHeadClickBtn5?: (e: any) => void;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 以下都是废弃的吧?
|
|
29
|
+
* @deprecated
|
|
30
|
+
*/
|
|
31
|
+
getEditVisible?: (e: any) => void | any;
|
|
32
|
+
getDeleteVisible?: (e: any) => void | any;
|
|
33
|
+
getDetailVisible?: (e: any) => void | any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TableRowExpandEventTypes {
|
|
37
|
+
/**
|
|
38
|
+
* 点击展开/收缩时触发
|
|
39
|
+
* @param expanded
|
|
40
|
+
* @param record
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
onExpand?: (expanded: boolean, record: any) => void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 展开行变换回调
|
|
47
|
+
* @param expandedRowKeys
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
onExpandedRowsChange?: (expandedRowKeys: any[]) => void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface TableEditEventTypes {
|
|
54
|
+
/**
|
|
55
|
+
* 点击内置的编辑按钮时触发
|
|
56
|
+
* @param key
|
|
57
|
+
* @param row
|
|
58
|
+
* @param index
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
onRowEdit?: (key: string, row: any, index: number | null) => void;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 点击内置的详情按钮时触发
|
|
65
|
+
* @param key
|
|
66
|
+
* @param row
|
|
67
|
+
* @param index
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
onRowDetail?: (key: string, row: any, index: number | null) => void;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 点击内置的删除按钮时触发
|
|
74
|
+
* @param key
|
|
75
|
+
* @param row
|
|
76
|
+
* @param index
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
onRowDelete?: (key: string, row: any, index: number | null) => void;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 点击行时触发
|
|
83
|
+
* @param key
|
|
84
|
+
* @param row
|
|
85
|
+
* @param index
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
onRowClick?: (key: any, row: any, index: any) => void;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 双击行时触发
|
|
92
|
+
* @param key
|
|
93
|
+
* @param row
|
|
94
|
+
* @param index
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
onRowDoubleClick?: (key: string, row: any, index: number) => void;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 开始行内编辑
|
|
101
|
+
* @param e
|
|
102
|
+
* @returns
|
|
103
|
+
*/
|
|
104
|
+
onBeforeInlineEdit?: (e: any) => void;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 保存行内编辑时触发
|
|
108
|
+
* @param data
|
|
109
|
+
* @param id
|
|
110
|
+
* @param index
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
onBeforeInlineSave?: (data: any, id: any, index: number | null) => void;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface TablePaginationEventTypes {
|
|
117
|
+
/**
|
|
118
|
+
* 页码改变回调时触发
|
|
119
|
+
* @param page
|
|
120
|
+
* @param size
|
|
121
|
+
* @returns
|
|
122
|
+
*/
|
|
123
|
+
onPageChange?: (page: React.SetStateAction<number>, size: number) => void;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type MyTableEventTypes = TableBaseEventTypes &
|
|
127
|
+
TableRowExpandEventTypes &
|
|
128
|
+
TableEditEventTypes &
|
|
129
|
+
TablePaginationEventTypes;
|