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,95 @@
|
|
|
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;
|
|
@@ -0,0 +1,319 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
interface IOpenTabOption {
|
|
2
|
+
/** 打开tab的key */
|
|
3
|
+
key?: string;
|
|
4
|
+
/** 打开页面的 path, 默认值 path = key */
|
|
5
|
+
path: string;
|
|
6
|
+
/** tab的标题 */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** 当前菜单所对应的id */
|
|
9
|
+
menuId?: string;
|
|
10
|
+
/** tab 是否可以关闭 */
|
|
11
|
+
closable?: boolean;
|
|
12
|
+
/** query 值 */
|
|
13
|
+
query?: Record<string, any>;
|
|
14
|
+
/** 返回上一页面的配置信息 */
|
|
15
|
+
backOption?: IOpenTabOption;
|
|
16
|
+
/** 其他可能存在的属性 */
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @name 关闭当前页签
|
|
21
|
+
* @param {string} pathname 需要关闭的页签路径
|
|
22
|
+
* @returns {void}
|
|
23
|
+
*/
|
|
24
|
+
export declare function closeTab(pathname: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* @name 刷新当前页签
|
|
27
|
+
* @param {string} pathname 需要刷新的页签路径
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
30
|
+
export declare function refreshTab(pathname: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* @name 路由切换相关传参信息隐式处理(类encrypt加密)
|
|
33
|
+
* @param {IOpenTabOption} options 需要进行隐式处理的页签配置信息
|
|
34
|
+
* @returns {string} 隐式处理后的短码
|
|
35
|
+
*/
|
|
36
|
+
export declare function encryptTabOptions(options: IOpenTabOption): string;
|
|
37
|
+
/**
|
|
38
|
+
* @name 路由切换相关传参信息显式处理(类encrypt解密)
|
|
39
|
+
* @param {string} optionKey 需要进行显式处理的页签配置信息存储key值
|
|
40
|
+
* @returns {IOpenTabOption|null} 显式处理后的页签配置信息
|
|
41
|
+
*/
|
|
42
|
+
export declare function decryptTabOptions(optionKey?: string): IOpenTabOption | null;
|
|
43
|
+
/**
|
|
44
|
+
* @name 打开某页签
|
|
45
|
+
* @param {IOpenTabOption} tabOptions 需要打开的页签参数
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*/
|
|
48
|
+
export declare function openTab(tabOptions: IOpenTabOption): void;
|
|
49
|
+
/**
|
|
50
|
+
* @name 返回上一页
|
|
51
|
+
* @param {object} params 上一页路径参数
|
|
52
|
+
* @param {string} params.path 上一页路径
|
|
53
|
+
* @param {string} params.title 上一页标题
|
|
54
|
+
* @param {boolean} params.isRefresh 是否刷新上一页
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*/
|
|
57
|
+
export declare function backTab(params?: IOpenTabOption & {
|
|
58
|
+
isRefresh?: boolean;
|
|
59
|
+
}): void;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["path", "isRefresh"];
|
|
3
|
+
// 二次封装菜单切换相关tab操作工具
|
|
4
|
+
import { getSession, setSession } from "utils/utils";
|
|
5
|
+
import { getTabFromKey, closeTab as customCloseTab, openTab as customOpenTab, refreshTab as customRefreshTab } from "utils/menuTab";
|
|
6
|
+
import { generateUUID } from "./utils";
|
|
7
|
+
/**
|
|
8
|
+
* @name 关闭当前页签
|
|
9
|
+
* @param {string} pathname 需要关闭的页签路径
|
|
10
|
+
* @returns {void}
|
|
11
|
+
*/
|
|
12
|
+
export function closeTab(pathname) {
|
|
13
|
+
customCloseTab(pathname);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @name 刷新当前页签
|
|
18
|
+
* @param {string} pathname 需要刷新的页签路径
|
|
19
|
+
* @returns {void}
|
|
20
|
+
*/
|
|
21
|
+
export function refreshTab(pathname) {
|
|
22
|
+
customRefreshTab(pathname);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @name 路由切换相关传参信息隐式处理(类encrypt加密)
|
|
27
|
+
* @param {IOpenTabOption} options 需要进行隐式处理的页签配置信息
|
|
28
|
+
* @returns {string} 隐式处理后的短码
|
|
29
|
+
*/
|
|
30
|
+
export function encryptTabOptions(options) {
|
|
31
|
+
const menuId = (options === null || options === void 0 ? void 0 : options.menuId) || generateUUID(); // 当前父页面的菜单ID
|
|
32
|
+
const key = `${menuId === null || menuId === void 0 ? void 0 : menuId.slice(2, 5)}${menuId === null || menuId === void 0 ? void 0 : menuId.slice(12, 15)}`; // 分别两次从中取3位字符拼接成新的6位字符作为其父页面页签配置信息存储短码
|
|
33
|
+
setSession(key, JSON.stringify(options));
|
|
34
|
+
return key;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @name 路由切换相关传参信息显式处理(类encrypt解密)
|
|
39
|
+
* @param {string} optionKey 需要进行显式处理的页签配置信息存储key值
|
|
40
|
+
* @returns {IOpenTabOption|null} 显式处理后的页签配置信息
|
|
41
|
+
*/
|
|
42
|
+
export function decryptTabOptions(optionKey) {
|
|
43
|
+
if (!optionKey) return null;
|
|
44
|
+
try {
|
|
45
|
+
const dataStr = getSession(optionKey);
|
|
46
|
+
return dataStr ? JSON.parse(dataStr) : null;
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @name 打开某页签
|
|
54
|
+
* @param {IOpenTabOption} tabOptions 需要打开的页签参数
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*/
|
|
57
|
+
export function openTab(tabOptions) {
|
|
58
|
+
var _location;
|
|
59
|
+
const fromKey = ((_location = location) === null || _location === void 0 ? void 0 : _location.pathname) || "";
|
|
60
|
+
const fromTabs = getTabFromKey(fromKey);
|
|
61
|
+
const bq = (tabOptions === null || tabOptions === void 0 ? void 0 : tabOptions.backOption) || fromTabs;
|
|
62
|
+
customOpenTab({
|
|
63
|
+
key: (tabOptions === null || tabOptions === void 0 ? void 0 : tabOptions.key) || (tabOptions === null || tabOptions === void 0 ? void 0 : tabOptions.path),
|
|
64
|
+
closable: true,
|
|
65
|
+
...tabOptions,
|
|
66
|
+
query: {
|
|
67
|
+
...(tabOptions === null || tabOptions === void 0 ? void 0 : tabOptions.query),
|
|
68
|
+
bq: encryptTabOptions(bq)
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @name 返回上一页
|
|
75
|
+
* @param {object} params 上一页路径参数
|
|
76
|
+
* @param {string} params.path 上一页路径
|
|
77
|
+
* @param {string} params.title 上一页标题
|
|
78
|
+
* @param {boolean} params.isRefresh 是否刷新上一页
|
|
79
|
+
* @returns {void}
|
|
80
|
+
*/
|
|
81
|
+
export function backTab(params) {
|
|
82
|
+
var _location2;
|
|
83
|
+
const _isRefresh$params = {
|
|
84
|
+
isRefresh: true,
|
|
85
|
+
...params
|
|
86
|
+
},
|
|
87
|
+
_isRefresh$params$pat = _isRefresh$params.path,
|
|
88
|
+
path = _isRefresh$params$pat === void 0 ? "" : _isRefresh$params$pat,
|
|
89
|
+
_isRefresh$params$isR = _isRefresh$params.isRefresh,
|
|
90
|
+
isRefresh = _isRefresh$params$isR === void 0 ? true : _isRefresh$params$isR,
|
|
91
|
+
args = _objectWithoutProperties(_isRefresh$params, _excluded);
|
|
92
|
+
const closePath = (_location2 = location) === null || _location2 === void 0 ? void 0 : _location2.pathname; // 当前需要返回的页面路径
|
|
93
|
+
closePath && closeTab(closePath); // 关闭当前页面
|
|
94
|
+
let openPath = path; // 当前需要进入的页面路径
|
|
95
|
+
// 如果自定义了返回路径 则进入自定义路径
|
|
96
|
+
if (path) {
|
|
97
|
+
customOpenTab({
|
|
98
|
+
key: path,
|
|
99
|
+
closable: true,
|
|
100
|
+
...args
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
// 否则读取缓存中的返回信息
|
|
104
|
+
let optionKey = "";
|
|
105
|
+
try {
|
|
106
|
+
var _location3;
|
|
107
|
+
const query = new URLSearchParams((_location3 = location) === null || _location3 === void 0 ? void 0 : _location3.search);
|
|
108
|
+
optionKey = (query === null || query === void 0 ? void 0 : query.get("bq")) || "";
|
|
109
|
+
} catch {
|
|
110
|
+
optionKey = "";
|
|
111
|
+
}
|
|
112
|
+
const backOptions = decryptTabOptions(optionKey);
|
|
113
|
+
if (backOptions) {
|
|
114
|
+
openPath = backOptions === null || backOptions === void 0 ? void 0 : backOptions.path;
|
|
115
|
+
customOpenTab({
|
|
116
|
+
key: openPath,
|
|
117
|
+
...backOptions
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
isRefresh && refreshTab(openPath);
|
|
122
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name 根据文件后缀判断onlyoffice文件配置参数
|
|
3
|
+
* @param {string} fileSuffix
|
|
4
|
+
* @returns {unknown} onlyoffice的配置项类型
|
|
5
|
+
*/
|
|
6
|
+
export declare function getOnlyofficeConfig(fileSuffix: string): {
|
|
7
|
+
documentType: string;
|
|
8
|
+
fileType: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 金额千分位格式化(支持负数,但货币场景通常非负)
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatThousandMoney(value: number | string | undefined | null, decimals?: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* 小写金额转人民币大写(财务票据标准)
|
|
16
|
+
* @param num 金额:数字 / 带千分位字符串
|
|
17
|
+
* @returns 人民币大写字符串
|
|
18
|
+
*/
|
|
19
|
+
export declare function moneyToChinese(num: number | string): string;
|
|
20
|
+
/**
|
|
21
|
+
* @name 随机生成16位uuid
|
|
22
|
+
* @returns {string}
|
|
23
|
+
*/
|
|
24
|
+
export declare function generateUUID(): string;
|
|
25
|
+
/**
|
|
26
|
+
* @name 根据URL获取文件UUID
|
|
27
|
+
* @description 文件路径形如xxxx/363a7627e49b45dc895a1f16fadfc521@文件名称.png
|
|
28
|
+
* @param {string} url 文件路径
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
export declare function getFileUUID(url: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* @name 根据URL获取文件名称
|
|
34
|
+
* @description 文件路径形如xxxx/363a7627e49b45dc895a1f16fadfc521@文件名称.png
|
|
35
|
+
* @param {string} url 文件路径
|
|
36
|
+
* @returns {string}
|
|
37
|
+
*/
|
|
38
|
+
export declare function getFileName(url: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* @name 根据文件URL下载文件
|
|
41
|
+
* @param {string} fileUrl 文件路径
|
|
42
|
+
* @param {string} fileName 文件名称
|
|
43
|
+
* @returns {void}
|
|
44
|
+
*/
|
|
45
|
+
export declare function handleDownloadFile(fileUrl: string, fileName?: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* 通用单行比较器
|
|
48
|
+
* @param currentItem a
|
|
49
|
+
* @param nextItem b
|
|
50
|
+
* @param sortField 排序字段
|
|
51
|
+
* @param sortOrder asc | desc
|
|
52
|
+
* @returns number -1 0 1
|
|
53
|
+
*/
|
|
54
|
+
export declare function itemCompare<T>(currentItem: T, nextItem: T, sortField: keyof T, sortOrder: "asc" | "desc" | undefined): number;
|
|
55
|
+
/**
|
|
56
|
+
* @name 对字符串进行base64编码
|
|
57
|
+
* @description 用于对接预览平台
|
|
58
|
+
* @param {string} str 要编码的字符串
|
|
59
|
+
* @returns 编码后的字符串
|
|
60
|
+
*/
|
|
61
|
+
export declare function base64Encode(str: string): string;
|