1.文件 index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="./index.js"></script>
</body>
</html>
2.文件 index.js:
let data2 = [
{ id: '10000', parentId: null, name: '账号管理' },
{ id: '11000', parentId: '10000', name: '用户管理' },
{ id: '11100', parentId: '11000', name: '查看' },
{ id: '11110', parentId: '11100', name: '用户列表' },
{ id: '11200', parentId: '11000', name: '编辑' },
{ id: '11210', parentId: '11200', name: '用户列表' },
{ id: '11220', parentId: '11200', name: '新增用户' },
{ id: '11300', parentId: '11000', name: '操作' },
{ id: '11310', parentId: '11300', name: '新增' },
{ id: '11320', parentId: '11300', name: '删除' },
{ id: '11330', parentId: '11300', name: '修改' },
{ id: '12000', parentId: '10000', name: '角色管理' },
{ id: '12100', parentId: '12000', name: '查看' },
{ id: '12110', parentId: '12100', name: '角色列表' },
{ id: '12200', parentId: '12000', name: '编辑' },
{ id: '122100', parentId: '12200', name: '角色列表' },
{ id: '12220', parentId: '12200', name: '新增角色' },
{ id: '12300', parentId: '12000', name: '操作' },
{ id: '12310', parentId: '12300', name: '新增' },
{ id: '12320', parentId: '12300', name: '删除' },
{ id: '12330', parentId: '12300', name: '修改' },
{ id: '20000', parentId: null, name: '个人中心' },
{ id: '21000', parentId: '20000', name: '个性化设置' },
{ id: '21100', parentId: '21000', name: '查看' },
{ id: '21110', parentId: '21100', name: '信息列表' },
{ id: '21200', parentId: '21000', name: '操作' },
{ id: '21210', parentId: '21200', name: '重置信息' },
{ id: '22000', parentId: '20000', name: '账户管理' },
{ id: '22100', parentId: '22000', name: '查看' },
{ id: '22110', parentId: '22100', name: '账户余额' },
{ id: '22120', parentId: '22100', name: '帐变记录' }
]
let data = [
{
id: "13",
createdAt: "2021-07-17 23:32:16",
updatedAt: "2021-07-17 23:32:16",
title: "查询",
parentId: "12",
type: 2,
typeLabel: "按钮",
permission: "SysRole:retrieve",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564280197120",
name: "1550072564280197120",
meta: { title: "查询", affix: false, icon: null },
idStr: "13",
},
{
id: "18",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "查询",
parentId: "17",
type: 2,
typeLabel: "按钮",
permission: "SysUser:retrieve",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564280197121",
name: "1550072564280197121",
meta: { title: "查询", affix: false, icon: null },
idStr: "18",
},
{
id: "43",
createdAt: "2021-07-17 23:32:21",
updatedAt: "2021-07-17 23:32:21",
title: "查询",
parentId: "42",
type: 2,
typeLabel: "按钮",
permission: "SysLog:retrieve",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564284391424",
name: "1550072564284391424",
meta: { title: "查询", affix: false, icon: null },
idStr: "43",
},
{
id: "50",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "地图首页",
parentId: null,
type: 0,
typeLabel: "目录",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564284391425",
name: "1550072564284391425",
meta: { title: "地图首页", affix: false, icon: null },
idStr: "50",
},
{
id: "51",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "浏览",
parentId: "50",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564284391426",
meta: { title: "浏览", affix: false, icon: null },
idStr: "51",
},
{
id: "58",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "信息显示",
parentId: "57",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564284391427",
meta: { title: "信息显示", affix: false, icon: null },
idStr: "58",
},
{
id: "66",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "数据采集",
parentId: "65",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564284391428",
meta: { title: "数据采集", affix: false, icon: null },
idStr: "66",
},
{
id: "67",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "开始",
parentId: "66",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564288585728",
name: "1550072564288585728",
meta: { title: "开始", affix: false, icon: null },
idStr: "67",
},
{
id: "70",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "接收机数据",
parentId: "69",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564288585729",
meta: { title: "接收机数据", affix: false, icon: null },
idStr: "70",
},
{
id: "71",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "浏览",
parentId: "70",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564288585730",
name: "1550072564288585730",
meta: { title: "浏览", affix: false, icon: null },
idStr: "71",
},
{
id: "74",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "浏览",
parentId: "73",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564288585731",
name: "1550072564288585731",
meta: { title: "浏览", affix: false, icon: null },
idStr: "74",
},
{
id: "80",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "浏览",
parentId: "79",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564288585732",
name: "1550072564288585732",
meta: { title: "浏览", affix: false, icon: null },
idStr: "80",
},
{
id: "83",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "点选",
parentId: "82",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564288585733",
meta: { title: "点选", affix: false, icon: null },
idStr: "83",
},
{
id: "91",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "浏览",
parentId: "90",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 1,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564292780032",
name: "1550072564292780032",
meta: { title: "浏览", affix: false, icon: null },
idStr: "91",
},
{
id: "12",
createdAt: "2021-07-17 23:32:16",
updatedAt: "2021-07-17 23:32:16",
title: "角色权限",
parentId: "1",
type: 1,
typeLabel: "菜单",
permission: "SysRole",
icon: "http://58.57.119.9:8989/visual_map_file/shezhitianchong.svg",
sort: 2,
status: 1,
statusLabel: "启用",
component: "@/views/permissionManage/index.vue",
externalLink: null,
path: "/@/views/permissionManage/index.vue",
name: "1550072564292780033",
meta: {
title: "角色权限",
affix: false,
icon: "http://58.57.119.9:8989/visual_map_file/shezhitianchong.svg",
},
idStr: "12",
},
{
id: "14",
createdAt: "2021-07-17 23:32:16",
updatedAt: "2021-07-17 23:32:16",
title: "新增",
parentId: "12",
type: 2,
typeLabel: "按钮",
permission: "SysRole:create",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564292780034",
name: "1550072564292780034",
meta: { title: "新增", affix: false, icon: null },
idStr: "14",
},
{
id: "19",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "新增",
parentId: "17",
type: 2,
typeLabel: "按钮",
permission: "SysUser:create",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564292780035",
name: "1550072564292780035",
meta: { title: "新增", affix: false, icon: null },
idStr: "19",
},
{
id: "52",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "搜索",
parentId: "50",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564292780036",
meta: { title: "搜索", affix: false, icon: null },
idStr: "52",
},
{
id: "57",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "接收机",
parentId: null,
type: 0,
typeLabel: "目录",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564296974336",
name: "1550072564296974336",
meta: { title: "接收机", affix: false, icon: null },
idStr: "57",
},
{
id: "59",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "信息编辑",
parentId: "57",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564296974337",
meta: { title: "信息编辑", affix: false, icon: null },
idStr: "59",
},
{
id: "64",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "导出",
parentId: "62",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564296974338",
name: "1550072564296974338",
meta: { title: "导出", affix: false, icon: null },
idStr: "64",
},
{
id: "68",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "开始计算",
parentId: "66",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564296974339",
name: "1550072564296974339",
meta: { title: "开始计算", affix: false, icon: null },
idStr: "68",
},
{
id: "72",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "导出",
parentId: "70",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564296974340",
name: "1550072564296974340",
meta: { title: "导出", affix: false, icon: null },
idStr: "72",
},
{
id: "73",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "定位数据",
parentId: "69",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564296974341",
meta: { title: "定位数据", affix: false, icon: null },
idStr: "73",
},
{
id: "75",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "导出",
parentId: "73",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564301168640",
name: "1550072564301168640",
meta: { title: "导出", affix: false, icon: null },
idStr: "75",
},
{
id: "81",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "下载",
parentId: "79",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564301168641",
name: "1550072564301168641",
meta: { title: "下载", affix: false, icon: null },
idStr: "81",
},
{
id: "84",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "圈选",
parentId: "82",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564301168642",
meta: { title: "圈选", affix: false, icon: null },
idStr: "84",
},
{
id: "92",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "上传",
parentId: "90",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 2,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564301168643",
name: "1550072564301168643",
meta: { title: "上传", affix: false, icon: null },
idStr: "92",
},
{
id: "17",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "用户管理",
parentId: "1",
type: 1,
typeLabel: "菜单",
permission: "SysUser",
icon: "http://58.57.119.9:8989/visual_map_file/yonghu.svg",
sort: 3,
status: 1,
statusLabel: "启用",
component: "@/views/permissionManage/index.vue",
externalLink: null,
path: "/@/views/permissionManage/index.vue",
name: "1550072564301168644",
meta: {
title: "用户管理",
affix: false,
icon: "http://58.57.119.9:8989/visual_map_file/yonghu.svg",
},
idStr: "17",
},
{
id: "22",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "启用/禁用(用户)",
parentId: "17",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 3,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564301168645",
name: "1550072564301168645",
meta: { title: "启用/禁用(用户)", affix: false, icon: null },
idStr: "22",
},
{
id: "23",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "启用/禁用(角色)",
parentId: "12",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 3,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564305362944",
name: "1550072564305362944",
meta: { title: "启用/禁用(角色)", affix: false, icon: null },
idStr: "23",
},
{
id: "53",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "图例",
parentId: "50",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 3,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564305362945",
meta: { title: "图例", affix: false, icon: null },
idStr: "53",
},
{
id: "60",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "新增点位",
parentId: "57",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 3,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564305362946",
meta: { title: "新增点位", affix: false, icon: null },
idStr: "60",
},
{
id: "65",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "数据采集",
parentId: null,
type: 0,
typeLabel: "目录",
permission: "",
icon: null,
sort: 3,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564305362947",
name: "1550072564305362947",
meta: { title: "数据采集", affix: false, icon: null },
idStr: "65",
},
{
id: "76",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "开始计算",
parentId: "73",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 3,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564305362948",
name: "1550072564305362948",
meta: { title: "开始计算", affix: false, icon: null },
idStr: "76",
},
{
id: "79",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "采集数据",
parentId: "69",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 3,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564309557248",
meta: { title: "采集数据", affix: false, icon: null },
idStr: "79",
},
{
id: "86",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "框选",
parentId: "82",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 3,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564309557249",
meta: { title: "框选", affix: false, icon: null },
idStr: "86",
},
{
id: "93",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "显示/隐藏",
parentId: "90",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 3,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564309557250",
name: "1550072564309557250",
meta: { title: "显示/隐藏", affix: false, icon: null },
idStr: "93",
},
{
id: "16",
createdAt: "2021-07-17 23:32:16",
updatedAt: "2021-07-17 23:32:16",
title: "编辑",
parentId: "12",
type: 2,
typeLabel: "按钮",
permission: "SysRole:update",
icon: null,
sort: 4,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564309557251",
name: "1550072564309557251",
meta: { title: "编辑", affix: false, icon: null },
idStr: "16",
},
{
id: "21",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "编辑",
parentId: "17",
type: 2,
typeLabel: "按钮",
permission: "SysUser:update",
icon: null,
sort: 4,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564309557252",
name: "1550072564309557252",
meta: { title: "编辑", affix: false, icon: null },
idStr: "21",
},
{
id: "54",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "地图切换",
parentId: "50",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 4,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564309557253",
meta: { title: "地图切换", affix: false, icon: null },
idStr: "54",
},
{
id: "61",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "数据下载",
parentId: "57",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 4,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564313751552",
meta: { title: "数据下载", affix: false, icon: null },
idStr: "61",
},
{
id: "69",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "数据查询",
parentId: null,
type: 0,
typeLabel: "目录",
permission: "",
icon: null,
sort: 4,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564313751553",
name: "1550072564313751553",
meta: { title: "数据查询", affix: false, icon: null },
idStr: "69",
},
{
id: "77",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "查看热力图",
parentId: "73",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 4,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564313751554",
name: "1550072564313751554",
meta: { title: "查看热力图", affix: false, icon: null },
idStr: "77",
},
{
id: "87",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "多边形选",
parentId: "82",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 4,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564313751555",
meta: { title: "多边形选", affix: false, icon: null },
idStr: "87",
},
{
id: "94",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "查看",
parentId: "90",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 4,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564313751556",
name: "1550072564313751556",
meta: { title: "查看", affix: false, icon: null },
idStr: "94",
},
{
id: "15",
createdAt: "2021-07-17 23:32:16",
updatedAt: "2021-07-17 23:32:16",
title: "删除",
parentId: "12",
type: 2,
typeLabel: "按钮",
permission: "SysRole:delete",
icon: null,
sort: 5,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564317945856",
name: "1550072564317945856",
meta: { title: "删除", affix: false, icon: null },
idStr: "15",
},
{
id: "20",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "删除",
parentId: "17",
type: 2,
typeLabel: "按钮",
permission: "SysUser:delete",
icon: null,
sort: 5,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564317945857",
name: "1550072564317945857",
meta: { title: "删除", affix: false, icon: null },
idStr: "20",
},
{
id: "55",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "视角切换",
parentId: "50",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 5,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564317945858",
meta: { title: "视角切换", affix: false, icon: null },
idStr: "55",
},
{
id: "62",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "告警查询",
parentId: "57",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 5,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564317945859",
meta: { title: "告警查询", affix: false, icon: null },
idStr: "62",
},
{
id: "78",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "更改类型",
parentId: "73",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 5,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564317945860",
name: "1550072564317945860",
meta: { title: "更改类型", affix: false, icon: null },
idStr: "78",
},
{
id: "82",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "地图工具",
parentId: null,
type: 0,
typeLabel: "目录",
permission: "",
icon: null,
sort: 5,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564317945861",
name: "1550072564317945861",
meta: { title: "地图工具", affix: false, icon: null },
idStr: "82",
},
{
id: "88",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "测距",
parentId: "82",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 5,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564322140160",
meta: { title: "测距", affix: false, icon: null },
idStr: "88",
},
{
id: "95",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "编辑",
parentId: "90",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 5,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564322140161",
name: "1550072564322140161",
meta: { title: "编辑", affix: false, icon: null },
idStr: "95",
},
{
id: "1",
createdAt: "2021-06-01 17:16:48",
updatedAt: "2021-06-02 17:14:16",
title: "系统管理",
parentId: null,
type: 0,
typeLabel: "目录",
permission: "Sys",
icon: null,
sort: 6,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564322140162",
name: "1550072564322140162",
meta: { title: "系统管理", affix: false, icon: null },
idStr: "1",
},
{
id: "45",
createdAt: "2021-07-17 23:39:41",
updatedAt: "2021-07-17 23:39:41",
title: "重置某用户密码",
parentId: "17",
type: 2,
typeLabel: "按钮",
permission: "SysUser:resetPassword",
icon: null,
sort: 6,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564322140163",
name: "1550072564322140163",
meta: { title: "重置某用户密码", affix: false, icon: null },
idStr: "45",
},
{
id: "48",
createdAt: "2022-06-29 19:17:33",
updatedAt: "2022-06-29 19:17:38",
title: "绑定角色与菜单关联关系",
parentId: "12",
type: 2,
typeLabel: "按钮",
permission: "SysRole:bindMenus",
icon: null,
sort: 6,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564322140164",
name: "1550072564322140164",
meta: { title: "绑定角色与菜单关联关系", affix: false, icon: null },
idStr: "48",
},
{
id: "56",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "信息显隐",
parentId: "50",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 6,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564322140165",
meta: { title: "信息显隐", affix: false, icon: null },
idStr: "56",
},
{
id: "63",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "浏览",
parentId: "62",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 6,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564326334464",
name: "1550072564326334464",
meta: { title: "浏览", affix: false, icon: null },
idStr: "63",
},
{
id: "89",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "测面",
parentId: "82",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 6,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564326334465",
meta: { title: "测面", affix: false, icon: null },
idStr: "89",
},
{
id: "96",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "删除",
parentId: "90",
type: 2,
typeLabel: "按钮",
permission: "",
icon: null,
sort: 6,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564326334466",
name: "1550072564326334466",
meta: { title: "删除", affix: false, icon: null },
idStr: "96",
},
{
id: "47",
createdAt: "2021-07-17 23:40:47",
updatedAt: "2021-07-17 23:41:15",
title: "踢某用户下线",
parentId: "17",
type: 2,
typeLabel: "按钮",
permission: "SysUser:kickOut",
icon: null,
sort: 7,
status: 1,
statusLabel: "启用",
component: "LAYOUT",
externalLink: null,
path: "/1550072564326334467",
name: "1550072564326334467",
meta: { title: "踢某用户下线", affix: false, icon: null },
idStr: "47",
},
{
id: "90",
createdAt: "2021-07-17 23:32:17",
updatedAt: "2021-07-17 23:32:17",
title: "图层导入",
parentId: "82",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 7,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564326334468",
meta: { title: "图层导入", affix: false, icon: null },
idStr: "90",
},
{
id: "42",
createdAt: "2021-07-17 23:32:21",
updatedAt: "2021-07-17 23:32:21",
title: "系统日志",
parentId: "1",
type: 1,
typeLabel: "菜单",
permission: "SysLog",
icon: "http://58.57.119.9:8989/visual_map_file/rizhi.svg",
sort: 8,
status: 1,
statusLabel: "启用",
component: "@/views/logManage/index.vue",
externalLink: null,
path: "/@/views/logManage/index.vue",
name: "1550072564326334469",
meta: {
title: "系统日志",
affix: false,
icon: "http://58.57.119.9:8989/visual_map_file/rizhi.svg",
},
idStr: "42",
},
{
id: "44",
createdAt: "2021-07-17 23:37:26",
updatedAt: "2021-07-17 23:38:28",
title: "修改当前用户密码",
parentId: "1",
type: 1,
typeLabel: "菜单",
permission: "",
icon: null,
sort: 9,
status: 1,
statusLabel: "启用",
component: null,
externalLink: null,
path: null,
name: "1550072564330528768",
meta: { title: "修改当前用户密码", affix: false, icon: null },
idStr: "44",
},
];
// console.log('data==',data);
// 封装方法,引入使用
// export function menu2Tree(items: any) {
// const data = JSON.parse(JSON.stringify(items)) // 深拷贝不改变源数据
// const result = []
// if (!Array.isArray(data)) {
// return result
// }
// data.forEach((item) => {
// delete item.children
// })
// const map = {}
// data.forEach((item) => {
// map[item.id] = item
// })
// console.log('map==',map);
// data.forEach((item) => {
// const parent = map[item.parentId]
// if (parent) {
// ;(parent.children || (parent.children = [])).push(item)
// } else {
// // @ts-ignore
// result.push(item)
// }
// })
// console.log('result', result)
// return result
// }
const result = []
data.forEach((item) => {
delete item.children
})
const map = {}
data.forEach((item) => {
map[item.id] = item
})
// 获取id的map对象
console.log('map==',map);
data.forEach((item) => {
// 根据map对象筛选parentId的数据
const parent = map[item.parentId]
console.log('parent==',parent);
// 如果存在parentId说明属于子节点,push到children数组里,如果不存在parentId说明是顶级父节点,直接push到最终的result里
if (parent) {
;(parent.children || (parent.children = [])).push(item)
} else {
// @ts-ignore
result.push(item)
}
})
// 得到最终的数据
console.log('result', result)