原始的数据是平铺的 比如
originalData: [
{ company: 'AAA', department:'AAA-D1', office: 'AAA-D1-O1', pass: 1, onhold: 3},
{ company: 'AAA', department:'AAA-D1', office: 'AAA-D1-O2', pass: 3, onhold: 5},
{ company: 'AAA', department:'AAA-D2', office: 'AAA-D2-O1', pass: 2, onhold: 7},
{ company: 'BBB', department:'BBB-D1', office: 'BBB-D1-O1', pass: 1, onhold: 3},
{ company: 'BBB', department:'BBB-D2', office: 'BBB-D2-O1', pass: 4, onhold: 3},
{ company: 'BBB', department:'BBB-D3', office: 'BBB-D3-O1', pass: 1, onhold: 3},
....
....
]
希望转换成
treeData: [
{ label: 'AAA', department:'AAA-D1', office: 'AAA-D1-O1', pass: 6, onhold: 15, // company level
children: [ // department level
{label: 'AAA-D1', pass: 4, onhold: 8,
children: [ // office level
{label: 'AAA-D1-O1', pass: 1, onhold: 3},
{label: 'AAA-D1-O2', pass: 1, onhold: 3},
]
},
{label: 'AAA-D2', pass: 2, onhold: 7,
children: [
{label: 'AAA-D2-O1', pass: 1, onhold: 3},
]
},
]
},
...
...
]
根据指定的列 转换成父子结构的数据 比如 上面的是根据 ['company', 'department', 'office'] 不知道怎么写了 请大神指导 :( :( :( :( :(
阿晨1998
相关分类