import {
	WeaTools
} from 'ecCom';

/**
 * 获取tab数据
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const getTabInfo = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/getSystemRightGroupTabInfo', 'GET', params)


/********************* group api *********************/
/**
 * 获取权限组查询条件
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const getAuthorizationGroupCondition = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/getSystemRightGroupCondition', 'GET', params)

/**
 * 获取权限组设置表单
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const getAuthorizationGroupForm = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/getSystemRightGroupForm?is_multilang_set=true', 'GET', params)

/**
 * 获取权限组数据
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const getAuthorizationGroupList = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/getSystemRightGroupList', 'POST', params)

/**
 * 保存权限组
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const saveAuthorizationGroup = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/saveSystemRightGroup', 'POST', params)

/**
 * 删除权限组
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const removeAuthorizationGroup = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/delSystemRightGroup', 'POST', params)
/********************* group api *********************/

/********************* authorization api *********************/
/**
 * 获取权限组查询条件
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const getAuthorizationListCondition = (params = {}) => WeaTools.callApi('/api/hrm/systemrightauthority/getSystemRightAuthorityCondition', 'GET', params)

/**
 * 获取全部权限数据
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const getAuthorizationList = (params = {}) => WeaTools.callApi('/api/hrm/systemrightauthority/getSystemRightAuthorityList', 'POST', params)

/**
 * 保存权限组权限明细
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const saveGroupAuthorizatioRela = (params = {}) => WeaTools.callApi('/api/hrm/systemrightauthority/saveSystemRightAuthority', 'POST', params)

/**
 * 移除权限组权限明细
 * @param  {Object} params [description]
 * @return {[type]}        [description]
 */
export const removeGroupAuthorizatioRela = (params = {}) => WeaTools.callApi('/api/hrm/systemrightauthority/delSystemRightAuthority', 'POST', params)
/********************* authorization api *********************/

/********************* promise api *********************/
/**
 * 初始权限设置化模块数据
 * @return {[type]} [description]
 */
export const initData = () => Promise.all([getTabInfo(), getAuthorizationGroupCondition()])

/**
 * 初始化权限组tab页数据
 * @return {[type]} [description]
 */
export const initAuthorizationGroupData = () => Promise.all([getAuthorizationGroupCondition(), getAuthorizationGroupList()])

/**
 * 初始化权限明细tab页数据
 * @return {[type]} [description]
 */
export const initAuthorizationListData = () => Promise.all([getAuthorizationListCondition(), getAuthorizationList()])

export const initAuthorizationEditDialog = (params = {}) => Promise.all([getAuthorizationGroupForm(params), getAuthorizationListCondition(), getAuthorizationList(params)])
/********************* promise api *********************/

export const getSystemRightRolesCondition = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/getSystemRightRolesCondition', 'GET', params)
export const getSystemRightRolesList = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/getSystemRightRolesList', 'POST', params)
export const getSystemRightRolesForm = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/getSystemRightRolesForm', 'GET', params)
export const addSystemRightRoles = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/addSystemRightRoles', 'POST', params)
export const editSystemRightRoles = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/editSystemRightRoles', 'POST', params)
export const delSystemRightRoles = (params = {}) => WeaTools.callApi('/api/hrm/systemrightgroup/delSystemRightRoles', 'POST', params)