|
@@ -19,7 +19,7 @@ export function getDescriptions(enumArr: any[], arr: any[]) {
|
|
* @param {Array} customParams 要插入数据的目标可以不传 { 0: { disabled: true } } 第0个数据内插入disabled: true
|
|
* @param {Array} customParams 要插入数据的目标可以不传 { 0: { disabled: true } } 第0个数据内插入disabled: true
|
|
* */
|
|
* */
|
|
export function convertEnumArr(enumArr: any, customParams: any = {}, config?: { key: string, value: string }) {
|
|
export function convertEnumArr(enumArr: any, customParams: any = {}, config?: { key: string, value: string }) {
|
|
- let result: { [key: string|number]: { text: string, disabled?: boolean } } = {};
|
|
|
|
|
|
+ let result: { [key: string | number]: { text: string, disabled?: boolean } } = {};
|
|
for (let item of enumArr) {
|
|
for (let item of enumArr) {
|
|
let newItem = { text: config ? item[config.value] : item.description };
|
|
let newItem = { text: config ? item[config.value] : item.description };
|
|
if (customParams[item.value]) {
|
|
if (customParams[item.value]) {
|
|
@@ -33,15 +33,15 @@ export function convertEnumArr(enumArr: any, customParams: any = {}, config?: {
|
|
/** base64转File */
|
|
/** base64转File */
|
|
export const dataURLtoFile = (dataurl: any, filename: any) => {
|
|
export const dataURLtoFile = (dataurl: any, filename: any) => {
|
|
let arr = dataurl.split(','),
|
|
let arr = dataurl.split(','),
|
|
- mime = arr[0].match(/:(.*?);/)[1],
|
|
|
|
- bstr = atob(arr[1]),
|
|
|
|
- n = bstr.length,
|
|
|
|
- u8arr = new Uint8Array(n);
|
|
|
|
|
|
+ mime = arr[0].match(/:(.*?);/)[1],
|
|
|
|
+ bstr = atob(arr[1]),
|
|
|
|
+ n = bstr.length,
|
|
|
|
+ u8arr = new Uint8Array(n);
|
|
while (n--) {
|
|
while (n--) {
|
|
- u8arr[n] = bstr.charCodeAt(n);
|
|
|
|
|
|
+ u8arr[n] = bstr.charCodeAt(n);
|
|
}
|
|
}
|
|
return new File([u8arr], filename, { type: mime });
|
|
return new File([u8arr], filename, { type: mime });
|
|
- };
|
|
|
|
|
|
+};
|
|
|
|
|
|
// 点击复制
|
|
// 点击复制
|
|
export const copy = (str: string) => {
|
|
export const copy = (str: string) => {
|
|
@@ -53,4 +53,14 @@ export const copy = (str: string) => {
|
|
document.execCommand("Copy")
|
|
document.execCommand("Copy")
|
|
document.body.removeChild(element);
|
|
document.body.removeChild(element);
|
|
message.success(`复制成功:${str}`)
|
|
message.success(`复制成功:${str}`)
|
|
|
|
+}
|
|
|
|
+// 将地址上的参数解析成对象
|
|
|
|
+export const searchToObj =(searchStr: string) => {
|
|
|
|
+ const searchParams = new URLSearchParams(searchStr);
|
|
|
|
+ // 将其转换为对象
|
|
|
|
+ const paramsObj: any = {};
|
|
|
|
+ searchParams.forEach((value, key) => {
|
|
|
|
+ paramsObj[key] = value;
|
|
|
|
+ });
|
|
|
|
+ return paramsObj
|
|
}
|
|
}
|