bee-front-components 1.0.0
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/config/config.ts +28 -0
- package/lib/assets/images/empty.png +0 -0
- package/lib/components/BaseModal/index.d.ts +41 -0
- package/lib/components/BaseModal/index.js +133 -0
- package/lib/components/BaseModal/index.module.less +66 -0
- package/lib/components/Buttons/Button.d.ts +17 -0
- package/lib/components/Buttons/Button.js +34 -0
- package/lib/components/Buttons/ButtonPermission.d.ts +18 -0
- package/lib/components/Buttons/ButtonPermission.js +34 -0
- package/lib/components/Buttons/index.d.ts +3 -0
- package/lib/components/Buttons/index.js +3 -0
- package/lib/components/Buttons/index.module.less +21 -0
- package/lib/components/ContentHeader/index.d.ts +17 -0
- package/lib/components/ContentHeader/index.js +22 -0
- package/lib/components/ContentHeader/index.module.less +14 -0
- package/lib/components/Empty/index.d.ts +17 -0
- package/lib/components/Empty/index.js +23 -0
- package/lib/components/Empty/index.module.less +15 -0
- package/lib/components/ExcelExport/index.d.ts +28 -0
- package/lib/components/ExcelExport/index.js +60 -0
- package/lib/components/ExcelExport/index.module.less +61 -0
- package/lib/components/Modal/index.d.ts +26 -0
- package/lib/components/Modal/index.js +191 -0
- package/lib/components/Modal/index.module.less +79 -0
- package/lib/components/PageHeader/index.d.ts +43 -0
- package/lib/components/PageHeader/index.js +72 -0
- package/lib/components/PageHeader/index.module.less +38 -0
- package/lib/components/PdfViewer/index.d.ts +49 -0
- package/lib/components/PdfViewer/index.js +699 -0
- package/lib/components/QueryBar/TableQueryBar.d.ts +32 -0
- package/lib/components/QueryBar/TableQueryBar.js +115 -0
- package/lib/components/QueryBar/index.d.ts +25 -0
- package/lib/components/QueryBar/index.js +102 -0
- package/lib/components/QueryBar/index.module.less +58 -0
- package/lib/components/RemainDay/index.d.ts +22 -0
- package/lib/components/RemainDay/index.js +47 -0
- package/lib/components/RemainDay/index.module.less +42 -0
- package/lib/components/Scanner/hooks/useKeyboardScanner.d.ts +14 -0
- package/lib/components/Scanner/hooks/useKeyboardScanner.js +95 -0
- package/lib/components/Scanner/index.d.ts +60 -0
- package/lib/components/Scanner/index.js +318 -0
- package/lib/components/Scanner/index.module.less +264 -0
- package/lib/components/Scanner/utils/device.d.ts +2 -0
- package/lib/components/Scanner/utils/device.js +18 -0
- package/lib/components/StatusTab/index.d.ts +36 -0
- package/lib/components/StatusTab/index.js +118 -0
- package/lib/components/StatusTab/index.module.less +20 -0
- package/lib/components/StatusTag/index.d.ts +32 -0
- package/lib/components/StatusTag/index.js +142 -0
- package/lib/components/StatusTag/index.module.less +37 -0
- package/lib/components/StepProgress/index.d.ts +36 -0
- package/lib/components/StepProgress/index.js +84 -0
- package/lib/components/StepProgress/index.module.less +180 -0
- package/lib/components/Table/index.d.ts +44 -0
- package/lib/components/Table/index.js +135 -0
- package/lib/components/Table/index.module.less +24 -0
- package/lib/components/TableOperationColumn/index.d.ts +45 -0
- package/lib/components/TableOperationColumn/index.js +205 -0
- package/lib/components/TableOperationColumn/index.module.less +22 -0
- package/lib/components/Tabs/TabGroup.d.ts +9 -0
- package/lib/components/Tabs/TabGroup.js +12 -0
- package/lib/components/Tabs/TabPane.d.ts +9 -0
- package/lib/components/Tabs/TabPane.js +12 -0
- package/lib/components/Tabs/Tabs.d.ts +23 -0
- package/lib/components/Tabs/Tabs.js +42 -0
- package/lib/components/Tabs/index.d.ts +4 -0
- package/lib/components/Tabs/index.js +4 -0
- package/lib/components/Tabs/index.module.less +20 -0
- package/lib/components/Upload/BatchUpload/index.d.ts +42 -0
- package/lib/components/Upload/BatchUpload/index.js +140 -0
- package/lib/components/Upload/BatchUpload/index.module.less +10 -0
- package/lib/components/Upload/DraggerUpload/index.d.ts +42 -0
- package/lib/components/Upload/DraggerUpload/index.js +142 -0
- package/lib/components/Upload/DraggerUpload/index.module.less +30 -0
- package/lib/components/Upload/FileUpload.d.ts +36 -0
- package/lib/components/Upload/FileUpload.js +122 -0
- package/lib/components/Upload/index.d.ts +4 -0
- package/lib/components/Upload/index.js +4 -0
- package/lib/components/VipFlag/index.d.ts +10 -0
- package/lib/components/VipFlag/index.js +23 -0
- package/lib/components/VipFlag/index.module.less +20 -0
- package/lib/typings/blank.d.ts +0 -0
- package/lib/typings.d.ts +3 -0
- package/lib/utils/const.d.ts +21 -0
- package/lib/utils/const.js +22 -0
- package/lib/utils/index.d.ts +95 -0
- package/lib/utils/index.js +319 -0
- package/lib/utils/menuTab.d.ts +60 -0
- package/lib/utils/menuTab.js +122 -0
- package/lib/utils/utils.d.ts +61 -0
- package/lib/utils/utils.js +270 -0
- package/package.json +41 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
// 公共工具函数
|
|
3
|
+
import notification from "utils/notification";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @name 根据文件后缀判断onlyoffice文件配置参数
|
|
7
|
+
* @param {string} fileSuffix
|
|
8
|
+
* @returns {unknown} onlyoffice的配置项类型
|
|
9
|
+
*/
|
|
10
|
+
export function getOnlyofficeConfig(fileSuffix) {
|
|
11
|
+
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"];
|
|
12
|
+
const cellExtensions = [".csv", ".et", ".ett", ".fods", ".numbers", ".ods", ".ots", ".sxc", ".xls", ".xlsb", ".xlsm", ".xlsx", ".xlt", ".xltm", ".xltx", ".xml"];
|
|
13
|
+
const slideExtensions = [".dps", ".dpt", ".fodp", ".key", ".odg", ".odp", ".otp", ".pot", ".potm", ".potx", ".pps", ".ppsm", ".ppsx", ".ppt", ".pptm", ".pptx", ".sxi"];
|
|
14
|
+
const pdfExtensions = [".djvu", ".oxps", ".pdf", ".xps"];
|
|
15
|
+
const diagramExtensions = [".vsdm", ".vsdx", ".vssm", ".vssx", ".vstm", ".vstx"];
|
|
16
|
+
const fileType = fileSuffix.slice(1);
|
|
17
|
+
if (wordExtensions.includes(fileSuffix)) {
|
|
18
|
+
return {
|
|
19
|
+
documentType: "word",
|
|
20
|
+
fileType
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (cellExtensions.includes(fileSuffix)) {
|
|
24
|
+
return {
|
|
25
|
+
documentType: "cell",
|
|
26
|
+
fileType
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (slideExtensions.includes(fileSuffix)) {
|
|
30
|
+
return {
|
|
31
|
+
documentType: "slide",
|
|
32
|
+
fileType
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (pdfExtensions.includes(fileSuffix)) {
|
|
36
|
+
return {
|
|
37
|
+
documentType: "pdf",
|
|
38
|
+
fileType
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (diagramExtensions.includes(fileSuffix)) {
|
|
42
|
+
return {
|
|
43
|
+
documentType: "diagram",
|
|
44
|
+
fileType
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
throw new Error("Unsupported file type.");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 金额千分位格式化(支持负数,但货币场景通常非负)
|
|
52
|
+
*/
|
|
53
|
+
export function formatThousandMoney(value, decimals = 2) {
|
|
54
|
+
if (value === null || value === undefined || value === "") return "0.00";
|
|
55
|
+
const num = Number(String(value).replace(/[, ]/g, ""));
|
|
56
|
+
if (Number.isNaN(num)) return "0.00";
|
|
57
|
+
const _num$toFixed$split = num.toFixed(decimals).split("."),
|
|
58
|
+
_num$toFixed$split2 = _slicedToArray(_num$toFixed$split, 2),
|
|
59
|
+
int = _num$toFixed$split2[0],
|
|
60
|
+
dec = _num$toFixed$split2[1];
|
|
61
|
+
const formattedInt = int.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
62
|
+
return `${formattedInt}.${dec}`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 小写金额转人民币大写(财务票据标准)
|
|
66
|
+
* @param num 金额:数字 / 带千分位字符串
|
|
67
|
+
* @returns 人民币大写字符串
|
|
68
|
+
*/
|
|
69
|
+
export function moneyToChinese(num) {
|
|
70
|
+
if (num === undefined || num === null || num === "") return "";
|
|
71
|
+
const money = parseFloat(String(num).replace(/,/g, ""));
|
|
72
|
+
if (Number.isNaN(money)) return "无效金额";
|
|
73
|
+
if (money < 0 || money > 9999999999999.99) return "金额超出范围";
|
|
74
|
+
const digits = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
|
|
75
|
+
const radices = ["", "拾", "佰", "仟"];
|
|
76
|
+
const bigRadices = ["", "万", "亿"];
|
|
77
|
+
const fixed = money.toFixed(2);
|
|
78
|
+
const _fixed$split = fixed.split("."),
|
|
79
|
+
_fixed$split2 = _slicedToArray(_fixed$split, 2),
|
|
80
|
+
intStr = _fixed$split2[0],
|
|
81
|
+
decStr = _fixed$split2[1];
|
|
82
|
+
if (intStr === "0" && decStr === "00") return "零元整";
|
|
83
|
+
|
|
84
|
+
// 从右向左每 4 位一组
|
|
85
|
+
const groupCount = Math.ceil(intStr.length / 4);
|
|
86
|
+
const groups = [];
|
|
87
|
+
for (let i = 0; i < groupCount; i++) {
|
|
88
|
+
const start = Math.max(0, intStr.length - (i + 1) * 4);
|
|
89
|
+
const end = intStr.length - i * 4;
|
|
90
|
+
groups.unshift(intStr.slice(start, end));
|
|
91
|
+
}
|
|
92
|
+
let result = "";
|
|
93
|
+
let needZero = false;
|
|
94
|
+
for (let g = 0; g < groups.length; g++) {
|
|
95
|
+
const group = groups[g];
|
|
96
|
+
const groupVal = parseInt(group, 10);
|
|
97
|
+
const isLast = g === groups.length - 1;
|
|
98
|
+
const bigUnit = isLast ? "元" : bigRadices[groups.length - 1 - g];
|
|
99
|
+
if (groupVal === 0) {
|
|
100
|
+
if (result && !isLast) needZero = true;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 中间整组为零时补"零"(仅当当前组不以零开头时,避免与组内逻辑重复)
|
|
105
|
+
if (needZero) {
|
|
106
|
+
const check = group.padStart(4, "0");
|
|
107
|
+
if (+check[0] !== 0) result += "零";
|
|
108
|
+
needZero = false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 组内 4 位转换
|
|
112
|
+
const padded = group.padStart(4, "0");
|
|
113
|
+
let zeroInGroup = false;
|
|
114
|
+
for (let i = 0; i < 4; i++) {
|
|
115
|
+
const n = +padded[i];
|
|
116
|
+
const pos = 3 - i;
|
|
117
|
+
if (n === 0) {
|
|
118
|
+
zeroInGroup = true;
|
|
119
|
+
} else {
|
|
120
|
+
if (zeroInGroup && result) result += "零";
|
|
121
|
+
result += digits[n] + radices[pos];
|
|
122
|
+
zeroInGroup = false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
result += bigUnit;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 整数大于零但元组为零时仍补"元"
|
|
129
|
+
if (intStr !== "0" && !result.endsWith("元")) {
|
|
130
|
+
const lastGroup = groups[groups.length - 1];
|
|
131
|
+
if (parseInt(lastGroup, 10) === 0) result += "元";
|
|
132
|
+
}
|
|
133
|
+
if (!result) result = "零元";
|
|
134
|
+
|
|
135
|
+
// 角分
|
|
136
|
+
const jiao = +decStr[0];
|
|
137
|
+
const fen = +decStr[1];
|
|
138
|
+
if (jiao === 0 && fen === 0) {
|
|
139
|
+
result += "整";
|
|
140
|
+
} else {
|
|
141
|
+
if (jiao > 0) result += digits[jiao] + "角";
|
|
142
|
+
if (fen > 0) {
|
|
143
|
+
if (jiao === 0 && intStr !== "0") result += "零";
|
|
144
|
+
result += digits[fen] + "分";
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @name 随机生成16位uuid
|
|
152
|
+
* @returns {string}
|
|
153
|
+
*/
|
|
154
|
+
export function generateUUID() {
|
|
155
|
+
return "xxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g, c => {
|
|
156
|
+
const r = Math.random() * 16 | 0;
|
|
157
|
+
const v = c === "x" ? r : r & 0x3 | 0x8;
|
|
158
|
+
return v.toString(16);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @name 根据URL获取文件UUID
|
|
164
|
+
* @description 文件路径形如xxxx/363a7627e49b45dc895a1f16fadfc521@文件名称.png
|
|
165
|
+
* @param {string} url 文件路径
|
|
166
|
+
* @returns {string}
|
|
167
|
+
*/
|
|
168
|
+
export function getFileUUID(url) {
|
|
169
|
+
try {
|
|
170
|
+
const parts = url === null || url === void 0 ? void 0 : url.split("/");
|
|
171
|
+
const lastPart = parts === null || parts === void 0 ? void 0 : parts[parts.length - 1];
|
|
172
|
+
const uuid = lastPart === null || lastPart === void 0 ? void 0 : lastPart.split("@")[0];
|
|
173
|
+
return uuid;
|
|
174
|
+
} catch (_error) {
|
|
175
|
+
return generateUUID();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @name 根据URL获取文件名称
|
|
181
|
+
* @description 文件路径形如xxxx/363a7627e49b45dc895a1f16fadfc521@文件名称.png
|
|
182
|
+
* @param {string} url 文件路径
|
|
183
|
+
* @returns {string}
|
|
184
|
+
*/
|
|
185
|
+
export function getFileName(url) {
|
|
186
|
+
try {
|
|
187
|
+
const fileName = url === null || url === void 0 ? void 0 : url.substring((url === null || url === void 0 ? void 0 : url.indexOf("@")) + 1);
|
|
188
|
+
return fileName;
|
|
189
|
+
} catch (_error) {
|
|
190
|
+
return "未知文件名";
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @name 根据文件URL下载文件
|
|
196
|
+
* @param {string} fileUrl 文件路径
|
|
197
|
+
* @param {string} fileName 文件名称
|
|
198
|
+
* @returns {void}
|
|
199
|
+
*/
|
|
200
|
+
export function handleDownloadFile(fileUrl, fileName) {
|
|
201
|
+
if (fileUrl) {
|
|
202
|
+
fetch(fileUrl).then(response => response.blob()).then(blob => {
|
|
203
|
+
// 创建一个临时的URL对象
|
|
204
|
+
const url = URL.createObjectURL(blob);
|
|
205
|
+
// 创建一个隐藏的<a>标签,并设置其href属性为临时URL
|
|
206
|
+
const a = document.createElement("a");
|
|
207
|
+
a.href = url;
|
|
208
|
+
a.download = fileName || getFileName(fileUrl); // 设置下载的文件名
|
|
209
|
+
a.style.display = "none";
|
|
210
|
+
// 将<a>标签添加到文档中,并模拟点击下载
|
|
211
|
+
document.body.appendChild(a);
|
|
212
|
+
a.click();
|
|
213
|
+
// 下载完成后,移除<a>标签和临时URL对象
|
|
214
|
+
document.body.removeChild(a);
|
|
215
|
+
URL.revokeObjectURL(url);
|
|
216
|
+
}).catch(error => {
|
|
217
|
+
notification.error({
|
|
218
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || "文件下载失败"
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
} else {
|
|
222
|
+
notification.error({
|
|
223
|
+
message: "无法正常获取文件路径,请刷新后重试"
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 通用单行比较器
|
|
230
|
+
* @param currentItem a
|
|
231
|
+
* @param nextItem b
|
|
232
|
+
* @param sortField 排序字段
|
|
233
|
+
* @param sortOrder asc | desc
|
|
234
|
+
* @returns number -1 0 1
|
|
235
|
+
*/
|
|
236
|
+
export function itemCompare(currentItem, nextItem, sortField, sortOrder) {
|
|
237
|
+
if (!sortOrder) return 0;
|
|
238
|
+
const valA = currentItem[sortField];
|
|
239
|
+
const valB = nextItem[sortField];
|
|
240
|
+
|
|
241
|
+
// 空值兜底 null/undefined排后面
|
|
242
|
+
if (valA == null && valB != null) return 1;
|
|
243
|
+
if (valA != null && valB == null) return -1;
|
|
244
|
+
if (valA == null && valB == null) return 0;
|
|
245
|
+
let result = 0;
|
|
246
|
+
if (typeof valA === "number" && typeof valB === "number") {
|
|
247
|
+
// 数字
|
|
248
|
+
result = valA - valB;
|
|
249
|
+
} else if (valA instanceof Date && valB instanceof Date) {
|
|
250
|
+
// 日期
|
|
251
|
+
result = valA.getTime() - valB.getTime();
|
|
252
|
+
} else {
|
|
253
|
+
// 字符串(中文拼音排序)
|
|
254
|
+
result = String(valA).localeCompare(String(valB), "zh-CN");
|
|
255
|
+
}
|
|
256
|
+
return sortOrder === "asc" ? result : -result;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @name 对字符串进行base64编码
|
|
261
|
+
* @description 用于对接预览平台
|
|
262
|
+
* @param {string} str 要编码的字符串
|
|
263
|
+
* @returns 编码后的字符串
|
|
264
|
+
*/
|
|
265
|
+
export function base64Encode(str) {
|
|
266
|
+
const utf8Bytes = new TextEncoder().encode(str);
|
|
267
|
+
// 使用 Array.from 将 Uint8Array 转为二进制字符串
|
|
268
|
+
const binaryString = Array.from(utf8Bytes, byte => String.fromCharCode(byte)).join("");
|
|
269
|
+
return btoa(binaryString);
|
|
270
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bee-front-components",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"start": "cross-env UMI_ENV=dev node ../../node_modules/umi/bin/umi.js dev",
|
|
7
|
+
"build": "cross-env UMI_ENV=dev node ../../node_modules/umi/bin/umi.js hzero-build",
|
|
8
|
+
"build:ms": "cross-env BUILD_SINGLE_PUBLIC_MS=true node ../../node_modules/umi/bin/umi.js hzero-build",
|
|
9
|
+
"transpile": "node ../../node_modules/umi/bin/umi.js hzero-transpile",
|
|
10
|
+
"build:app": "cross-env BUILD_SINGLE_PUBLIC_MS=true node ../../node_modules/umi/bin/umi.js hzero-build --only-build-parent",
|
|
11
|
+
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
|
|
12
|
+
"test": "umi-test",
|
|
13
|
+
"test:coverage": "umi-test --coverage"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"lib",
|
|
17
|
+
"config/config.ts",
|
|
18
|
+
"!lib/config/alias.js",
|
|
19
|
+
"!lib/config/babel-config.js",
|
|
20
|
+
"!.umi",
|
|
21
|
+
"!lib/config/.env.*",
|
|
22
|
+
"!lib/config/alias.js",
|
|
23
|
+
"!lib/config/alias.js",
|
|
24
|
+
"!lib/config/theme.js",
|
|
25
|
+
"!lib/config/babel-config.js",
|
|
26
|
+
"!.umi-production"
|
|
27
|
+
],
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@hzero-front-ui/cfg": "*",
|
|
30
|
+
"axios": "*",
|
|
31
|
+
"choerodon-ui": "*",
|
|
32
|
+
"dva": "*",
|
|
33
|
+
"hzero-front": "*",
|
|
34
|
+
"hzero-ui": "*",
|
|
35
|
+
"mobx": "*",
|
|
36
|
+
"react": "*",
|
|
37
|
+
"react-dom": "*",
|
|
38
|
+
"react-intl-universal": "*",
|
|
39
|
+
"mobx-react": "*"
|
|
40
|
+
}
|
|
41
|
+
}
|