import store from '@/store'

export function getUserData() {
    return store.getters.user_info.employee_detail.role_list;
  }
export function getIsCreator (key) {
	 let is=false;
	 let getUserdatas = getUserData()
	 for(let i in getUserdatas){
		//  console.log(getUserdatas[i])
		 if(key == getUserdatas[i].name){
			is=true;
		 }
	 }
	//  getUserData().forEach(item=>{ 
	// 	 if(key==item.name){
	// 		 is=true;
	// 	 }
	//  })
	 return is
}
export function supremeAuthority () {
	if(getIsCreator('creator')){
		return 'creator'
	}else if(getIsCreator('admin')){
		return 'admin'
	}else if(getIsCreator('point_manager')){
		return 'point_manager'
	}else if(getIsCreator('dept_manager')){
		return 'dept_manager'
	}else if(getIsCreator('employee')){
		return 'employee'
	}
}
export function authoritys (key) {//判断是否为某项权限：this.$authoritys('dept_manager')
	return supremeAuthority() == key
}



// 防抖
//用法
// _debounce(this.XXX(),1000)
export function _debounce (fn, delay) {
    let timer = null
    return function () {
        let arg = arguments
        clearTimeout(timer)
        timer = setTimeout(() => {
          console.log(this,arg)
            fn.apply(this, arg)
        }, delay)
    }
}
