beer-assembly-biz 1.1.3-alpha.1 → 1.1.3-alpha.3
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/layout/AppLayout.js +3 -3
- package/package.json +1 -1
- package/promises.d.ts +39 -0
- package/promises.js +125 -0
package/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export { MyPageContainer } from './layout/MyPageContainer';
|
|
|
10
10
|
export { Permission } from './permission/Permission';
|
|
11
11
|
export { AIEditor, AIEditorProps } from './rich/AIEditor';
|
|
12
12
|
export { Slider, SliderCode, SliderCodeToken } from './slider/SliderCode';
|
|
13
|
-
export { Promises } from './promises';
|
|
13
|
+
export { Promises, Async, NumberUtils, CascadeUtils, ArrayUtils, NavigateUtils } from './promises';
|
|
14
14
|
export { UserModals } from './UserModals';
|
package/index.js
CHANGED
|
@@ -10,5 +10,5 @@ export { MyPageContainer } from './layout/MyPageContainer';
|
|
|
10
10
|
export { Permission } from './permission/Permission';
|
|
11
11
|
export { AIEditor } from './rich/AIEditor';
|
|
12
12
|
export { SliderCode } from './slider/SliderCode';
|
|
13
|
-
export { Promises } from './promises';
|
|
13
|
+
export { Promises, Async, NumberUtils, CascadeUtils, ArrayUtils, NavigateUtils } from './promises';
|
|
14
14
|
export { UserModals } from './UserModals';
|
package/layout/AppLayout.js
CHANGED
|
@@ -4,9 +4,9 @@ import { ProLayout } from '@ant-design/pro-components';
|
|
|
4
4
|
import { Dropdown, message, theme, Typography } from 'antd';
|
|
5
5
|
import { Session } from 'beer-network/session';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
|
-
import ImageLayout01 from '
|
|
8
|
-
import ImageLayout02 from '
|
|
9
|
-
import ImageLayout03 from '
|
|
7
|
+
import ImageLayout01 from '../images/layout_01.png';
|
|
8
|
+
import ImageLayout02 from '../images/layout_02.png';
|
|
9
|
+
import ImageLayout03 from '../images/layout_03.png';
|
|
10
10
|
dayjs.locale('zh-cn');
|
|
11
11
|
/**
|
|
12
12
|
* 通用布局.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beer-assembly-biz",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.1.3-alpha.
|
|
4
|
+
"version": "1.1.3-alpha.3",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"pub-w": "tsc && copy package.json .\\dist\\package.json && npm publish ./dist",
|
|
7
7
|
"copy": "cp -a src/rich/AIEditor.css dist/rich/AIEditor.css && cp -a src/icon dist/icon && cp -a src/images dist/images",
|
package/promises.d.ts
CHANGED
|
@@ -8,3 +8,42 @@ export declare class Promises {
|
|
|
8
8
|
*/
|
|
9
9
|
static result(promise: Promise<any>): Promise<boolean>;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* 异步任务管理工具.
|
|
13
|
+
*/
|
|
14
|
+
export declare class Async {
|
|
15
|
+
private isRun;
|
|
16
|
+
/**
|
|
17
|
+
* 同时只有一个函数能运行.
|
|
18
|
+
* @param func
|
|
19
|
+
*/
|
|
20
|
+
run<T>(func: () => Promise<T>): Promise<T | undefined>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 简单的数值工具类.
|
|
24
|
+
*/
|
|
25
|
+
export declare class NumberUtils {
|
|
26
|
+
static isNumeric(value: any): boolean;
|
|
27
|
+
static ifGeZeroNumeric(value: any, defaultValue?: any): any;
|
|
28
|
+
static number(value: any): string;
|
|
29
|
+
static format(value: number): string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 级联选择工具类.
|
|
33
|
+
*/
|
|
34
|
+
export declare class CascadeUtils {
|
|
35
|
+
static recursionFind(dataList: any[], parentId: string): string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 数组工具类.
|
|
39
|
+
*/
|
|
40
|
+
export declare class ArrayUtils {
|
|
41
|
+
static flat(array?: any[], index?: number): any;
|
|
42
|
+
static toArray(value?: string | number): (string | number)[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 后退导航工具类.
|
|
46
|
+
*/
|
|
47
|
+
export declare class NavigateUtils {
|
|
48
|
+
static useBack(): () => void;
|
|
49
|
+
}
|
package/promises.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
2
|
+
const pathPartition = (sessionStorage.getItem('DETAIL_PARTITION') || '') === ''
|
|
3
|
+
? ['CREATE', 'EDIT', 'AUDIT', 'PREVIEW', 'DETAIL', 'READ', 'IN', 'INPUT', 'OUTPUT']
|
|
4
|
+
: JSON.parse(sessionStorage.getItem('DETAIL_PARTITION') || '[]');
|
|
1
5
|
/**
|
|
2
6
|
* 异步函数增强工具库.
|
|
3
7
|
*/
|
|
@@ -13,3 +17,124 @@ export class Promises {
|
|
|
13
17
|
});
|
|
14
18
|
}
|
|
15
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* 异步任务管理工具.
|
|
22
|
+
*/
|
|
23
|
+
export class Async {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.isRun = false;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 同时只有一个函数能运行.
|
|
29
|
+
* @param func
|
|
30
|
+
*/
|
|
31
|
+
async run(func) {
|
|
32
|
+
try {
|
|
33
|
+
if (this.isRun) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
this.isRun = true;
|
|
37
|
+
return await func();
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
this.isRun = false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 简单的数值工具类.
|
|
46
|
+
*/
|
|
47
|
+
export class NumberUtils {
|
|
48
|
+
static isNumeric(value) {
|
|
49
|
+
if (typeof value === 'number') {
|
|
50
|
+
return !Number.isNaN(value);
|
|
51
|
+
}
|
|
52
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
53
|
+
return !Number.isNaN(Number(value)) && !Number.isNaN(Number.parseFloat(value));
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
static ifGeZeroNumeric(value, defaultValue) {
|
|
58
|
+
return this.isNumeric(value) && Number(value) > 0 ? value : defaultValue;
|
|
59
|
+
}
|
|
60
|
+
static number(value) {
|
|
61
|
+
if (value === undefined || value === null || value === '') {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
return Number(value)
|
|
65
|
+
.toFixed(2);
|
|
66
|
+
}
|
|
67
|
+
static format(value) {
|
|
68
|
+
return (Math.floor(value * 100) / 100).toFixed(2);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 级联选择工具类.
|
|
73
|
+
*/
|
|
74
|
+
export class CascadeUtils {
|
|
75
|
+
static recursionFind(dataList, parentId) {
|
|
76
|
+
if (parentId === '0') {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
if (dataList === undefined || dataList.length <= 0) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
for (const item of dataList) {
|
|
83
|
+
if (item.children === undefined || item.children.length <= 0) {
|
|
84
|
+
// 如果没有子集, 能匹配则匹配 不能则跳过循环
|
|
85
|
+
if (item.value === parentId) {
|
|
86
|
+
return [item.value];
|
|
87
|
+
}
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
else if (item.value === parentId) {
|
|
91
|
+
return [item.value];
|
|
92
|
+
}
|
|
93
|
+
const result = this.recursionFind(item.children, parentId);
|
|
94
|
+
if (result.length <= 0) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
return [item.value, ...result];
|
|
98
|
+
}
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 数组工具类.
|
|
104
|
+
*/
|
|
105
|
+
export class ArrayUtils {
|
|
106
|
+
static flat(array, index) {
|
|
107
|
+
const value = array?.[index || 0];
|
|
108
|
+
return (value === undefined || value === null) ? undefined : value;
|
|
109
|
+
}
|
|
110
|
+
static toArray(value) {
|
|
111
|
+
if (value === undefined || value === null) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
return [value];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 后退导航工具类.
|
|
119
|
+
*/
|
|
120
|
+
export class NavigateUtils {
|
|
121
|
+
static useBack() {
|
|
122
|
+
const location = useLocation();
|
|
123
|
+
const navigate = useNavigate();
|
|
124
|
+
return () => {
|
|
125
|
+
let partition = pathPartition.find(path => {
|
|
126
|
+
return location.pathname.toUpperCase()
|
|
127
|
+
.indexOf(`/${path}/`) > -1;
|
|
128
|
+
});
|
|
129
|
+
// 无法确认是否是子页面 则后退一步
|
|
130
|
+
if (partition === undefined) {
|
|
131
|
+
navigate(-1);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// 如果确认是子页面 则前进路由
|
|
135
|
+
partition = partition.toLowerCase();
|
|
136
|
+
const path = location.pathname.split(`/${partition}/`)[0];
|
|
137
|
+
navigate(path);
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|