import request from '@/utils/request'
import qs from 'qs'
// const authService = '/api/service-ctrl-tower';
const authService = '/service-ctrl-tower-wms'
// const authService = '/api/service-ctrl-tower';
const PlatformSettings = '/service-platform-power-base'
const dataApiBase = '/service-data-api-base'
const baseApi = '/api'

//  查询所有组织
export function getAllOrganization(params = {}) {
  // 不分页查询
  return request({
    url: baseApi + PlatformSettings + '/organization/all', // 不分页查询
    method: 'get',
    params: params
  })
}

// 新增 步骤1
export function addDataAuthHdr(parameter) {
  return request({
    url: baseApi + authService + '/dataAuthHdr/addDataAuthHdr',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function listDataAuthHdr(parameter) {
  // 数据权限查询
  return request({
    url: baseApi + authService + '/dataAuthHdr/listDataAuthHdr',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;'
    }
  })
}

export function updateDataAuthHdr(parameter) {
  // 修改权限汇总
  return request({
    url: baseApi + authService + '/dataAuthHdr/updateDataAuthHdr',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;'
    }
  })
}

export function deleteDataAuthHdr(parameter) {
  // 删除权限
  return request({
    url: baseApi + authService + '/dataAuthHdr/deleteDataAuthHdr',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;'
    }
  })
}

export function listCompanyByAuthId(parameter) {
  // 根据权限ID查询关联单位列表1
  return request({
    url: baseApi + authService + '/dataAuthHdr/listCompanyByAuthId',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;'
    }
  })
}

//  步骤2、3、4共用接口，根据权限ID查询关联单位列表 post
// 查询type=0未关联的单位信息，就要调这个接口http://192.168.1.23:7001/service-data-api-base/search/page
export function searchPage(parameter) {
  // 根据权限ID查询关联单位列表2
  return request({
    url: baseApi + dataApiBase + '/search/page',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;'
    }
  })
}

export function saveDataAuthCompany(parameter) {
  // 保存权限与单位关联
  return request({
    url: baseApi + authService + '/dataAuthHdr/saveDataAuthCompany',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;'
    }
  })
}
