export function handleLeftMenu(classArr,allA) {

 for (let i = 0; i < classArr.length; i++) {
  let findAllChildren = allA.filter(iy => (iy.PARENT || iy.PARENT_LABEL_ID) === (classArr[i].SHOWCODE || classArr[i].LABEL_ID))

  classArr[i].LABEL_ID = classArr[i].LABEL_ID || classArr[i].SHOWCODE
  classArr[i].LABEL_NAME = classArr[i].LABEL_NAME || classArr[i].NAME
  if (findAllChildren.length > 0){
   classArr[i].children = [...findAllChildren.map(ii => ({...ii,LABEL_ID:ii.LABEL_ID ||ii.SHOWCODE,LABEL_NAME:ii.LABEL_NAME||ii.NAME}))]

   handleLeftMenu(classArr[i].children,[...allA])

  }
 }
}
export function handleLeftMenu2(classArr,allA) {

 for (let i = 0; i < classArr.length; i++) {

  let findAllChildren = allA.filter(iy => (iy.HIGHER + '') === (classArr[i].CODE + ''))

  console.log('找到阿德',findAllChildren,classArr[i].CODE)
  if (findAllChildren.length > 0){
   classArr[i].children = [...findAllChildren]

   handleLeftMenu2(classArr[i].children,[...allA])

  }
 }
}
export function handleLeftMenu3(classArr2,arr = []) {
 let classArr =   [...classArr2]
 classArr.sort((pre,cur) => {
  return pre.CODE.localeCompare(cur.CODE)
 })
 for (let j = 0; j < classArr.length; j+1) {

  let allChildren = []
  let findZ = classArr.filter(it => (classArr[j].CODE ) === it.CODE) //有几十个


  for (let k = 0; k < findZ.length; k++) {


   allChildren.push({
    ...findZ[k],
    layer:2,
    NAME:findZ[k].USERNAME
   })



  }


  arr.push({
   layer:1,
   ...classArr[j],
   children:allChildren
  })
  // classArr =  classArr.filter(it => classArr[j].CODE_MIDDLE !== it.CODE_MIDDLE) //有几十个
  j+= findZ.length





 }

 return arr
}
export function handleLeftMenu4(classArr,allA) {

 for (let i = 0; i < classArr.length; i++) {
  let findAllChildren = allA.filter(iy => +(iy.pid) === +(classArr[i].id))


  if (findAllChildren.length > 0){
   findAllChildren.sort((pre,cur) => +pre.o_index - +cur.o_index)
   classArr[i].children = [...findAllChildren]

   handleLeftMenu4(classArr[i].children,[...allA])

  }
 }
}
