bee-front-components 1.0.0 → 1.0.2
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/index.d.ts +24 -0
- package/lib/index.js +24 -0
- package/lib/styles/_variable.less +130 -0
- package/package.json +4 -1
- package/lib/utils/index.d.ts +0 -95
- package/lib/utils/index.js +0 -319
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./styles/_variable.less";
|
|
2
|
+
import "//at.alicdn.com/t/c/font_5189798_vx6yinyr8o.css";
|
|
3
|
+
export { default as BaseModal } from "./components/BaseModal";
|
|
4
|
+
export { Button, ButtonPermission } from "./components/Buttons";
|
|
5
|
+
export { default as ContentHeader } from "./components/ContentHeader";
|
|
6
|
+
export { default as Empty } from "./components/Empty";
|
|
7
|
+
export { default as ExcelExport } from "./components/ExcelExport";
|
|
8
|
+
export { Modal } from "./components/Modal";
|
|
9
|
+
export { default as PageHeader } from "./components/PageHeader";
|
|
10
|
+
export { default as PdfViewer } from "./components/PdfViewer";
|
|
11
|
+
export { default as QueryBar } from "./components/QueryBar/TableQueryBar";
|
|
12
|
+
export { default as RemainDay } from "./components/RemainDay";
|
|
13
|
+
export { default as Scanner } from "./components/Scanner";
|
|
14
|
+
export { default as StatusTab } from "./components/StatusTab";
|
|
15
|
+
export { default as StatusTag } from "./components/StatusTag";
|
|
16
|
+
export { default as StepProgress } from "./components/StepProgress";
|
|
17
|
+
export { default as Table } from "./components/Table";
|
|
18
|
+
export { default as TableOperationColumn } from "./components/TableOperationColumn";
|
|
19
|
+
export { Tabs, TabPane } from "./components/Tabs";
|
|
20
|
+
export { FileUpload, BatchUpload, DraggerUpload } from "./components/Upload";
|
|
21
|
+
export { default as VipFlag } from "./components/VipFlag";
|
|
22
|
+
export * from "./utils/const";
|
|
23
|
+
export * from "./utils/menuTab";
|
|
24
|
+
export * from "./utils/utils";
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./styles/_variable.less";
|
|
2
|
+
import "//at.alicdn.com/t/c/font_5189798_vx6yinyr8o.css";
|
|
3
|
+
export { default as BaseModal } from "./components/BaseModal";
|
|
4
|
+
export { Button, ButtonPermission } from "./components/Buttons";
|
|
5
|
+
export { default as ContentHeader } from "./components/ContentHeader";
|
|
6
|
+
export { default as Empty } from "./components/Empty";
|
|
7
|
+
export { default as ExcelExport } from "./components/ExcelExport";
|
|
8
|
+
export { Modal } from "./components/Modal";
|
|
9
|
+
export { default as PageHeader } from "./components/PageHeader";
|
|
10
|
+
export { default as PdfViewer } from "./components/PdfViewer";
|
|
11
|
+
export { default as QueryBar } from "./components/QueryBar/TableQueryBar";
|
|
12
|
+
export { default as RemainDay } from "./components/RemainDay";
|
|
13
|
+
export { default as Scanner } from "./components/Scanner";
|
|
14
|
+
export { default as StatusTab } from "./components/StatusTab";
|
|
15
|
+
export { default as StatusTag } from "./components/StatusTag";
|
|
16
|
+
export { default as StepProgress } from "./components/StepProgress";
|
|
17
|
+
export { default as Table } from "./components/Table";
|
|
18
|
+
export { default as TableOperationColumn } from "./components/TableOperationColumn";
|
|
19
|
+
export { Tabs, TabPane } from "./components/Tabs";
|
|
20
|
+
export { FileUpload, BatchUpload, DraggerUpload } from "./components/Upload";
|
|
21
|
+
export { default as VipFlag } from "./components/VipFlag";
|
|
22
|
+
export * from "./utils/const";
|
|
23
|
+
export * from "./utils/menuTab";
|
|
24
|
+
export * from "./utils/utils";
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// @import '~choerodon-ui/lib/style/themes/default.less';
|
|
2
|
+
// 全局属性变量
|
|
3
|
+
/** 主要主题色 */
|
|
4
|
+
:root {
|
|
5
|
+
--primary-color: #1677ff;
|
|
6
|
+
--hover-primary-color: #4492fe;
|
|
7
|
+
--primary-color-light: #dcebff;
|
|
8
|
+
--table-header-bg-color: #dcebff;
|
|
9
|
+
--table-row-bg-color: #f2f8ff;
|
|
10
|
+
--left-menu-active-color: rgba(22, 119, 255, 0.05);
|
|
11
|
+
--table-hover-bg-color: rgba(22, 119, 255, 0.1);
|
|
12
|
+
}
|
|
13
|
+
@primaryColor: var(--primary-color);
|
|
14
|
+
@leftMenuActiveColor: var(--left-menu-active-color);
|
|
15
|
+
@hoverPrimaryColor: var(--hover-primary-color);
|
|
16
|
+
@selectedPrimaryColor: var(--primary-color);
|
|
17
|
+
@primaryWord: #212231;
|
|
18
|
+
@labelWord: #666666;
|
|
19
|
+
@minorWord: #808080;
|
|
20
|
+
@lightWord: #e6e6e6;
|
|
21
|
+
@borderColor: #c5ccdb;
|
|
22
|
+
@mainBgColor: #f4f5f7;
|
|
23
|
+
@deepBgColor: #f0f0f0;
|
|
24
|
+
@scrollbarBg: #b7b7b7;
|
|
25
|
+
@errorColor: #ed0100;
|
|
26
|
+
@warnColor: #ffc400;
|
|
27
|
+
@successColor: #00c498;
|
|
28
|
+
@urgentColor: #902020;
|
|
29
|
+
@pendingColor: #722ed1;
|
|
30
|
+
@cancelColor: #bfbfbf;
|
|
31
|
+
@white: #ffffff;
|
|
32
|
+
// 浅色
|
|
33
|
+
@primaryLightColor: var(--primary-color-light);
|
|
34
|
+
@successLightColor: #d9f6f0;
|
|
35
|
+
@warnLightColor: #fff6d9;
|
|
36
|
+
@errorLightColor: #fdd9d9;
|
|
37
|
+
|
|
38
|
+
@basicHeight: 0.36rem;
|
|
39
|
+
@borderRadius: 0.08rem;
|
|
40
|
+
@smallFont: 0.12rem;
|
|
41
|
+
@fontSize14: 0.14rem;
|
|
42
|
+
@fontSize: 0.16rem;
|
|
43
|
+
@fontSize18: 0.18rem;
|
|
44
|
+
@fontSize20: 0.2rem;
|
|
45
|
+
@mediumFont: 0.22rem;
|
|
46
|
+
@largeFont: 0.24rem;
|
|
47
|
+
@hugeFont: 0.28rem;
|
|
48
|
+
@superFont: 0.3rem;
|
|
49
|
+
@superBigFont: 0.32rem;
|
|
50
|
+
@superHugeFont: 0.36rem;
|
|
51
|
+
|
|
52
|
+
// 表格表头背景颜色
|
|
53
|
+
@tableHeaderBgColor: var(--table-header-bg-color);
|
|
54
|
+
// 表格偶数行背景颜色
|
|
55
|
+
@tableRowBgColor: var(--table-row-bg-color);
|
|
56
|
+
// 表格悬停行背景颜色
|
|
57
|
+
@tableHoverBgColor: var(--table-hover-bg-color);
|
|
58
|
+
|
|
59
|
+
// 混入定义
|
|
60
|
+
.flex(@dir: row, @justify: center, @align: center, @wrap: wrap) {
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-flow: @dir @wrap;
|
|
63
|
+
justify-content: @justify;
|
|
64
|
+
align-items: @align;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.position(@position: static, @top: unset, @right: unset, @bottom: unset, @left: unset) {
|
|
68
|
+
position: @position;
|
|
69
|
+
top: @top;
|
|
70
|
+
right: @right;
|
|
71
|
+
bottom: @bottom;
|
|
72
|
+
left: @left;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 公共外边框样式
|
|
76
|
+
.commonWrap(@radius: 0.16rem, @color: @white) {
|
|
77
|
+
border-radius: @radius;
|
|
78
|
+
background-color: @color;
|
|
79
|
+
box-shadow: 0 0.02rem 0.04rem 0 rgba(0, 0, 0, 0.02), 0 0.02rem 0.08rem 0px rgba(0, 0, 0, 0.02),
|
|
80
|
+
0px 0.02rem 0.03rem 0px rgba(0, 0, 0, 0.03);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 多行省略
|
|
84
|
+
.multiline(@line: 2) {
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
text-overflow: ellipsis;
|
|
87
|
+
display: -webkit-box;
|
|
88
|
+
-webkit-line-clamp: @line;
|
|
89
|
+
-webkit-box-orient: vertical;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 状态对应颜色映射 Mixin
|
|
93
|
+
.statusBg(@status) when (@status = waiting) {
|
|
94
|
+
background-color: @warnColor;
|
|
95
|
+
}
|
|
96
|
+
.statusBg(@status) when (@status = process) {
|
|
97
|
+
background-color: @lightPrimaryColor;
|
|
98
|
+
}
|
|
99
|
+
.statusBg(@status) when (@status = pending) {
|
|
100
|
+
background-color: @pendingColor;
|
|
101
|
+
}
|
|
102
|
+
.statusBg(@status) when (@status = warning) {
|
|
103
|
+
background-color: @errorColor;
|
|
104
|
+
}
|
|
105
|
+
.statusBg(@status) when (@status = completed) {
|
|
106
|
+
background-color: @successColor;
|
|
107
|
+
}
|
|
108
|
+
.statusBg(@status) when (@status = canceled) {
|
|
109
|
+
background-color: @cancelColor;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 通用状态样式 Mixin,传入状态名即可
|
|
113
|
+
.status(@name) {
|
|
114
|
+
.statusBg(@name);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 呼吸灯效果
|
|
118
|
+
@keyframes breathing {
|
|
119
|
+
0%,
|
|
120
|
+
100% {
|
|
121
|
+
display: inline-block;
|
|
122
|
+
opacity: 1;
|
|
123
|
+
transform: scale(1);
|
|
124
|
+
}
|
|
125
|
+
50% {
|
|
126
|
+
display: inline-block;
|
|
127
|
+
opacity: 0.7;
|
|
128
|
+
transform: scale(1.1); /* 稍微放大,增加视觉效果 */
|
|
129
|
+
}
|
|
130
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bee-front-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "cross-env UMI_ENV=dev node ../../node_modules/umi/bin/umi.js dev",
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
"!lib/config/babel-config.js",
|
|
26
26
|
"!.umi-production"
|
|
27
27
|
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"registry": "https://registry.npmjs.org/"
|
|
30
|
+
},
|
|
28
31
|
"peerDependencies": {
|
|
29
32
|
"@hzero-front-ui/cfg": "*",
|
|
30
33
|
"axios": "*",
|
package/lib/utils/index.d.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
export declare const EXT_TYPE_MAP: {
|
|
2
|
-
".doc": string;
|
|
3
|
-
".docx": string;
|
|
4
|
-
".xls": string;
|
|
5
|
-
".xlsx": string;
|
|
6
|
-
".ppt": string;
|
|
7
|
-
".pptx": string;
|
|
8
|
-
".pdf": string;
|
|
9
|
-
".jpg": string;
|
|
10
|
-
".jpeg": string;
|
|
11
|
-
".png": string;
|
|
12
|
-
".gif": string;
|
|
13
|
-
".bmp": string;
|
|
14
|
-
".zip": string;
|
|
15
|
-
".rar": string;
|
|
16
|
-
".7z": string;
|
|
17
|
-
".tar": string;
|
|
18
|
-
".gz": string;
|
|
19
|
-
".tgz": string;
|
|
20
|
-
".bz2": string;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* @name 根据文件后缀判断onlyoffice文件配置参数
|
|
24
|
-
* @param {string} fileSuffix
|
|
25
|
-
* @returns {unknown} onlyoffice的配置项类型
|
|
26
|
-
*/
|
|
27
|
-
export declare function getOnlyofficeConfig(fileSuffix: string): {
|
|
28
|
-
documentType: string;
|
|
29
|
-
fileType: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* @name 返回上一页
|
|
33
|
-
* @param {string} params 上一页路径参数
|
|
34
|
-
* @param {string} params.path 上一页路径
|
|
35
|
-
* @param {string} params.title 上一页标题
|
|
36
|
-
* @param {boolean} params.isRefresh 是否刷新上一页
|
|
37
|
-
* @returns {void}
|
|
38
|
-
*/
|
|
39
|
-
export declare function backTab(params: {
|
|
40
|
-
path: string;
|
|
41
|
-
title?: string;
|
|
42
|
-
isRefresh?: boolean;
|
|
43
|
-
[key: string]: any;
|
|
44
|
-
}): void;
|
|
45
|
-
/**
|
|
46
|
-
* 金额千分位格式化(支持负数,但货币场景通常非负)
|
|
47
|
-
*/
|
|
48
|
-
export declare function formatThousandMoney(value: number | string | undefined | null, decimals?: number): string;
|
|
49
|
-
/**
|
|
50
|
-
* 小写金额转人民币大写(财务票据标准)
|
|
51
|
-
* @param num 金额:数字 / 带千分位字符串
|
|
52
|
-
* @returns 人民币大写字符串
|
|
53
|
-
*/
|
|
54
|
-
export declare function moneyToChinese(num: number | string): string;
|
|
55
|
-
/**
|
|
56
|
-
* @name 随机生成16位uuid
|
|
57
|
-
* @returns {string}
|
|
58
|
-
*/
|
|
59
|
-
export declare function generateUUID(): string;
|
|
60
|
-
/**
|
|
61
|
-
* @name 根据URL获取文件UUID
|
|
62
|
-
* @description 文件路径形如xxxx/363a7627e49b45dc895a1f16fadfc521@文件名称.png
|
|
63
|
-
* @param {string} url 文件路径
|
|
64
|
-
* @returns {string}
|
|
65
|
-
*/
|
|
66
|
-
export declare function getFileUUID(url: string): string;
|
|
67
|
-
/**
|
|
68
|
-
* @name 根据URL获取文件名称
|
|
69
|
-
* @description 文件路径形如xxxx/363a7627e49b45dc895a1f16fadfc521@文件名称.png
|
|
70
|
-
* @param {string} url 文件路径
|
|
71
|
-
* @returns {string}
|
|
72
|
-
*/
|
|
73
|
-
export declare function getFileName(url: string): string;
|
|
74
|
-
/**
|
|
75
|
-
* @name 根据文件URL下载文件
|
|
76
|
-
* @param {string} fileUrl 文件路径
|
|
77
|
-
* @param {string} fileName 文件名称
|
|
78
|
-
* @returns {void}
|
|
79
|
-
*/
|
|
80
|
-
export declare function handleDownloadFile(fileUrl: string, fileName?: string): void;
|
|
81
|
-
/**
|
|
82
|
-
* 通用单行比较器
|
|
83
|
-
* @param currentItem a
|
|
84
|
-
* @param nextItem b
|
|
85
|
-
* @param sortField 排序字段
|
|
86
|
-
* @param sortOrder asc | desc
|
|
87
|
-
* @returns number -1 0 1
|
|
88
|
-
*/
|
|
89
|
-
export declare function itemCompare<T>(currentItem: T, nextItem: T, sortField: keyof T, sortOrder: "asc" | "desc" | undefined): number;
|
|
90
|
-
/**
|
|
91
|
-
* @name 字符串 base64 编码 用于对接预览平台
|
|
92
|
-
* @param str 要编码的字符串
|
|
93
|
-
* @returns 编码后的字符串
|
|
94
|
-
*/
|
|
95
|
-
export declare function base64Encode(str: any): string;
|
package/lib/utils/index.js
DELETED
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
const _excluded = ["path", "title", "isRefresh"];
|
|
4
|
-
import notification from "utils/notification";
|
|
5
|
-
import { closeTab, openTab, refreshTab } from "./menuTab";
|
|
6
|
-
|
|
7
|
-
// 常见文件类型与file.type的对应关系
|
|
8
|
-
export const EXT_TYPE_MAP = {
|
|
9
|
-
".doc": "application/msword",
|
|
10
|
-
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
11
|
-
".xls": "application/vnd.ms-excel",
|
|
12
|
-
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
13
|
-
".ppt": "application/vnd.ms-powerpoint",
|
|
14
|
-
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
15
|
-
".pdf": "application/pdf",
|
|
16
|
-
".jpg": "image/jpeg",
|
|
17
|
-
".jpeg": "image/jpeg",
|
|
18
|
-
".png": "image/png",
|
|
19
|
-
".gif": "image/gif",
|
|
20
|
-
".bmp": "image/bmp",
|
|
21
|
-
".zip": "application/x-zip-compressed",
|
|
22
|
-
".rar": "application/x-compressed",
|
|
23
|
-
".7z": "application/x-compressed",
|
|
24
|
-
".tar": "application/x-tar",
|
|
25
|
-
".gz": "application/x-gzip",
|
|
26
|
-
".tgz": "application/x-compressed",
|
|
27
|
-
".bz2": "application/x-compressed"
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @name 根据文件后缀判断onlyoffice文件配置参数
|
|
32
|
-
* @param {string} fileSuffix
|
|
33
|
-
* @returns {unknown} onlyoffice的配置项类型
|
|
34
|
-
*/
|
|
35
|
-
export function getOnlyofficeConfig(fileSuffix) {
|
|
36
|
-
const wordExtensions = [".doc", ".docm", ".docx", ".dot", ".dotm", ".dotx", ".epub", ".fb2", ".fodt", ".htm", ".html", ".md", ".hwp", ".hwpx", ".mht", ".mhtml", ".odt", ".ott", ".pages", ".rtf", ".stw", ".sxw", ".txt", ".wps", ".wpt", ".xml"];
|
|
37
|
-
const cellExtensions = [".csv", ".et", ".ett", ".fods", ".numbers", ".ods", ".ots", ".sxc", ".xls", ".xlsb", ".xlsm", ".xlsx", ".xlt", ".xltm", ".xltx", ".xml"];
|
|
38
|
-
const slideExtensions = [".dps", ".dpt", ".fodp", ".key", ".odg", ".odp", ".otp", ".pot", ".potm", ".potx", ".pps", ".ppsm", ".ppsx", ".ppt", ".pptm", ".pptx", ".sxi"];
|
|
39
|
-
const pdfExtensions = [".djvu", ".oxps", ".pdf", ".xps"];
|
|
40
|
-
const diagramExtensions = [".vsdm", ".vsdx", ".vssm", ".vssx", ".vstm", ".vstx"];
|
|
41
|
-
const fileType = fileSuffix.slice(1);
|
|
42
|
-
if (wordExtensions.includes(fileSuffix)) {
|
|
43
|
-
return {
|
|
44
|
-
documentType: "word",
|
|
45
|
-
fileType
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
if (cellExtensions.includes(fileSuffix)) {
|
|
49
|
-
return {
|
|
50
|
-
documentType: "cell",
|
|
51
|
-
fileType
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
if (slideExtensions.includes(fileSuffix)) {
|
|
55
|
-
return {
|
|
56
|
-
documentType: "slide",
|
|
57
|
-
fileType
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
if (pdfExtensions.includes(fileSuffix)) {
|
|
61
|
-
return {
|
|
62
|
-
documentType: "pdf",
|
|
63
|
-
fileType
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
if (diagramExtensions.includes(fileSuffix)) {
|
|
67
|
-
return {
|
|
68
|
-
documentType: "diagram",
|
|
69
|
-
fileType
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
throw new Error("Unsupported file type.");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @name 返回上一页
|
|
77
|
-
* @param {string} params 上一页路径参数
|
|
78
|
-
* @param {string} params.path 上一页路径
|
|
79
|
-
* @param {string} params.title 上一页标题
|
|
80
|
-
* @param {boolean} params.isRefresh 是否刷新上一页
|
|
81
|
-
* @returns {void}
|
|
82
|
-
*/
|
|
83
|
-
export function backTab(params) {
|
|
84
|
-
const path = params.path,
|
|
85
|
-
_params$title = params.title,
|
|
86
|
-
title = _params$title === void 0 ? "" : _params$title,
|
|
87
|
-
_params$isRefresh = params.isRefresh,
|
|
88
|
-
isRefresh = _params$isRefresh === void 0 ? true : _params$isRefresh,
|
|
89
|
-
other = _objectWithoutProperties(params, _excluded);
|
|
90
|
-
closeTab(location.pathname);
|
|
91
|
-
openTab({
|
|
92
|
-
title: title,
|
|
93
|
-
key: path,
|
|
94
|
-
path: path,
|
|
95
|
-
closable: true,
|
|
96
|
-
...other
|
|
97
|
-
});
|
|
98
|
-
isRefresh && refreshTab(path);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* 金额千分位格式化(支持负数,但货币场景通常非负)
|
|
102
|
-
*/
|
|
103
|
-
export function formatThousandMoney(value, decimals = 2) {
|
|
104
|
-
if (value === null || value === undefined || value === "") return "0.00";
|
|
105
|
-
const num = Number(String(value).replace(/[, ]/g, ""));
|
|
106
|
-
if (Number.isNaN(num)) return "0.00";
|
|
107
|
-
const _num$toFixed$split = num.toFixed(decimals).split("."),
|
|
108
|
-
_num$toFixed$split2 = _slicedToArray(_num$toFixed$split, 2),
|
|
109
|
-
int = _num$toFixed$split2[0],
|
|
110
|
-
dec = _num$toFixed$split2[1];
|
|
111
|
-
const formattedInt = int.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
112
|
-
return `${formattedInt}.${dec}`;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* 小写金额转人民币大写(财务票据标准)
|
|
116
|
-
* @param num 金额:数字 / 带千分位字符串
|
|
117
|
-
* @returns 人民币大写字符串
|
|
118
|
-
*/
|
|
119
|
-
export function moneyToChinese(num) {
|
|
120
|
-
if (num === undefined || num === null || num === "") return "";
|
|
121
|
-
const money = parseFloat(String(num).replace(/,/g, ""));
|
|
122
|
-
if (Number.isNaN(money)) return "无效金额";
|
|
123
|
-
if (money < 0 || money > 9999999999999.99) return "金额超出范围";
|
|
124
|
-
const digits = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
|
|
125
|
-
const radices = ["", "拾", "佰", "仟"];
|
|
126
|
-
const bigRadices = ["", "万", "亿"];
|
|
127
|
-
const fixed = money.toFixed(2);
|
|
128
|
-
const _fixed$split = fixed.split("."),
|
|
129
|
-
_fixed$split2 = _slicedToArray(_fixed$split, 2),
|
|
130
|
-
intStr = _fixed$split2[0],
|
|
131
|
-
decStr = _fixed$split2[1];
|
|
132
|
-
if (intStr === "0" && decStr === "00") return "零元整";
|
|
133
|
-
|
|
134
|
-
// 从右向左每 4 位一组
|
|
135
|
-
const groupCount = Math.ceil(intStr.length / 4);
|
|
136
|
-
const groups = [];
|
|
137
|
-
for (let i = 0; i < groupCount; i++) {
|
|
138
|
-
const start = Math.max(0, intStr.length - (i + 1) * 4);
|
|
139
|
-
const end = intStr.length - i * 4;
|
|
140
|
-
groups.unshift(intStr.slice(start, end));
|
|
141
|
-
}
|
|
142
|
-
let result = "";
|
|
143
|
-
let needZero = false;
|
|
144
|
-
for (let g = 0; g < groups.length; g++) {
|
|
145
|
-
const group = groups[g];
|
|
146
|
-
const groupVal = parseInt(group, 10);
|
|
147
|
-
const isLast = g === groups.length - 1;
|
|
148
|
-
const bigUnit = isLast ? "元" : bigRadices[groups.length - 1 - g];
|
|
149
|
-
if (groupVal === 0) {
|
|
150
|
-
if (result && !isLast) needZero = true;
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// 中间整组为零时补"零"(仅当当前组不以零开头时,避免与组内逻辑重复)
|
|
155
|
-
if (needZero) {
|
|
156
|
-
const check = group.padStart(4, "0");
|
|
157
|
-
if (+check[0] !== 0) result += "零";
|
|
158
|
-
needZero = false;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// 组内 4 位转换
|
|
162
|
-
const padded = group.padStart(4, "0");
|
|
163
|
-
let zeroInGroup = false;
|
|
164
|
-
for (let i = 0; i < 4; i++) {
|
|
165
|
-
const n = +padded[i];
|
|
166
|
-
const pos = 3 - i;
|
|
167
|
-
if (n === 0) {
|
|
168
|
-
zeroInGroup = true;
|
|
169
|
-
} else {
|
|
170
|
-
if (zeroInGroup && result) result += "零";
|
|
171
|
-
result += digits[n] + radices[pos];
|
|
172
|
-
zeroInGroup = false;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
result += bigUnit;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// 整数大于零但元组为零时仍补"元"
|
|
179
|
-
if (intStr !== "0" && !result.endsWith("元")) {
|
|
180
|
-
const lastGroup = groups[groups.length - 1];
|
|
181
|
-
if (parseInt(lastGroup, 10) === 0) result += "元";
|
|
182
|
-
}
|
|
183
|
-
if (!result) result = "零元";
|
|
184
|
-
|
|
185
|
-
// 角分
|
|
186
|
-
const jiao = +decStr[0];
|
|
187
|
-
const fen = +decStr[1];
|
|
188
|
-
if (jiao === 0 && fen === 0) {
|
|
189
|
-
result += "整";
|
|
190
|
-
} else {
|
|
191
|
-
if (jiao > 0) result += digits[jiao] + "角";
|
|
192
|
-
if (fen > 0) {
|
|
193
|
-
if (jiao === 0 && intStr !== "0") result += "零";
|
|
194
|
-
result += digits[fen] + "分";
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return result;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @name 随机生成16位uuid
|
|
202
|
-
* @returns {string}
|
|
203
|
-
*/
|
|
204
|
-
export function generateUUID() {
|
|
205
|
-
return "xxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g, c => {
|
|
206
|
-
const r = Math.random() * 16 | 0;
|
|
207
|
-
const v = c === "x" ? r : r & 0x3 | 0x8;
|
|
208
|
-
return v.toString(16);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* @name 根据URL获取文件UUID
|
|
214
|
-
* @description 文件路径形如xxxx/363a7627e49b45dc895a1f16fadfc521@文件名称.png
|
|
215
|
-
* @param {string} url 文件路径
|
|
216
|
-
* @returns {string}
|
|
217
|
-
*/
|
|
218
|
-
export function getFileUUID(url) {
|
|
219
|
-
try {
|
|
220
|
-
const parts = url === null || url === void 0 ? void 0 : url.split("/");
|
|
221
|
-
const lastPart = parts === null || parts === void 0 ? void 0 : parts[parts.length - 1];
|
|
222
|
-
const uuid = lastPart === null || lastPart === void 0 ? void 0 : lastPart.split("@")[0];
|
|
223
|
-
return uuid;
|
|
224
|
-
} catch (_error) {
|
|
225
|
-
return generateUUID();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* @name 根据URL获取文件名称
|
|
231
|
-
* @description 文件路径形如xxxx/363a7627e49b45dc895a1f16fadfc521@文件名称.png
|
|
232
|
-
* @param {string} url 文件路径
|
|
233
|
-
* @returns {string}
|
|
234
|
-
*/
|
|
235
|
-
export function getFileName(url) {
|
|
236
|
-
try {
|
|
237
|
-
const fileName = url === null || url === void 0 ? void 0 : url.substring((url === null || url === void 0 ? void 0 : url.indexOf("@")) + 1);
|
|
238
|
-
return fileName;
|
|
239
|
-
} catch (_error) {
|
|
240
|
-
return "未知文件名";
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* @name 根据文件URL下载文件
|
|
246
|
-
* @param {string} fileUrl 文件路径
|
|
247
|
-
* @param {string} fileName 文件名称
|
|
248
|
-
* @returns {void}
|
|
249
|
-
*/
|
|
250
|
-
export function handleDownloadFile(fileUrl, fileName) {
|
|
251
|
-
if (fileUrl) {
|
|
252
|
-
fetch(fileUrl).then(response => response.blob()).then(blob => {
|
|
253
|
-
// 创建一个临时的URL对象
|
|
254
|
-
const url = URL.createObjectURL(blob);
|
|
255
|
-
// 创建一个隐藏的<a>标签,并设置其href属性为临时URL
|
|
256
|
-
const a = document.createElement("a");
|
|
257
|
-
a.href = url;
|
|
258
|
-
a.download = fileName || getFileName(fileUrl); // 设置下载的文件名
|
|
259
|
-
a.style.display = "none";
|
|
260
|
-
// 将<a>标签添加到文档中,并模拟点击下载
|
|
261
|
-
document.body.appendChild(a);
|
|
262
|
-
a.click();
|
|
263
|
-
// 下载完成后,移除<a>标签和临时URL对象
|
|
264
|
-
document.body.removeChild(a);
|
|
265
|
-
URL.revokeObjectURL(url);
|
|
266
|
-
}).catch(error => {
|
|
267
|
-
notification.error({
|
|
268
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || "文件下载失败"
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
} else {
|
|
272
|
-
notification.error({
|
|
273
|
-
message: "无法正常获取文件路径,请刷新后重试"
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* 通用单行比较器
|
|
280
|
-
* @param currentItem a
|
|
281
|
-
* @param nextItem b
|
|
282
|
-
* @param sortField 排序字段
|
|
283
|
-
* @param sortOrder asc | desc
|
|
284
|
-
* @returns number -1 0 1
|
|
285
|
-
*/
|
|
286
|
-
export function itemCompare(currentItem, nextItem, sortField, sortOrder) {
|
|
287
|
-
if (!sortOrder) return 0;
|
|
288
|
-
const valA = currentItem[sortField];
|
|
289
|
-
const valB = nextItem[sortField];
|
|
290
|
-
|
|
291
|
-
// 空值兜底 null/undefined排后面
|
|
292
|
-
if (valA == null && valB != null) return 1;
|
|
293
|
-
if (valA != null && valB == null) return -1;
|
|
294
|
-
if (valA == null && valB == null) return 0;
|
|
295
|
-
let result = 0;
|
|
296
|
-
if (typeof valA === "number" && typeof valB === "number") {
|
|
297
|
-
// 数字
|
|
298
|
-
result = valA - valB;
|
|
299
|
-
} else if (valA instanceof Date && valB instanceof Date) {
|
|
300
|
-
// 日期
|
|
301
|
-
result = valA.getTime() - valB.getTime();
|
|
302
|
-
} else {
|
|
303
|
-
// 字符串(中文拼音排序)
|
|
304
|
-
result = String(valA).localeCompare(String(valB), "zh-CN");
|
|
305
|
-
}
|
|
306
|
-
return sortOrder === "asc" ? result : -result;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* @name 字符串 base64 编码 用于对接预览平台
|
|
311
|
-
* @param str 要编码的字符串
|
|
312
|
-
* @returns 编码后的字符串
|
|
313
|
-
*/
|
|
314
|
-
export function base64Encode(str) {
|
|
315
|
-
const utf8Bytes = new TextEncoder().encode(str);
|
|
316
|
-
// 使用 Array.from 将 Uint8Array 转为二进制字符串
|
|
317
|
-
const binaryString = Array.from(utf8Bytes, byte => String.fromCharCode(byte)).join("");
|
|
318
|
-
return btoa(binaryString);
|
|
319
|
-
}
|