import co from 'co'
export function getImgsrc (name) {
  return "/images/"+name+".gif"
}

export var f
//加载功能列表
let gen = function * (self, util) {
  let getFullTree = yield self.$http.post('/rs/search', {data: {
      source: 'tool.getFullTree(this.getRights().where(row.getName() == $组织管理$||row.getName() == $功能管理$||row.getName() == $部门管理$ || row.getName() == $角色管理$ || row.getName() == $人员管理$|| row.getName() == $资源调配$ ))',
      userid: self.$login.f.id
    }})
  self.functions = util.f = getFullTree.data[0].children[0].children[0].children
}
let ldapResgen = function * (self, util) {
  yield self.$http.post('/rs/search', {data: {
      source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($资源操作$) != -1)',
      userid: self.$login.f.id
    }}).then(ret => {
    let arry=[]
    ret.data.forEach((item) => {
      arry.push(item.name)
    })
    util.f.ldapReslist=arry
  }).catch(ret => {
    console.log(JSON.stringify(ret))
  })
}
// 加载功能列表
export function loadFuns (self) {
  let g = gen(self, this)
  return co(g)
}
// 加载资源权限列表
export function loadRights (self) {
  let g = ldapResgen(self, this)
  return co(g)
}

