@lingxiteam/ebe-utils 0.4.4 → 0.4.6
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.
|
@@ -10,11 +10,7 @@ import BodyCell from './BodyCell';
|
|
|
10
10
|
import HeaderCell from './HeaderCell';
|
|
11
11
|
import TableHead from './TableHead';
|
|
12
12
|
import { useFuncExpExecute } from '../utils/hooks/useFuncExpExecute';
|
|
13
|
-
import {
|
|
14
|
-
useColumns,
|
|
15
|
-
useRowMerge,
|
|
16
|
-
useScroll,
|
|
17
|
-
} from './hooks';
|
|
13
|
+
import { useColumns, useRowMerge, useScroll } from './hooks';
|
|
18
14
|
import type { MyTableProps, WrapperTablePropsTypes } from './types/prop';
|
|
19
15
|
import EmptyComp from '../utils/Empty';
|
|
20
16
|
import { usePrintMode, PrintContainer } from '../utils';
|
|
@@ -74,7 +70,6 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
74
70
|
form,
|
|
75
71
|
...restProps
|
|
76
72
|
} = props;
|
|
77
|
-
|
|
78
73
|
|
|
79
74
|
const { uid: compId } = $$componentItem;
|
|
80
75
|
const { size, sortDirections, sticky, summary, tableLayout, title, rowClassName, showHeader = true } = restProps || {};
|
|
@@ -91,11 +86,7 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
91
86
|
const engineApis = getEngineApis?.();
|
|
92
87
|
const { backgroundStyle } = useBackgroundStyle({ backgroundType, engineApis, appId: $$componentItem?.appId, mode: 'engine' });
|
|
93
88
|
|
|
94
|
-
const {
|
|
95
|
-
sandBoxSafeRun,
|
|
96
|
-
dataState,
|
|
97
|
-
} = engineApis || {};
|
|
98
|
-
|
|
89
|
+
const { sandBoxSafeRun, dataState } = engineApis || {};
|
|
99
90
|
|
|
100
91
|
const { getLocale } = useLocale(engineApis || {});
|
|
101
92
|
|
|
@@ -104,11 +95,7 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
104
95
|
const appId = props?.appId || $$componentItem?.appId;
|
|
105
96
|
const pageId = props?.pageId || $$componentItem?.pageId;
|
|
106
97
|
|
|
107
|
-
const {
|
|
108
|
-
rowSpanColMap,
|
|
109
|
-
rowSpanMap,
|
|
110
|
-
rowClassMap,
|
|
111
|
-
} = useRowMerge({
|
|
98
|
+
const { rowSpanColMap, rowSpanMap, rowClassMap } = useRowMerge({
|
|
112
99
|
...props,
|
|
113
100
|
currentPageDataSource,
|
|
114
101
|
nowInlineEditKey,
|
|
@@ -211,12 +198,7 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
211
198
|
innerTableStyle.overflowY = styles.overflowY;
|
|
212
199
|
}
|
|
213
200
|
|
|
214
|
-
const handleTableChange = (
|
|
215
|
-
newPagination: any,
|
|
216
|
-
newFilters: any,
|
|
217
|
-
newSorter: any,
|
|
218
|
-
newExtra: any,
|
|
219
|
-
) => {
|
|
201
|
+
const handleTableChange = (newPagination: any, newFilters: any, newSorter: any, newExtra: any) => {
|
|
220
202
|
if (typeof onChange === 'function') {
|
|
221
203
|
onChange(newPagination, newFilters, newSorter, newExtra);
|
|
222
204
|
}
|
|
@@ -227,7 +209,7 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
227
209
|
newPagination?.current,
|
|
228
210
|
newPagination?.pageSize,
|
|
229
211
|
newSorter?.order === 'ascend' ? newSorter?.field : undefined,
|
|
230
|
-
newSorter?.order === 'descend' ? newSorter?.field : undefined
|
|
212
|
+
newSorter?.order === 'descend' ? newSorter?.field : undefined
|
|
231
213
|
);
|
|
232
214
|
return;
|
|
233
215
|
}
|
|
@@ -266,13 +248,15 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
266
248
|
// }, [columnWidth]);
|
|
267
249
|
|
|
268
250
|
const InnerHeaderCell = useMemo(() => {
|
|
269
|
-
return (info: any) =>
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
251
|
+
return (info: any) => (
|
|
252
|
+
<HeaderCell
|
|
253
|
+
{...info}
|
|
254
|
+
key={info.columnIndex}
|
|
255
|
+
tableData={sortDataSource}
|
|
256
|
+
hasExpandContent={hasExpandContent}
|
|
257
|
+
childrenColumnName={realExpandable.childrenColumnName}
|
|
258
|
+
/>
|
|
259
|
+
);
|
|
276
260
|
}, [sortDataSource, hasExpandContent, realExpandable.childrenColumnName]);
|
|
277
261
|
const eleProps = {
|
|
278
262
|
appId,
|
|
@@ -284,15 +268,7 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
284
268
|
|
|
285
269
|
return visible ? (
|
|
286
270
|
<>
|
|
287
|
-
<div
|
|
288
|
-
{...eleProps}
|
|
289
|
-
style={{ ...backgroundStyle, ...styles }}
|
|
290
|
-
className={classnames(
|
|
291
|
-
'ued-table-wrap',
|
|
292
|
-
className,
|
|
293
|
-
)}
|
|
294
|
-
ref={tableWrapRef}
|
|
295
|
-
>
|
|
271
|
+
<div {...eleProps} style={{ ...backgroundStyle, ...styles }} className={classnames('ued-table-wrap', className)} ref={tableWrapRef}>
|
|
296
272
|
<TableHead
|
|
297
273
|
{...restProps}
|
|
298
274
|
source="engine"
|
|
@@ -305,14 +281,14 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
305
281
|
/>
|
|
306
282
|
<Form form={form}>
|
|
307
283
|
<Table
|
|
308
|
-
|
|
284
|
+
// {...restProps} // TODO: 不要这么透传,需要什么传什么,先注释,之后缺什么再补
|
|
309
285
|
{...tableProps}
|
|
310
286
|
showHeader={showHeader}
|
|
311
287
|
locale={{
|
|
312
288
|
emptyText: <EmptyComp dataState={dataState} getLocale={getLocale} />,
|
|
313
289
|
}}
|
|
314
290
|
ref={tableRef}
|
|
315
|
-
|
|
291
|
+
// loading={loading}
|
|
316
292
|
bordered={isBordered}
|
|
317
293
|
className={innerClassName}
|
|
318
294
|
style={innerTableStyle}
|
|
@@ -336,7 +312,7 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
336
312
|
scroll={scroll}
|
|
337
313
|
onChange={handleTableChange}
|
|
338
314
|
onRow={(record) => {
|
|
339
|
-
return
|
|
315
|
+
return {
|
|
340
316
|
onClick: (event) => {
|
|
341
317
|
const hasOnRowClick = onRowClick(event, record, getRealIndexById(record[currentRowKey]));
|
|
342
318
|
!hasOnRowClick && onRowSelectClick(record, getRealIndexById(record[currentRowKey]));
|
|
@@ -344,13 +320,13 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
344
320
|
onDoubleClick: (event) => {
|
|
345
321
|
onRowDoubleClick(event, record, getRealIndexById(record[currentRowKey]));
|
|
346
322
|
},
|
|
347
|
-
onContextMenu: (event) => {
|
|
348
|
-
onMouseEnter: (event) => {
|
|
349
|
-
onMouseLeave: (event) => {
|
|
350
|
-
}
|
|
323
|
+
onContextMenu: (event) => {},
|
|
324
|
+
onMouseEnter: (event) => {}, // 鼠标移入行
|
|
325
|
+
onMouseLeave: (event) => {},
|
|
326
|
+
};
|
|
351
327
|
}}
|
|
352
|
-
rowSelection={rowSelection}
|
|
353
|
-
|
|
328
|
+
rowSelection={rowSelection && rowSelection?.type ? rowSelection : false}
|
|
329
|
+
// loading没有数据的时候模拟3个数据,当数据为空时依然展示骨架屏
|
|
354
330
|
dataSource={isEmptyLoading ? [{}, {}, {}] : sortDataSource}
|
|
355
331
|
expandable={realExpandable}
|
|
356
332
|
pagination={isEmptyLoading ? false : page && pagination}
|
|
@@ -401,12 +377,14 @@ const MyTable = LingxiForwardRef<any, Omit<MyTableProps, keyof WrapperTableProps
|
|
|
401
377
|
cell: BodyCell,
|
|
402
378
|
},
|
|
403
379
|
header: {
|
|
404
|
-
cell: (info: any) =>
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
380
|
+
cell: (info: any) => (
|
|
381
|
+
<HeaderCell
|
|
382
|
+
{...info}
|
|
383
|
+
tableData={printData?.dataSource?.length > 0 ? printData.dataSource : sortDataSource}
|
|
384
|
+
childrenColumnName={realExpandable.childrenColumnName}
|
|
385
|
+
hasExpandContent={hasExpandContent}
|
|
386
|
+
/>
|
|
387
|
+
),
|
|
410
388
|
},
|
|
411
389
|
}}
|
|
412
390
|
columns={printColumns.map((item, index) => {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import LcdpBaseApi from './lcdpBaseApi';
|
|
2
|
+
import { historytool, HISTORYTYPES } from '@/utils/historytool';
|
|
3
|
+
import { history } from 'alita';
|
|
4
|
+
import message from 'antd/es/message';
|
|
5
|
+
import DrawerMap from '@/components/drawer';
|
|
6
|
+
import ModalMap from '@/components/modal';
|
|
2
7
|
|
|
3
8
|
export declare type LocaleFunction = (key: string, placeholder?: string, kv?: Record<string, string>) => string;
|
|
4
9
|
// 对应用全局数据和全局方法访问的接口对象,为自定义代码提供更多可能性
|
|
@@ -15,26 +20,6 @@ class LcdpApi extends LcdpBaseApi {
|
|
|
15
20
|
/* @__HOT_UPDATE__ @alias LcdpApi */
|
|
16
21
|
constructor(mountObj?: any, singletonLcdpApi?: any) {
|
|
17
22
|
super(mountObj, singletonLcdpApi);
|
|
18
|
-
// 废弃
|
|
19
|
-
// this.mount(mountObj);
|
|
20
|
-
if (singletonLcdpApi) {
|
|
21
|
-
// router 只应该由singletonLcdpApi访问
|
|
22
|
-
['router'].forEach(k => {
|
|
23
|
-
(() => {
|
|
24
|
-
// eslint-disable-next-line
|
|
25
|
-
let val = null;
|
|
26
|
-
Object.defineProperty(this, k, {
|
|
27
|
-
get() {
|
|
28
|
-
return (url: string, lcdpParentRenderId: string, state?: Record<string, any>) =>
|
|
29
|
-
singletonLcdpApi[k](url, this.data.pages, this.data.appConfig.appId, lcdpParentRenderId, state);
|
|
30
|
-
},
|
|
31
|
-
set(value) {
|
|
32
|
-
val = value;
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
})();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
23
|
}
|
|
39
24
|
|
|
40
25
|
/**
|
|
@@ -46,89 +31,39 @@ class LcdpApi extends LcdpBaseApi {
|
|
|
46
31
|
* @param state 组件状态数据
|
|
47
32
|
*/
|
|
48
33
|
router(url: string, currentAppPages: Array<any>, appId: string, lcdpParentRenderId: string, state?: Record<string, any>) {
|
|
49
|
-
const { message } = this.antd;
|
|
50
34
|
if (!url) {
|
|
51
35
|
message?.warning(this.getLocale('lcdpApi.router.urlEmpty', '页面跳转地址缺失,请检查'));
|
|
52
36
|
}
|
|
53
|
-
if (/^((http|https):)?\/\/[^\s]+/.test(url)
|
|
37
|
+
if (/^((http|https):)?\/\/[^\s]+/.test(url)) {
|
|
54
38
|
window.location.href = url;
|
|
55
39
|
} else {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
: currentAppPages.find((n: any) => url.split('?').includes(n.pagePath));
|
|
63
|
-
}
|
|
64
|
-
// this.data.pages 包含所有应用页面
|
|
65
|
-
if (!pageData) {
|
|
66
|
-
pageData = isPageId
|
|
67
|
-
? this.data.pages.find((n: any) => n.pageId === url)
|
|
68
|
-
: this.data.pages.find((n: any) => url.split('?').includes(n.pagePath));
|
|
69
|
-
}
|
|
70
|
-
if (pageData) {
|
|
71
|
-
const [pathname, search] = url.split('?');
|
|
72
|
-
const searchPamams = search
|
|
73
|
-
? search.split('&').reduce((pre: any, cur: any) => {
|
|
74
|
-
const [k, v] = cur.split('=');
|
|
75
|
-
if (v) {
|
|
76
|
-
pre[decodeURIComponent(k)] = decodeURIComponent(v);
|
|
77
|
-
}
|
|
78
|
-
return pre;
|
|
79
|
-
}, {})
|
|
80
|
-
: {};
|
|
81
|
-
switch (pageData.pageContainerType) {
|
|
82
|
-
case 'Page': {
|
|
83
|
-
let realSearch = search;
|
|
84
|
-
if (!searchPamams?.appId) {
|
|
85
|
-
realSearch = `${search === undefined ? '?' : `${search}&`}appId=${pageData.appId || appId}`;
|
|
86
|
-
}
|
|
87
|
-
this.refs.history.push({
|
|
88
|
-
pathname,
|
|
89
|
-
search: realSearch,
|
|
90
|
-
});
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
case 'Drawer': {
|
|
94
|
-
try {
|
|
95
|
-
this.refs.ModalManager.current.openDrawer({
|
|
96
|
-
pageId: pageData.pageId,
|
|
97
|
-
params: {
|
|
98
|
-
...searchPamams,
|
|
99
|
-
...state,
|
|
100
|
-
},
|
|
101
|
-
lcdpParentRenderId,
|
|
102
|
-
});
|
|
103
|
-
} catch (e) {
|
|
104
|
-
console.error(e);
|
|
105
|
-
message?.warning(this.getLocale('lcdpApi.router.openFail', '打开新页面失败,缺失Drawer', { type: 'Drawer' }));
|
|
106
|
-
}
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
case 'Modal':
|
|
110
|
-
case 'MobileModal': {
|
|
111
|
-
try {
|
|
112
|
-
this.refs.ModalManager.current.openModal({
|
|
113
|
-
pageId: pageData.pageId,
|
|
114
|
-
params: searchPamams,
|
|
115
|
-
lcdpParentRenderId,
|
|
116
|
-
});
|
|
117
|
-
} catch (e) {
|
|
118
|
-
console.error(e);
|
|
119
|
-
message?.warning(this.getLocale('lcdpApi.router.openFail', '打开新页面失败,缺失Modal', { type: 'Modal' }));
|
|
120
|
-
}
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
default: {
|
|
124
|
-
message?.warning(
|
|
125
|
-
this.getLocale('lcdpApi.router.notSupport', `不支持的页面类型: ${pageData.pageContainerType}`, { type: pageData.pageContainerType })
|
|
126
|
-
);
|
|
127
|
-
break;
|
|
40
|
+
const [pathname, search] = url.split('?');
|
|
41
|
+
const searchPamams = search
|
|
42
|
+
? search.split('&').reduce((pre: any, cur: any) => {
|
|
43
|
+
const [k, v] = cur.split('=');
|
|
44
|
+
if (v) {
|
|
45
|
+
pre[decodeURIComponent(k)] = decodeURIComponent(v);
|
|
128
46
|
}
|
|
129
|
-
|
|
47
|
+
return pre;
|
|
48
|
+
}, {})
|
|
49
|
+
: {};
|
|
50
|
+
if (ModalMap[pathname]) {
|
|
51
|
+
this.refs.ModalManager.current.openModal({
|
|
52
|
+
pathname,
|
|
53
|
+
params: searchPamams,
|
|
54
|
+
});
|
|
55
|
+
} else if (DrawerMap[pathname]) {
|
|
56
|
+
this.refs.ModalManager.current.openDrawer({
|
|
57
|
+
pathname,
|
|
58
|
+
params: searchPamams,
|
|
59
|
+
});
|
|
130
60
|
} else {
|
|
131
|
-
|
|
61
|
+
historytool(HISTORYTYPES.replace, {
|
|
62
|
+
pathname,
|
|
63
|
+
search,
|
|
64
|
+
state: {},
|
|
65
|
+
history,
|
|
66
|
+
});
|
|
132
67
|
}
|
|
133
68
|
}
|
|
134
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxiteam/ebe-utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@babel/types": "^7.12.12",
|
|
20
20
|
"cac": "^6.7.14",
|
|
21
21
|
"fs-extra": "9.x",
|
|
22
|
-
"@lingxiteam/ebe": "0.4.
|
|
22
|
+
"@lingxiteam/ebe": "0.4.6"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|