import Vue from 'vue'
import ldapService from './components/ldapService'

/* 异步注册组件 */
require('./custom.less')
/** **************************主菜单******************************/
export default function (filiale) {
  Vue.use(ldapService)

  /* 特殊路由组件，只针对于资源服务*/
  Vue.component('dynamic-ldap', (resolve) => { require(['./components/special/ldapDynamic'], resolve) })
  Vue.component('tab-ldap', (resolve) => { require(['./components/special/ldapTab'], resolve) })
  Vue.component('tabset-ldap', (resolve) => { require(['./components/special/ldapTabset'], resolve) })

  /*   资源服务导航*/
  Vue.component('res-main', (resolve) => { require(['./components/server/ResMain'], resolve) })
  Vue.component('resource-tree', (resolve) => { require(['./components/server/ResourceTree'], resolve) })

  /* 基础组件【资源类型】前台不使用，后台直接路由使用*/
  // 组织
  Vue.component('organization', (resolve) => { require(['./components/base/Organization'], resolve) })
  // 区域
  Vue.component('zone', (resolve) => { require(['./components/base/Zone'], resolve) })
  // 权限
  Vue.component('licensepolicy', (resolve) => { require(['./components/base/Licensepolicy'], resolve) })
  // 部门
  Vue.component('department', (resolve) => { require(['./components/base/Department'], resolve) })
  // 角色
  Vue.component('role', (resolve) => { require(['./components/base/Role'], resolve) })
  // 人员
  Vue.component('user', (resolve) => { require(['./components/base/User'], resolve) })
  // 功能
  Vue.component('function', (resolve) => { require(['./components/base/Function'], resolve) })

  /* 【组织】相关组件*/
  // 所属组织模态框
  Vue.component('organization-modal', (resolve) => { require(['./components/org/OrganizationModal'], resolve) })

  /* 【区域】相关组件*/
  // 添加区域
  Vue.component('add-zone', (resolve) => { require(['./components/zone/AddZone'], resolve) })
  /* 【角色】相关组件*/
  // 所属角色模态框
  Vue.component('role-modal', (resolve) => { require(['./components/role/RoleModal'], resolve) })
  /* 【部门】相关组件*/
  // 所属部门模态框
  Vue.component('department-modal', (resolve) => { require(['./components/department/DepartmentModal'], resolve) })
  /* 【功能】相关组件*/
  // 调整功能位置（前后）
  Vue.component('adjust-fun-pos', (resolve) => { require(['./components/function/AdjustFunPos'], resolve) })

  /* 【授权信息】相关组件*/
  // 功能授权
  Vue.component('func-permissions-modal', (resolve) => { require(['./components/permission/FuncPermissionModal'], resolve) })
  // 数据授权
  Vue.component('data-permission-modal', (resolve) => { require(['./components/permission/DataPermissionModal'], resolve) })
  // 所属角色授权模态框
  Vue.component('role-permissions-modal', (resolve) => { require(['./components/permission/RolePermissionsModal'], resolve) })
  /* 【组织管理】*/
  Vue.component('org-list-manage', (resolve) => { require(['./components/orgmanage/OrgListManage'], resolve) })
  Vue.component('org-list', (resolve) => { require(['./components/orgmanage/OrgList'], resolve) })
  /* 【功能管理】*/
  Vue.component('fun-list-manage', (resolve) => { require(['./components/funmanage/FunListManage'], resolve) })
  Vue.component('fun-list', (resolve) => { require(['./components/funmanage/FunList'], resolve) })
  /* 【功能展示】*/
  Vue.component('fun-display-manage', (resolve) => { require(['./components/displayManage/FunDisplayManage'], resolve) })
  Vue.component('fun-display', (resolve) => { require(['./components/displayManage/FunDisplayList'], resolve) })
  // 功能
  Vue.component('display', (resolve) => { require(['./components/base/Display'], resolve) })
  Vue.component('md-to-html', (resolve) => { require(['./components/base/MdToHtml'], resolve) })
  /* 【部门管理】*/
  Vue.component('dep-list-manage', (resolve) => { require(['./components/departmentmanage/DepListManage'], resolve) })
  Vue.component('dep-list', (resolve) => { require(['./components/departmentmanage/DepList'], resolve) })
  Vue.component('dep-compile-list', (resolve) => { require(['./components/departmentmanage/DepCompileList'], resolve) })
  /* 【角色管理】*/
  Vue.component('role-list-manage', (resolve) => { require(['./components/rolemanage/RoleListManage'], resolve) })
  Vue.component('role-list', (resolve) => { require(['./components/rolemanage/RoleList'], resolve) })
  Vue.component('role-compile-list', (resolve) => { require(['./components/rolemanage/RoleCompileList'], resolve) })
  /* 【人员管理】*/
  Vue.component('staff-list-manage', (resolve) => { require(['./components/staffmanage/StaffListManage'], resolve) })
  Vue.component('staff-list', (resolve) => { require(['./components/staffmanage/StaffList'], resolve) })
  Vue.component('staff-compile-list', (resolve) => { require(['./components/staffmanage/StaffCompileList'], resolve) })
  Vue.component('file-staff-compile-list', (resolve) => { require(['./components/staffmanage/FileStaffCompileList'], resolve) })

  /* 【资源调配】*/
  Vue.component('move-res-manage', (resolve) => { require(['./components/moveres/MoveResManage'], resolve) })
  Vue.component('user-res-list', (resolve) => { require(['./components/moveres/UserResList'], resolve) })
  Vue.component('user-res-history', (resolve) => { require(['./components/moveres/UserResHistory'], resolve) })
  Vue.component('user-res-change', (resolve) => { require(['./components/moveres/ResChange'], resolve) })

  // 分公司特殊页面注册替换
  if (filiale) {
    let filialeComp = require(`./filiale/${filiale}/sale`).specialComp
    for (let key in filialeComp) {
      Vue.component(key, filialeComp[key])
    }
  }
}
