js树形选择结构的属性值变更
function changeNodes(data) {
const haveChildren = Array.isArray(data.orginfoList) && data.orginfoList.length > 0;
if (haveChildren) {
return {
reportOrgId: data.orgCode,
reportOrg: data.orgName,
orgTypeId: data.orgTypeId,
children: data.orginfoList.map(i => changeNodes(i)),
}
} else {
return {
reportOrgId: data.orgCode,
reportOrg: data.orgName,
orgTypeId: data.orgTypeId,
}
}
}
let dataList = []
dataList = data.orgTreeInfo.map(org => changeNodes(org))
js对象的去重
arr.reduce((cur, next) => {
obj[next.value] ? "" : obj[next.value] = true && cur.push(next);
return cur;
}, [])