|
@@ -190,6 +190,7 @@ export default {
|
|
|
// childrenKey: 'children'
|
|
// childrenKey: 'children'
|
|
|
// })
|
|
// })
|
|
|
const data1 = JSON.parse(JSON.stringify(data))
|
|
const data1 = JSON.parse(JSON.stringify(data))
|
|
|
|
|
+ data1.sort((a, b) => a.sn - b.sn)
|
|
|
const map = new Map()
|
|
const map = new Map()
|
|
|
const tree = []
|
|
const tree = []
|
|
|
// 第一遍遍历:将所有节点存入映射表,并初始化children数组
|
|
// 第一遍遍历:将所有节点存入映射表,并初始化children数组
|
|
@@ -197,6 +198,11 @@ export default {
|
|
|
item.children = [] // 初始化子节点数组
|
|
item.children = [] // 初始化子节点数组
|
|
|
map.set(item.id, item)
|
|
map.set(item.id, item)
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ 'data1===>',
|
|
|
|
|
+ data1.map((t) => t.sn)
|
|
|
|
|
+ )
|
|
|
// 第二遍遍历:建立父子关系
|
|
// 第二遍遍历:建立父子关系
|
|
|
data1.forEach((item) => {
|
|
data1.forEach((item) => {
|
|
|
const parentId = item.parentId
|
|
const parentId = item.parentId
|