import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/blade-system/role/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
export const grantTree = () => {
  return request({
    url: '/api/blade-system/menu/grant-tree',
    method: 'get',
  })
}

export const grant = (roleIds, menuIds, menuClientIds, dataScopeIds, apiScopeIds, tableOwners) => {
  return request({
    url: '/api/blade-system/role/grant',
    method: 'post',
    data: {
      roleIds,
      menuIds,
      menuClientIds,
      tableOwners,
      dataScopeIds,
      apiScopeIds
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/api/blade-system/role/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/blade-system/role/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/blade-system/role/submit',
    method: 'post',
    data: row
  })
}


export const getRole = (roleIds) => {
  return request({
    url: '/api/blade-system/menu/role-tree-keys',
    method: 'get',
    params: {
      roleIds,
    }
  })
}

export const getRoleTree = () => {
  return request({
    url: '/api/blade-system/dict-biz/dictionary',
    method: 'get',
    params: {
      code: 'maintainer_role',
    }
  })
}

//所属角色
export const roletree = () => {
  return request({
    url: '/api/blade-system/role/tree',
    method: 'get',
    params: {
      tenantId: ''
    }
  })
}

export const getRoleTreeById = (roleId) => {
  return request({
    url: '/api/blade-system/role/tree-by-id',
    method: 'get',
    params: {
      roleId,
    }
  })
}

export const treeUser = (roleId) => {
  return request({
    url: '/api/blade-system/role/treeTow',
    method: 'get',
    params: {
      roleId,
    }
  })
}

//编辑加载项目合同段信息
export const findProjectAndContractList = (params) => {
  return request({
    url: '/api/blade-manager/projectInfo/getProjectAndContractList',
    method: 'get',
    params
  })
}

//编辑新增项目合同段信息
export const saveUserInfoByProjectTow = (params) => {
  return request({
    url: '/api/blade-manager/contractInfo/saveUserInfoByProjectTow',
    method: 'post',
    data: params
  })
}
