父节点的分数值socre等于直属子节点的score之和,只有最有一级节点的score有值,所以需要倒序求出每个父节点score的值,没想出来要怎么搞,求助大神的帮助
总结就是:3级加起来等于2级,2级加起来等于1级
let treeData = [{
level: "1",
parentCode: "0",
score: "",
setItemCode: "cdx10031",
setItemContent: "一级内容1",
sortNumber: 1,
children: [{
level: "2",
parentCode: "cdx10031",
score: "",
setItemCode: "cdx10061"
setItemContent: "二级内容1-1"
sortNumber: 1,
children: [{
level: "3",
parentCode: "cdx10061",
score: "1",
setItemCode: "cdx10090"
setItemContent: "三级级内容1-1-1"
sortNumber: 1,
},{
level: "3",
parentCode: "cdx10061",
score: "2",
setItemCode: "cdx10091"
setItemContent: "三级内容1-1-2"
sortNumber: 2,
}]
},{
level: "2",
parentCode: "cdx10031",
score: "",
setItemCode: "cdx10062"
setItemContent: "二级内容1-2"
sortNumber: 2,
children: [{
level: "3",
parentCode: "cdx10062",
score: "3",
setItemCode: "cdx10092"
setItemContent: "三级级内容1-2-1"
sortNumber: 1,
},{
level: "3",
parentCode: "cdx10062",
score: "4",
setItemCode: "cdx10093"
setItemContent: "三级内容1-2-2"
sortNumber: 2,
}]
}]
},{
level: "1",
parentCode: "0",
score: "",
setItemCode: "cdx10035",
setItemContent: "一级内容2",
sortNumber: 2,
children: [{
level: "2",
parentCode: "cdx10035",
score: "",
setItemCode: "cdx10065"
setItemContent: "二级内容2-1"
sortNumber: 1,
children: [{
level: "3",
parentCode: "cdx10065",
score: "1",
setItemCode: "cdx10095"
setItemContent: "三级级内容2-1-1"
sortNumber: 1,
},{
level: "3",
parentCode: "cdx10065",
score: "2",
setItemCode: "cdx10096"
setItemContent: "三级内容2-1-2"
sortNumber: 2,
}]
},{
level: "2",
parentCode: "cdx10035",
score: "",
setItemCode: "cdx10066"
setItemContent: "二级内容2-2"
sortNumber: 2,
children: [{
level: "3",
parentCode: "cdx10066",
score: "3",
setItemCode: "cdx10097"
setItemContent: "三级级内容2-2-1"
sortNumber: 1,
},{
level: "3",
parentCode: "cdx10066",
score: "4",
setItemCode: "cdx10098"
setItemContent: "三级内容2-2-2"
sortNumber: 2,
}]
}]
}]
先算出二级的score,之后再算一级的score