fnUtils.ts 1.06 KB
// 将后端返回的字段转换成树组件的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');