@lingxiteam/ebe-utils 0.2.21 → 0.2.23
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/h5public/yarn.lock +7 -8
- package/lib/pcpublic/src/components/pcfactory/src/Button/index.tsx +11 -10
- package/lib/pcpublic/src/components/pcfactory/src/Card/CardTitle/index.tsx +31 -24
- package/lib/pcpublic/src/components/pcfactory/src/Card/index.tsx +32 -14
- package/lib/pcpublic/src/components/pcfactory/src/Card/useExtendBtn.tsx +85 -48
- package/lib/pcpublic/src/components/pcfactory/src/ChartLine/ChartLine.tsx +24 -6
- package/lib/pcpublic/src/components/pcfactory/src/ChartLine/PropsType.ts +31 -5
- package/lib/pcpublic/src/components/pcfactory/src/ChartLine/index.tsx +3 -2
- package/lib/pcpublic/src/components/pcfactory/src/ChartLine/loader.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/Form/Form.tsx +153 -129
- package/lib/pcpublic/src/components/pcfactory/src/Form/index.tsx +2 -5
- package/lib/pcpublic/src/components/pcfactory/src/Form/useFormStatus.ts +8 -4
- package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/LXPieChart.tsx +15 -3
- package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/PropsType.ts +4 -3
- package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/loader.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/LXRadarChat.tsx +18 -4
- package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/PropsType.ts +2 -1
- package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/index.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/loader.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/BaseModalSelect.tsx +7 -2
- package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/index.tsx +60 -26
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/LcdpUeditorMain.tsx +62 -55
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditor.tsx +2 -6
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditorMain.tsx +5 -5
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/index.tsx +9 -2
- package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/loader.ts +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/Select/index.tsx +145 -66
- package/lib/pcpublic/src/components/pcfactory/src/Select/selectUtils.ts +13 -9
- package/lib/pcpublic/src/components/pcfactory/src/Table/BodyCell/index.tsx +36 -26
- package/lib/pcpublic/src/components/pcfactory/src/Table/EditComponent/index.tsx +69 -94
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/GhostTag/index.tsx +12 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Hyperlink/index.tsx +9 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PointTag/index.tsx +11 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureColourFill/index.tsx +11 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureFadeColourTag/index.tsx +14 -7
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Thumbnail/index.tsx +30 -31
- package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/index.tsx +89 -41
- package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/HeaderCellTitle/index.tsx +25 -12
- package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/index.tsx +12 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/PopoverWrapper.tsx +220 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/SingleBtn.tsx +39 -32
- package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/index.tsx +178 -148
- package/lib/pcpublic/src/components/pcfactory/src/Table/Table.tsx +439 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/TableHead/index.tsx +159 -72
- package/lib/pcpublic/src/components/pcfactory/src/Table/TableSummaryRow/index.tsx +12 -20
- package/lib/pcpublic/src/components/pcfactory/src/Table/constant.ts +3 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/index.ts +4 -4
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +32 -28
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCheckStrict.ts +44 -57
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +306 -276
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCommon.ts +9 -6
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useDataSource.ts +30 -21
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useExpandable.tsx +33 -27
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFilter.tsx +84 -77
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFormatCell.tsx +33 -16
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/usePagination.ts +15 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowEdit.ts +33 -33
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowMerge.ts +13 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useScroll.ts +94 -28
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSelection.ts +108 -99
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSort.ts +8 -5
- package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +27 -43
- package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +73 -394
- package/lib/pcpublic/src/components/pcfactory/src/Table/loader.tsx +15 -0
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/OperationCell.d.ts +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/event.d.ts +12 -8
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/headerCell.d.ts +2 -1
- package/lib/pcpublic/src/components/pcfactory/src/Table/types/prop.d.ts +24 -11
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/SequenceId.ts +2 -1
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +90 -82
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/indexedDBHelper.ts +9 -22
- package/lib/pcpublic/src/components/pcfactory/src/Table/utils/translate.ts +59 -0
- package/lib/pcpublic/src/components/pcfactory/src/Transfer/Transfer.tsx +644 -0
- package/lib/pcpublic/src/components/pcfactory/src/Transfer/index.tsx +49 -637
- package/lib/pcpublic/src/components/pcfactory/src/Transfer/loader.tsx +11 -0
- package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeEllipsisIcon.tsx +38 -0
- package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeNodeMenu/index.tsx +34 -35
- package/lib/pcpublic/src/components/pcfactory/src/Tree/index.tsx +213 -149
- package/lib/pcpublic/src/components/pcfactory/src/TreeSelect/index.tsx +47 -43
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/TreeTable.tsx +264 -0
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/index.ts +4 -1
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useCMDAction.ts +9 -3
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useExpandable.tsx +9 -3
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +52 -191
- package/lib/pcpublic/src/components/pcfactory/src/TreeTable/loader.tsx +16 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/index.tsx +34 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/svg/quadrate.tsx +20 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/svg/roundness.tsx +14 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/svg/semicircle.tsx +15 -0
- package/lib/pcpublic/src/components/pcfactory/src/assets/svg/verticalLine.tsx +12 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/common.less +17 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Card.less +57 -11
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Form.less +101 -12
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/ModalSelect.less +6 -0
- package/lib/pcpublic/src/components/pcfactory/src/styles/components/Select.less +70 -6
- package/lib/pcpublic/src/components/pcfactory/src/utils/ChannelContainer.tsx +20 -14
- package/lib/pcpublic/src/components/pcfactory/src/utils/ChildRender.ts +6 -8
- package/lib/pcpublic/src/components/pcfactory/src/utils/CustomModule.tsx +4 -6
- package/lib/pcpublic/src/components/pcfactory/src/utils/DummyFormContext.ts +9 -13
- package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/empty.tsx +5 -17
- package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/index.tsx +3 -3
- package/lib/pcpublic/src/components/pcfactory/src/utils/Holidays.ts +11 -39
- package/lib/pcpublic/src/components/pcfactory/src/utils/HolidaysFormat.ts +83 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/index.tsx +47 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/scheduler.ts +74 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/LoaderHelper.tsx +4 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/Spin/index.tsx +8 -7
- package/lib/pcpublic/src/components/pcfactory/src/utils/WithSyncValue.ts +25 -23
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/index.ts +10 -7
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMap.ts +9 -6
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMemoizedFn.ts +4 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/usePersistFn.ts +17 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSafeState.ts +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSetState.ts +7 -5
- package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +23 -50
- package/lib/pcpublic/src/components/pcfactory/src/utils/constant.ts +53 -57
- package/lib/pcpublic/src/components/pcfactory/src/utils/dynamicUtils/DynamicContext.tsx +12 -17
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormContext.tsx +22 -12
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormFields.tsx +50 -19
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/WrapperContainer.tsx +58 -37
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/cmdHelper.ts +33 -30
- package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/common.ts +2 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/generatorDisabledCallback.ts +121 -113
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCommonImperativeHandle.ts +16 -14
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCompState.tsx +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDataMask.ts +7 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDoubleClick.ts +3 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useFuncExpExecute.ts +16 -14
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useGetStaticAttrData.ts +9 -3
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useHiddenStyle.ts +4 -5
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInit.ts +11 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInitReactQuill.ts +3 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useListenState.ts +1 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useLocale.ts +5 -3
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/usePrintMode.tsx +2 -2
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useRules.ts +1 -1
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useTestHelper.ts +2 -0
- package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useToggleBoolean.ts +8 -4
- package/lib/pcpublic/src/components/pcfactory/src/utils/index.ts +10 -10
- package/lib/pcpublic/src/components/pcfactory/src/utils/polyfill.js +29 -31
- package/lib/pcpublic/src/components/pcfactory/src/utils/renderReadOnly.tsx +29 -26
- package/lib/public/public/iconfont.js +1 -0
- package/package.json +2 -2
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { TableProps } from 'antd/lib/table';
|
|
2
2
|
import type { MyTableEventTypes } from './event';
|
|
3
|
+
import { useCMDAction, useCommon, useDataSource, useExpandable, useFilter, usePagination, useRowEdit, useSelection, useSort } from '../hooks';
|
|
3
4
|
|
|
4
5
|
export type SummaryConfig = {
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 不合计|单列|多列
|
|
8
9
|
*/
|
|
9
|
-
type: 'none' | 'single' | 'multi'
|
|
10
|
+
type: 'none' | 'single' | 'multi',
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* 总结行名称
|
|
@@ -16,7 +17,7 @@ export type SummaryConfig = {
|
|
|
16
17
|
/**
|
|
17
18
|
* 单列合并值
|
|
18
19
|
*/
|
|
19
|
-
col?:
|
|
20
|
+
col?:Array<ColItem>;
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* 多列合并
|
|
@@ -26,13 +27,13 @@ export type SummaryConfig = {
|
|
|
26
27
|
/**
|
|
27
28
|
* 保留几位小数
|
|
28
29
|
*/
|
|
29
|
-
decimal?: number
|
|
30
|
+
decimal?: number,
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* 背景色
|
|
33
34
|
*/
|
|
34
35
|
background?: string;
|
|
35
|
-
}
|
|
36
|
+
}
|
|
36
37
|
export interface TableBasePropTypes extends TableProps<any> {
|
|
37
38
|
className?: string;
|
|
38
39
|
style?: React.CSSProperties;
|
|
@@ -134,6 +135,8 @@ export interface TableBasePropTypes extends TableProps<any> {
|
|
|
134
135
|
* 总结合计行
|
|
135
136
|
*/
|
|
136
137
|
summaryTotal?: SummaryConfig;
|
|
138
|
+
|
|
139
|
+
backgroundType?: any;
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
export interface TablePaginationPropTypes {
|
|
@@ -275,11 +278,9 @@ export interface TableRowSelectPropType {
|
|
|
275
278
|
/**
|
|
276
279
|
* 选择模式
|
|
277
280
|
*/
|
|
278
|
-
rowSelection?:
|
|
279
|
-
|
|
|
280
|
-
|
|
281
|
-
type: 'radio' | 'checkbox';
|
|
282
|
-
};
|
|
281
|
+
rowSelection?: false | {
|
|
282
|
+
type: 'radio' | 'checkbox'
|
|
283
|
+
};
|
|
283
284
|
|
|
284
285
|
/**
|
|
285
286
|
* 可选表格行选择是否禁用判断
|
|
@@ -292,12 +293,24 @@ export interface TableRowSelectPropType {
|
|
|
292
293
|
checkLoosed?: boolean;
|
|
293
294
|
}
|
|
294
295
|
|
|
295
|
-
export type
|
|
296
|
+
export type WrapperTablePropsTypes =
|
|
297
|
+
ReturnType<typeof useCommon> &
|
|
298
|
+
ReturnType<typeof useDataSource> &
|
|
299
|
+
ReturnType<typeof usePagination> &
|
|
300
|
+
ReturnType<typeof useRowEdit> &
|
|
301
|
+
ReturnType<typeof useExpandable> &
|
|
302
|
+
ReturnType<typeof useSort> &
|
|
303
|
+
ReturnType<typeof useFilter> &
|
|
304
|
+
ReturnType<typeof useCMDAction> &
|
|
305
|
+
ReturnType<typeof useSelection> & {form?: any};
|
|
306
|
+
|
|
307
|
+
export type MyTableProps =
|
|
308
|
+
TableBasePropTypes &
|
|
296
309
|
TablePaginationPropTypes &
|
|
297
310
|
TableEditPropTypes &
|
|
298
311
|
TableRowExpandPropTypes &
|
|
299
312
|
TableRowSelectPropType &
|
|
300
|
-
MyTableEventTypes
|
|
313
|
+
MyTableEventTypes
|
|
301
314
|
|
|
302
315
|
export type LevelItem<T> = {
|
|
303
316
|
__parent__?: LevelItem<T>;
|
|
@@ -5,7 +5,7 @@ interface SequenceIdOptions {
|
|
|
5
5
|
/**
|
|
6
6
|
* 创建id类型 random 随机 increment 自增
|
|
7
7
|
*/
|
|
8
|
-
type?: 'random' | 'increment'
|
|
8
|
+
type?: 'random' | 'increment',
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* 随机数创建的长度
|
|
@@ -34,6 +34,7 @@ const getRandomId = (randomBit = 6) => {
|
|
|
34
34
|
return t;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
class SequenceId {
|
|
38
39
|
private idMap: (string | number)[] = [];
|
|
39
40
|
|
|
@@ -8,13 +8,16 @@ export type SingleRowInfo = {
|
|
|
8
8
|
rowIdAndTitleColMap: any;
|
|
9
9
|
nextRowsChildren: any;
|
|
10
10
|
};
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
// 获取分组名称,为空的向下补全
|
|
13
13
|
const findGroupName = (groupList: string[], startIndex: number) => {
|
|
14
14
|
const list = groupList.slice(startIndex);
|
|
15
|
-
return list.find(g => !!g) || '';
|
|
15
|
+
return list.find((g) => !!g) || '';
|
|
16
16
|
};
|
|
17
|
-
export const handleMultiLevelHeader = (
|
|
17
|
+
export const handleMultiLevelHeader = (
|
|
18
|
+
leftTree: any,
|
|
19
|
+
column: any,
|
|
20
|
+
) => {
|
|
18
21
|
const { fixed = '' } = column;
|
|
19
22
|
let { group } = column;
|
|
20
23
|
|
|
@@ -24,7 +27,11 @@ export const handleMultiLevelHeader = (leftTree: any, column: any) => {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
// 兼容可能存在的空数据
|
|
27
|
-
if (
|
|
30
|
+
if (
|
|
31
|
+
group === '' ||
|
|
32
|
+
group === null ||
|
|
33
|
+
group === undefined
|
|
34
|
+
) {
|
|
28
35
|
group = [''];
|
|
29
36
|
}
|
|
30
37
|
|
|
@@ -37,9 +44,16 @@ export const handleMultiLevelHeader = (leftTree: any, column: any) => {
|
|
|
37
44
|
if (Array.isArray(group) && groupLen > 0) {
|
|
38
45
|
// 标记右树从哪个节点开始至最后一个都为空(undefined/null/'')
|
|
39
46
|
let groupEmptyStartIndex = groupLen - 1;
|
|
40
|
-
while (
|
|
47
|
+
while (
|
|
48
|
+
typeof group[groupEmptyStartIndex] === 'undefined' ||
|
|
49
|
+
group[groupEmptyStartIndex] === null ||
|
|
50
|
+
group[groupEmptyStartIndex] === ''
|
|
51
|
+
) {
|
|
41
52
|
// 当分组数据遍历完成 或 下一个已经不为空时,退出循环
|
|
42
|
-
if (
|
|
53
|
+
if (
|
|
54
|
+
groupEmptyStartIndex - 1 < 0 ||
|
|
55
|
+
group[groupEmptyStartIndex - 1]
|
|
56
|
+
) {
|
|
43
57
|
break;
|
|
44
58
|
}
|
|
45
59
|
groupEmptyStartIndex -= 1;
|
|
@@ -112,7 +126,8 @@ export const handleMultiLevelHeader = (leftTree: any, column: any) => {
|
|
|
112
126
|
leftTreeLast.children = [];
|
|
113
127
|
}
|
|
114
128
|
leftTreeLast.children.push(...(current?.children || []));
|
|
115
|
-
} else if (current && current?.title === leftTreeLast?.title
|
|
129
|
+
} else if (current && current?.title === leftTreeLast?.title
|
|
130
|
+
&& current?.fixed === leftTreeLast?.fixed) {
|
|
116
131
|
current.colSpanStart = leftTreeLast?.colSpanStart || leftTreeLast;
|
|
117
132
|
const colSpan = current?.colSpanStart?.colSpan || 1;
|
|
118
133
|
current.colSpanStart.colSpan = colSpan + 1;
|
|
@@ -127,16 +142,7 @@ export const handleMultiLevelHeader = (leftTree: any, column: any) => {
|
|
|
127
142
|
};
|
|
128
143
|
|
|
129
144
|
// 合并上下相同的分组
|
|
130
|
-
export const handleMergeHeader = <
|
|
131
|
-
T extends {
|
|
132
|
-
title?: string;
|
|
133
|
-
className?: string;
|
|
134
|
-
children?: T[];
|
|
135
|
-
colSpan?: number;
|
|
136
|
-
}
|
|
137
|
-
>(
|
|
138
|
-
columns?: Array<T>
|
|
139
|
-
) => {
|
|
145
|
+
export const handleMergeHeader = <T extends {title?: string; className?: string; children?: T[]; colSpan?: number}>(columns?: Array<T>) => {
|
|
140
146
|
const getRowSpan = (col: T) => {
|
|
141
147
|
let span = 1;
|
|
142
148
|
const newCol = { ...col };
|
|
@@ -144,7 +150,9 @@ export const handleMergeHeader = <
|
|
|
144
150
|
while (current !== null) {
|
|
145
151
|
if (current?.children?.length === 1) {
|
|
146
152
|
const next: T = current.children?.[0];
|
|
147
|
-
if (next.title === col?.title && col?.title
|
|
153
|
+
if (next.title === col?.title && col?.title
|
|
154
|
+
&& next.className !== hiddenHeaderCellClass
|
|
155
|
+
&& col?.colSpan === next?.colSpan) {
|
|
148
156
|
// 分组名一致,上下合并
|
|
149
157
|
span += 1;
|
|
150
158
|
next.className = hiddenHeaderCellClass;
|
|
@@ -162,7 +170,7 @@ export const handleMergeHeader = <
|
|
|
162
170
|
};
|
|
163
171
|
};
|
|
164
172
|
const recursive = (cols: T[]) => {
|
|
165
|
-
return cols.map(col => {
|
|
173
|
+
return cols.map((col) => {
|
|
166
174
|
if (col?.title) {
|
|
167
175
|
const { rowSpan } = getRowSpan(col);
|
|
168
176
|
if (rowSpan > 1) {
|
|
@@ -182,15 +190,20 @@ export const handleMergeHeader = <
|
|
|
182
190
|
return recursive(columns || []);
|
|
183
191
|
};
|
|
184
192
|
|
|
185
|
-
export const handleExpandColumn = ({
|
|
193
|
+
export const handleExpandColumn = ({
|
|
194
|
+
expandComponents,
|
|
195
|
+
expandIconPositionRef,
|
|
196
|
+
expandIconPosition,
|
|
197
|
+
columns,
|
|
198
|
+
}: any) => {
|
|
186
199
|
// 有设置扩展内容 且 存在行展开图标位置配置
|
|
187
200
|
if (Array.isArray(expandComponents) && expandComponents.length && expandIconPositionRef) {
|
|
188
201
|
// 找到行展开图标位置 基准列的索引(有可能也是分组)
|
|
189
|
-
const refColIndex = columns?.findIndex((c: {
|
|
202
|
+
const refColIndex = columns?.findIndex((c: {dataIndex: string | string[]; [key:string]: any}) => {
|
|
190
203
|
if (c.dataIndex) {
|
|
191
204
|
return `${c.dataIndex || ''}` === `${expandIconPositionRef?.dataIndex || ''}`;
|
|
192
205
|
}
|
|
193
|
-
|
|
206
|
+
|
|
194
207
|
if (c.title) {
|
|
195
208
|
return c.title === expandIconPositionRef?.title;
|
|
196
209
|
}
|
|
@@ -220,39 +233,50 @@ export const createTempRowKey = () => {
|
|
|
220
233
|
|
|
221
234
|
export const EMPTY_ROW_TEMP_KEY_ATTR = '_lxTempKey';
|
|
222
235
|
export const LATEST_EMPTY_ROW_FLAG_ATTR = '_latestCreation';
|
|
236
|
+
// 保存当前行时根据是否需要更新数据源做处理
|
|
237
|
+
export const UPDATE_DATA_SOURCE_FLAG = '_updateDataSource';
|
|
223
238
|
|
|
239
|
+
// 清除表格数据中新增空白行数据增加的临时属性,如_latestCreation,_updateDataSource等
|
|
224
240
|
export const deleteTempRowProperties = (row: any) => {
|
|
225
241
|
if (row) {
|
|
226
242
|
delete row[LATEST_EMPTY_ROW_FLAG_ATTR];
|
|
243
|
+
delete row[UPDATE_DATA_SOURCE_FLAG];
|
|
227
244
|
}
|
|
228
245
|
};
|
|
229
246
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
247
|
+
/**
|
|
248
|
+
* 新增空白行数据
|
|
249
|
+
* @param needUpdateDataSource 是否需要同步数据源,打标,保存当前行时根据该标识决定是否要上报数据源
|
|
250
|
+
* @returns
|
|
251
|
+
*/
|
|
252
|
+
export const createEmptyRow = (needUpdateDataSource: boolean) => {
|
|
253
|
+
const row: any = ({
|
|
254
|
+
[LATEST_EMPTY_ROW_FLAG_ATTR]: true, // 最新创建的
|
|
255
|
+
[EMPTY_ROW_TEMP_KEY_ATTR]: createTempRowKey(),
|
|
256
|
+
});
|
|
257
|
+
if (needUpdateDataSource) {
|
|
258
|
+
row[UPDATE_DATA_SOURCE_FLAG] = needUpdateDataSource;
|
|
259
|
+
}
|
|
260
|
+
return row;
|
|
261
|
+
};
|
|
234
262
|
|
|
235
|
-
export const handleRecursiveParseColumns = (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
fontWeight?: number;
|
|
251
|
-
fontSize?: string;
|
|
252
|
-
};
|
|
253
|
-
};
|
|
263
|
+
export const handleRecursiveParseColumns = (columnList: any[], rowIndex = 1, styleInfo?: {
|
|
264
|
+
colorType: 'custom' | 'single',
|
|
265
|
+
singleColorSetting?: {
|
|
266
|
+
backgroundColor?: string,
|
|
267
|
+
color?: string,
|
|
268
|
+
fontWeight?: number,
|
|
269
|
+
fontSize?: string,
|
|
270
|
+
},
|
|
271
|
+
customColorSetting?: {
|
|
272
|
+
[id: string] : {
|
|
273
|
+
backgroundColor?: string,
|
|
274
|
+
color?: string,
|
|
275
|
+
fontWeight?: number,
|
|
276
|
+
fontSize?: string,
|
|
277
|
+
}
|
|
254
278
|
}
|
|
255
|
-
) => {
|
|
279
|
+
}) => {
|
|
256
280
|
const colChildList: any[] = [];
|
|
257
281
|
let colIdMap: { [id: string]: any } = {};
|
|
258
282
|
let cols = columnList;
|
|
@@ -321,19 +345,19 @@ export const compareFn = (a: any, b: any) => {
|
|
|
321
345
|
const [, nextNegative, , nextDecimal = '', nextUnit] = nextMatch;
|
|
322
346
|
// 单位一致才比较,否则按字符串比
|
|
323
347
|
// 其中有一个为空值时,也进行比较
|
|
324
|
-
if (prevUnit === nextUnit || !a || !b) {
|
|
348
|
+
if ((prevUnit === nextUnit) || !a || !b) {
|
|
325
349
|
if (prevNegative !== nextNegative) {
|
|
326
350
|
// 一正一负,正的大
|
|
327
351
|
return prevNegative ? -1 : 1;
|
|
328
352
|
}
|
|
329
353
|
if (prevNegative === nextNegative) {
|
|
330
354
|
// 两数间最长的小数位长度
|
|
331
|
-
const expandedLen = prevDecimal.length > nextDecimal?.length ? prevDecimal.length - 1 : nextDecimal.length - 1;
|
|
355
|
+
const expandedLen = prevDecimal.length > nextDecimal?.length ? (prevDecimal.length - 1) : (nextDecimal.length - 1);
|
|
332
356
|
const expand = (decimal: string, len: number) => {
|
|
333
357
|
// 小数部分内容
|
|
334
358
|
const num = decimal.indexOf('.') === 0 ? decimal.slice(1) : decimal;
|
|
335
359
|
// 长度不一的小数进行补位
|
|
336
|
-
const zero = len - num.length > 0 ? new Array(len - num.length).fill('0') : [];
|
|
360
|
+
const zero = (len - num.length) > 0 ? (new Array(len - num.length)).fill('0') : [];
|
|
337
361
|
return `${num}${zero.join('')}`;
|
|
338
362
|
};
|
|
339
363
|
// 小数时两个数字同时扩大
|
|
@@ -360,10 +384,10 @@ export function recursionDataSource<T extends Record<string, any>, U extends T =
|
|
|
360
384
|
dataSource: T[],
|
|
361
385
|
parseNodeFn?: (node: T, parentPath?: U[]) => U | void,
|
|
362
386
|
childrenKey: string = 'children',
|
|
363
|
-
parentPath: U[] = []
|
|
387
|
+
parentPath: U[] = [],
|
|
364
388
|
) {
|
|
365
389
|
if (!Array.isArray(dataSource)) return dataSource;
|
|
366
|
-
return dataSource.map(d => {
|
|
390
|
+
return dataSource.map((d) => {
|
|
367
391
|
let data: Record<string, any> = {
|
|
368
392
|
...d,
|
|
369
393
|
};
|
|
@@ -375,15 +399,18 @@ export function recursionDataSource<T extends Record<string, any>, U extends T =
|
|
|
375
399
|
}
|
|
376
400
|
}
|
|
377
401
|
if (Array.isArray(data[childrenKey]) && data[childrenKey].length) {
|
|
378
|
-
data[childrenKey] = recursionDataSource(data[childrenKey], parseNodeFn, childrenKey, [...parentPath, data as U]);
|
|
402
|
+
data[childrenKey] = recursionDataSource(data[childrenKey], parseNodeFn, childrenKey, [...parentPath, data as U],);
|
|
379
403
|
}
|
|
380
404
|
|
|
381
405
|
return data;
|
|
382
406
|
});
|
|
383
407
|
}
|
|
384
408
|
|
|
409
|
+
|
|
385
410
|
// 根据选中节点由下往上计算包含父节点在内的选中key
|
|
386
|
-
export const getFullCheckedKeySet = <
|
|
411
|
+
export const getFullCheckedKeySet = <
|
|
412
|
+
T extends {},
|
|
413
|
+
>(params: {
|
|
387
414
|
levelEntries: Map<number, LevelItem<T>[]>;
|
|
388
415
|
maxLevel: number;
|
|
389
416
|
currentCheckedKey: (string | number)[];
|
|
@@ -392,23 +419,19 @@ export const getFullCheckedKeySet = <T extends {}>(params: {
|
|
|
392
419
|
}) => {
|
|
393
420
|
const { maxLevel, levelEntries, currentCheckedKey, checked, disabledMap } = params;
|
|
394
421
|
// key格式做弱等类型判断
|
|
395
|
-
const checkedLooseMap =
|
|
396
|
-
|
|
397
|
-
return p;
|
|
398
|
-
}, {} as Record<string | number, string | number>);
|
|
422
|
+
const checkedLooseMap =
|
|
423
|
+
currentCheckedKey.reduce((p, n) => { p[n] = n; return p; }, {} as Record<string|number, string|number>);
|
|
399
424
|
const visitedKey = new Set();
|
|
400
425
|
// 从下往上收集选中的父节点
|
|
401
426
|
for (let level = maxLevel; level >= 0; level -= 1) {
|
|
402
427
|
const levelList = levelEntries.get(level);
|
|
403
|
-
levelList?.forEach(node => {
|
|
428
|
+
levelList?.forEach((node) => {
|
|
404
429
|
let allChecked = true;
|
|
405
430
|
const parent = node.__parent__;
|
|
406
|
-
if (parent && (disabledMap[parent?.__key__] || visitedKey.has(parent.__key__)))
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
431
|
+
if (parent && (disabledMap[parent?.__key__] || visitedKey.has(parent.__key__))) return;
|
|
409
432
|
if (disabledMap[node?.__key__]) return;
|
|
410
|
-
const siblings = parent?.__children__?.filter(c => !disabledMap[c.__key__]);
|
|
411
|
-
siblings?.forEach(child => {
|
|
433
|
+
const siblings = parent?.__children__?.filter((c) => !disabledMap[c.__key__]);
|
|
434
|
+
siblings?.forEach((child) => {
|
|
412
435
|
// 子节点都选中,父节点也要选中
|
|
413
436
|
if (allChecked && !checkedLooseMap[child.__key__]) {
|
|
414
437
|
allChecked = false;
|
|
@@ -427,25 +450,10 @@ export const getFullCheckedKeySet = <T extends {}>(params: {
|
|
|
427
450
|
}
|
|
428
451
|
});
|
|
429
452
|
}
|
|
430
|
-
return new Set(
|
|
431
|
-
Object.keys(checkedLooseMap).reduce((p, n) => {
|
|
432
|
-
p.push(checkedLooseMap[n]);
|
|
433
|
-
return p;
|
|
434
|
-
}, [] as (string | number)[])
|
|
435
|
-
);
|
|
453
|
+
return new Set(Object.keys(checkedLooseMap).reduce((p, n) => { p.push(checkedLooseMap[n]); return p; }, [] as (string|number)[]));
|
|
436
454
|
};
|
|
437
455
|
|
|
438
456
|
// 获取编辑组件表单项字段编码
|
|
439
|
-
export const getFormItemFieldName = ({
|
|
440
|
-
compId,
|
|
441
|
-
currentRowKey
|
|
442
|
-
rowData,
|
|
443
|
-
rowId,
|
|
444
|
-
dataIndex,
|
|
445
|
-
}: {
|
|
446
|
-
compId: string;
|
|
447
|
-
currentRowKey: string;
|
|
448
|
-
rowData: any;
|
|
449
|
-
rowId?: string | number;
|
|
450
|
-
dataIndex: string | string[];
|
|
451
|
-
}) => `${compId}_${currentRowKey}_${rowData[currentRowKey] || rowId}_${dataIndex}`;
|
|
457
|
+
export const getFormItemFieldName = ({ compId, currentRowKey, rowData, rowId, dataIndex }:
|
|
458
|
+
{compId: string, currentRowKey: string; rowData: any; rowId?: string | number; dataIndex: string | string[]}) =>
|
|
459
|
+
`${compId}_${currentRowKey}_${rowData[currentRowKey] || rowId}_${dataIndex}`;
|
|
@@ -13,12 +13,12 @@ const DBNAME = 'TABLE_CUSTOM';
|
|
|
13
13
|
const isIE = !!((window as any).ActiveXObject || 'ActiveXObject' in window);
|
|
14
14
|
|
|
15
15
|
const getOrSaveData = (actionData: DataProps) => {
|
|
16
|
-
return new Promise(resolve => {
|
|
17
|
-
const pagePatch = window.location.hash?.match(PATTERN)?.[0]?.replace(/^#\//, '') || '';
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const pagePatch = (window.location.hash?.match(PATTERN))?.[0]?.replace(/^#\//, '') || '';
|
|
18
18
|
const pageKey = `${actionData.appId}_${pagePatch}_${actionData.userId}`;
|
|
19
19
|
// 兼容浏览器
|
|
20
20
|
const indexedDB = window.indexedDB || (window as any).mozIndexedDB || (window as any).webkitIndexedDB || (window as any).msIndexedDB;
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
if (indexedDB) {
|
|
23
23
|
let version = new Date().getTime();
|
|
24
24
|
if (isIE) {
|
|
@@ -35,11 +35,7 @@ const getOrSaveData = (actionData: DataProps) => {
|
|
|
35
35
|
const objectStore = transaction.objectStore(pageKey);
|
|
36
36
|
// 保存数据
|
|
37
37
|
if (actionData.save) {
|
|
38
|
-
const actionPut = objectStore.put({
|
|
39
|
-
ORDER: actionData.order,
|
|
40
|
-
SELECTED: actionData.selected,
|
|
41
|
-
id: actionData.compId,
|
|
42
|
-
});
|
|
38
|
+
const actionPut = objectStore.put({ ORDER: actionData.order, SELECTED: actionData.selected, id: actionData.compId });
|
|
43
39
|
actionPut.onsuccess = (e: any) => {
|
|
44
40
|
// console.log('数组插入成功');
|
|
45
41
|
db.close();
|
|
@@ -47,8 +43,7 @@ const getOrSaveData = (actionData: DataProps) => {
|
|
|
47
43
|
actionPut.onerror = () => {
|
|
48
44
|
db.close();
|
|
49
45
|
};
|
|
50
|
-
} else {
|
|
51
|
-
// 读取数据
|
|
46
|
+
} else { // 读取数据
|
|
52
47
|
const action = objectStore.get(actionData.compId);
|
|
53
48
|
action.onsuccess = (e: any) => {
|
|
54
49
|
// 获取对象成功
|
|
@@ -62,7 +57,7 @@ const getOrSaveData = (actionData: DataProps) => {
|
|
|
62
57
|
}
|
|
63
58
|
};
|
|
64
59
|
// 数据库打开失败的回调
|
|
65
|
-
request.onerror = event => {
|
|
60
|
+
request.onerror = (event) => {
|
|
66
61
|
console.log('indexedDB数据库打开报错:', event);
|
|
67
62
|
resolve({});
|
|
68
63
|
};
|
|
@@ -76,7 +71,7 @@ const getOrSaveData = (actionData: DataProps) => {
|
|
|
76
71
|
}
|
|
77
72
|
};
|
|
78
73
|
} else {
|
|
79
|
-
|
|
74
|
+
// 不支持indexDB,就用localStorage存储
|
|
80
75
|
const allData: any = JSON.parse(window.localStorage.getItem(DBNAME) || '{}');
|
|
81
76
|
if (actionData.save) {
|
|
82
77
|
// 超过100个就删掉一些
|
|
@@ -87,17 +82,9 @@ const getOrSaveData = (actionData: DataProps) => {
|
|
|
87
82
|
allKeys = Object.keys(allData);
|
|
88
83
|
if (allKeys.includes(pageKey)) {
|
|
89
84
|
const data: any = allData[pageKey];
|
|
90
|
-
data[actionData.compId] = {
|
|
91
|
-
ORDER: actionData.order,
|
|
92
|
-
SELECTED: actionData.selected,
|
|
93
|
-
};
|
|
85
|
+
data[actionData.compId] = { ORDER: actionData.order, SELECTED: actionData.selected };
|
|
94
86
|
} else {
|
|
95
|
-
allData[pageKey] = {
|
|
96
|
-
[actionData.compId]: {
|
|
97
|
-
ORDER: actionData.order,
|
|
98
|
-
SELECTED: actionData.selected,
|
|
99
|
-
},
|
|
100
|
-
};
|
|
87
|
+
allData[pageKey] = { [actionData.compId]: { ORDER: actionData.order, SELECTED: actionData.selected } };
|
|
101
88
|
}
|
|
102
89
|
window.localStorage.setItem(DBNAME, JSON.stringify(allData));
|
|
103
90
|
} else if (allData?.[pageKey]?.[actionData.compId]) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* 翻译静态数据 按照如下查找
|
|
4
|
+
*
|
|
5
|
+
* 1、第一个平级找到,第二个平级找到,后面都是平级找到
|
|
6
|
+
2、第一个平级找到,第二个子级找到,后面都是从上一个子级找
|
|
7
|
+
3、第一个平级找到,第二个找不到,后面都是平级找
|
|
8
|
+
4、第一个找不到,后面都是平级找
|
|
9
|
+
*/
|
|
10
|
+
export const translateStaticData = (text: string, staticDataSource: any) => {
|
|
11
|
+
if (!text) return text;
|
|
12
|
+
if (!Array.isArray(staticDataSource)) return text;
|
|
13
|
+
|
|
14
|
+
const translateContentArr = (Array.isArray(text) ? text : String(text).split(','));
|
|
15
|
+
|
|
16
|
+
if (translateContentArr.length === 0) return text;
|
|
17
|
+
|
|
18
|
+
const findTranslateInfo = (a: string, list: any[] = staticDataSource) => {
|
|
19
|
+
return list?.find(o => `${o.value}` === `${a}`);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// 平级翻译出所有数据
|
|
23
|
+
const flattenTranslateText = () => translateContentArr?.map(it => findTranslateInfo(it)?.label ?? it).join(',');
|
|
24
|
+
|
|
25
|
+
// 先翻译出第一个数据
|
|
26
|
+
const firstTranslateContent = findTranslateInfo(translateContentArr[0]);
|
|
27
|
+
|
|
28
|
+
// 第一个翻译不出来,其他全部平级
|
|
29
|
+
if (!firstTranslateContent) return flattenTranslateText();
|
|
30
|
+
|
|
31
|
+
// 再翻译出第二个
|
|
32
|
+
let secondTranslateContent = findTranslateInfo(translateContentArr[1]);
|
|
33
|
+
// 如果翻译过来了,就直接返回所有
|
|
34
|
+
if (secondTranslateContent) return flattenTranslateText();
|
|
35
|
+
|
|
36
|
+
// 深层查找 根据第一个元素深层查找第二个
|
|
37
|
+
secondTranslateContent = findTranslateInfo(translateContentArr[1], firstTranslateContent.children || []);
|
|
38
|
+
|
|
39
|
+
// 深层查找没翻译出来
|
|
40
|
+
if (!secondTranslateContent) return flattenTranslateText();
|
|
41
|
+
|
|
42
|
+
// 深层查找找到数据后 剩下的递归查找
|
|
43
|
+
const treeTranslateText = () => {
|
|
44
|
+
let data = staticDataSource;
|
|
45
|
+
const result: string[] = [];
|
|
46
|
+
for (let index = 0; index < translateContentArr.length; index += 1) {
|
|
47
|
+
const element = translateContentArr[index];
|
|
48
|
+
const info = findTranslateInfo(element, data);
|
|
49
|
+
if (!info) return result.join(',');
|
|
50
|
+
if (info) {
|
|
51
|
+
data = info.children;
|
|
52
|
+
result.push(info.label ?? element);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return result.join(',');
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return treeTranslateText();
|
|
59
|
+
};
|