fnUtils.ts
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// 将后端返回的字段转换成树组件的ApiSelectTree的对应字段
export const copyTransFun = (arr: any[]) => {
arr.forEach((item) => {
if (item.name) {
item.label = item.name;
delete item.name;
}
if (item.id) {
item.value = item.id;
delete item.id;
}
if (item.children) {
if (item.children.length) {
copyTransFun(item.children);
}
}
});
};
// 将后端返回的字段转换成树组件的Tree的对应字段
export const copyTransTreeFun = (arr: any[]) => {
arr.forEach((item) => {
if (item.name) {
item.title = item.name;
delete item.name;
}
if (item.id) {
item.key = item.id;
delete item.id;
}
if (item.children) {
if (item.children.length) {
copyTransTreeFun(item.children);
}
}
});
};
// 百度地图url
export const register_BAI_DU_MAP_URL = (ak: string) => {
return `https://api.map.baidu.com/getscript?v=3.0&ak=${ak}`;
};
export const BAI_DU_MAP_URL = register_BAI_DU_MAP_URL('7uOPPyAHn2Y2ZryeQqHtcRqtIY374vKa');