import request from '@/utils/request'
function customParamsSerializer(params) {
  let result = '';
  for (let key in params) {
    if (params.hasOwnProperty(key)) {
      if (Array.isArray(params[key])) {
        params[key].forEach((item,index) => {
          result += `${key}[${index}][key]=${item.key}&${key}[${index}][op]=${item.op}&${key}[${index}][value]=${item.value}&`;
        });
      } else {
        result += `${key}=${params[key]}&`;
      }
    }
  }
  return result.slice(0, -1);
}
export function index(params) {
  return request({
    method: 'get',
    url: '/api/oa/config/index',
    params,
    paramsSerializer: customParamsSerializer
  })
}

export function show(params) {
  return request({
    method: 'get',
    url: '/api/oa/config/show',
    params
  })
}

export function save(data, isLoading = true) {
  return request({
    method: 'post',
    url: '/api/oa/config/save',
    data,
    isLoading
  })
}

export function destroy(params, isLoading = true) {
  return request({
    method: 'get',
    url: '/api/oa/config/destroy',
    params,
    isLoading
  })
}
