// 这里是DTO数据定义集合
// import Mock from 'mockjs'

// export const team = Mock.mock({
//   'data|1-1': [
//     {
//       id: 0,
//       name: '杭州复杂美科技有限公司',
//       'children|1-3': [{
//         parentId: 0,
//         'id|1-5': 1,
//         name: Mock.mock('@ctitle')
//       }]
//     }
//   ]
// })

import { contacts, Person, flatContacts } from './contacts'
import { List, Info, details } from './request'
// import { punchList, Punch, state } from './attendance'

interface Member {
  parentId?: number,
  parentName?: string,
  id: number,
  name: string,
  children?: Array<Member>
}

const team = [{
  id: 0,
  name: '杭州复杂美科技有限公司',
  children: [{
    parentId: 0,
    id: 1,
    name: '产品设计部',
    children: [{
      parentId: 1,
      id: 11,
      name: '产品部'
    }, {
      parentId: 1,
      id: 12,
      name: '设计部',
      children: [{
        parentId: 12,
        id: 121,
        name: '设计'
      }]
    }]
  }, {
    parentId: 0,
    id: 2,
    name: '移动部',
    children: [{
      parentId: 2,
      id: 21,
      name: 'IOS部门'
    }]
  }, {
    parentId: 0,
    id: 3,
    name: '运营部'
  }]
}]

function getFaltArray(arr: Array<any>) {
  let newArr: Array<any> = []
  for (let i = 0; i < arr.length; i++) {
    newArr.push(arr[i])
    if (arr[i].children?.length) {
      newArr = newArr.concat(getFaltArray(arr[i].children))
    }
  }
  return newArr
}

const flatTeams = getFaltArray(team)

// getFlatTeams(arr: Array<Member>) {
//   let newArr: Array<Member> = []
//   for (let i=0; i<arr.length; i++) {
//     newArr.push(arr[i])
//     if (arr[i].children?.length) {
//       newArr = newArr.concat(this.getFlatTeams(arr[i].children as Array<Member>))
//     }
//   }
//   return newArr
// },

export {
  team,
  flatTeams,
  contacts,
  flatContacts,
  Person,
  Member,
  List,
  Info,
  details
  // Punch,
  // punchList,
  // state
}
